QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#133114#6629. Travelling TraderPCTprobability#18 93ms67724kbC++1411.7kb2023-08-01 15:44:042024-07-04 01:06:14

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 01:06:14]
  • 评测
  • 测评结果:18
  • 用时:93ms
  • 内存:67724kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-01 15:44:04]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define endl "\n"
typedef pair<int, int> Pii;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i))
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(x) begin(x), end(x)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(s) (s).begin(),(s).end()
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)
#define rever(vec) reverse(vec.begin(), vec.end())
#define sor(vec) sort(vec.begin(), vec.end())
#define fi first
#define FOR_(n) for (ll _ = 0; (_) < (ll)(n); ++(_))
#define FOR(i, n) for (ll i = 0; (i) < (ll)(n); ++(i))
#define se second
#define pb push_back
#define P pair<ll,ll>
#define PQminll priority_queue<ll, vector<ll>, greater<ll>>
#define PQmaxll priority_queue<ll,vector<ll>,less<ll>>
#define PQminP priority_queue<P, vector<P>, greater<P>>
#define PQmaxP priority_queue<P,vector<P>,less<P>>
#define NP next_permutation
//const ll mod = 1000000009;
//const ll mod = 998244353;
const ll mod = 1000000007;
const ll inf = 4100000000000000000ll;
const ld eps = ld(0.00000000001);
static const long double pi = 3.141592653589793;
template<class T>void vcin(vector<T> &n){for(int i=0;i<int(n.size());i++) cin>>n[i];}
template<class T,class K>void vcin(vector<T> &n,vector<K> &m){for(int i=0;i<int(n.size());i++) cin>>n[i]>>m[i];}
template<class T>void vcout(vector<T> &n){for(int i=0;i<int(n.size());i++){cout<<n[i]<<" ";}cout<<endl;}
template<class T>void vcin(vector<vector<T>> &n){for(int i=0;i<int(n.size());i++){for(int j=0;j<int(n[i].size());j++){cin>>n[i][j];}}}
template<class T>void vcout(vector<vector<T>> &n){for(int i=0;i<int(n.size());i++){for(int j=0;j<int(n[i].size());j++){cout<<n[i][j]<<" ";}cout<<endl;}cout<<endl;}
void yes(bool a){cout<<(a?"yes":"no")<<endl;}
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
void possible(bool a){ cout<<(a?"possible":"impossible")<<endl; }
void Possible(bool a){ cout<<(a?"Possible":"Impossible")<<endl; }
void POSSIBLE(bool a){ cout<<(a?"POSSIBLE":"IMPOSSIBLE")<<endl; }
#define FOR_R(i, n) for (ll i = (ll)(n)-1; (i) >= 0; --(i))
template<class T>auto min(const T& a){ return *min_element(all(a)); }
template<class T>auto max(const T& a){ return *max_element(all(a)); }
template<class T,class F>void print(pair<T,F> a){cout<<a.fi<<" "<<a.se<<endl;}
template<class T>bool chmax(T &a,const T b) { if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a,const T b) { if (b<a) { a=b; return 1; } return 0;}
template<class T> void ifmin(T t,T u){if(t>u){cout<<-1<<endl;}else{cout<<t<<endl;}}
template<class T> void ifmax(T t,T u){if(t>u){cout<<-1<<endl;}else{cout<<t<<endl;}}
ll fastgcd(ll u,ll v){ll shl=0;while(u&&v&&u!=v){bool eu=!(u&1);bool ev=!(v&1);if(eu&&ev){++shl;u>>=1;v>>=1;}else if(eu&&!ev){u>>=1;}else if(!eu&&ev){v>>=1;}else if(u>=v){u=(u-v)>>1;}else{ll tmp=u;u=(v-u)>>1;v=tmp;}}return !u?v<<shl:u<<shl;}
ll modPow(ll a, ll n, ll mod) { if(mod==1) return 0;ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }
vector<ll> divisor(ll x){ vector<ll> ans; for(ll i = 1; i * i <= x; i++){ if(x % i == 0) {ans.push_back(i); if(i*i!=x){ ans.push_back(x / ans[i]);}}}sor(ans); return ans; }
ll pop(ll x){return __builtin_popcountll(x);}
ll poplong(ll x){ll y=-1;while(x){x/=2;y++;}return y;}
P hyou(P a){ll x=fastgcd(abs(a.fi),abs(a.se));a.fi/=x;a.se/=x;if(a.se<0){a.fi*=-1;a.se*=-1;}return a;}
P Pplus(P a,P b){ return hyou({a.fi*b.se+b.fi*a.se,a.se*b.se});}
P Ptimes(P a,ll b){ return hyou({a.fi*b,a.se});}
P Ptimes(P a,P b){ return hyou({a.fi*b.fi,a.se*b.se});}
P Pminus(P a,P b){ return hyou({a.fi*b.se-b.fi*a.se,a.se*b.se});}
P Pgyaku(P a){ return hyou({a.se,a.fi});}
template<class T>
struct Sum{
  vector<T> data;
  Sum(const vector<T>& v):data(v.size()+1){
    for(ll i=0;i<v.size();i++) data[i+1]=data[i]+v[i];
  }
  T get(ll l,ll r) const {
    return data[r]-data[l];
  }
};
template<class T>
struct Sum2{
  vector<vector<T>> data;
  Sum2(const vector<vector<T>> &v):data(v.size()+1,vector<T>(v[0].size()+1)){
    for(int i=0;i<v.size();i++) for(int j=0;j<v[i].size();j++) data[i+1][j+1]=data[i][j+1]+v[i][j];
    for(int i=0;i<v.size();i++) for(int j=0;j<v[i].size();j++) data[i+1][j+1]+=data[i+1][j];
  }
  T get(ll x1,ll y1,ll x2,ll y2) const {
    return data[x2][y2]+data[x1][y1]-data[x1][y2]-data[x2][y1];
  }
};
 
void cincout(){
  ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
  cout<< fixed << setprecision(15);
}
vector<ll> g[200000];
vector<ll> ans;
ll use[200000];
ll p[200000];
ll dp[200000][2][3];
vector<ll> way[200000][2][3];
int dfs(int a,int b,int x){
  for(auto e:g[a]){
    if(e==b) continue;
    if(x==0){
      use[a]=1;
      ans.pb(a);
      x=3;
    }
    x=dfs(e,a,x-1);
    x--;
  }
  if(use[a]==0){
    use[a]=1;
    ans.pb(a);
    x=3;
  }
  return x;
}
bool dfs3(int a,int b,int idx){
  if(a==idx){
    ans.pb(a);
    return true;
  }
  for(auto e:g[a]){
    if(e==b) continue;
    if(dfs3(e,a,idx)){
      ans.pb(a);
      return true;
    }
  }
  return false;
}
void dfs2(int a,int b){
  for(auto e:g[a]){
    if(e==b) continue;
    p[e]+=p[a];
    dfs2(e,a);
  }
}
void Merge(vector<ll> &a,vector<ll> b){
  for(auto e:b) a.pb(e);
}
void solve(int i,int b){
  vector<int> v;
  for(auto e:g[i]){
    if(e==b) continue;
    solve(e,i);
    v.pb(e);
  }
  dp[i][0][1]=p[i];
  way[i][0][1]={i};
  dp[i][0][0]=p[i];
  ll idx=0,m=-inf;
  for(auto e:v) if(chmax(m,dp[e][0][0]-dp[e][0][1])) idx=e;
  dp[i][1][1]=p[i];
  for(auto e:v){
    if(e==idx) dp[i][1][1]+=dp[e][0][0];
    else dp[i][1][1]+=dp[e][0][1];
  }
  dp[i][0][0]=dp[i][1][1];
  for(auto e:v){
    if(e!=idx) Merge(way[i][1][1],way[e][0][1]);
  }
  for(auto e:v){
    if(e==idx) Merge(way[i][1][1],way[e][0][0]);
  }
  Merge(way[i][1][1],{i});
  Merge(way[i][0][0],{i});
  for(auto e:v){
    if(e==idx) Merge(way[i][0][0],way[e][1][1]);
  }
  for(auto e:v){
    if(e!=idx) Merge(way[i][0][0],way[e][0][1]);
  }
  ll sum=0;
  for(auto e:v) sum+=dp[e][0][1];
  dp[i][1][2]=p[i];
  way[i][1][2]={i};
  vector<P> A,B,C;
  for(int j=0;j<v.size();j++){
    A.pb({dp[v[j]][0][0]-dp[v[j]][0][1],v[j]});
    B.pb({dp[v[j]][1][1]-dp[v[j]][0][1],v[j]});
    C.pb({dp[v[j]][0][2]-dp[v[j]][0][1],v[j]});
  }
  sor(A);
  sor(B);
  sor(C);
  rever(A);
  rever(B);
  rever(C);
  for(int ii2=0;ii2<int(v.size());ii2++){
    for(int j2=0;j2<int(v.size());j2++){
      for(int k2=0;k2<int(v.size());k2++){
        int ii=A[ii2].se,j=B[j2].se,k=C[k2].se;
        if(ii==j||j==k||k==ii) continue;
        ll sum2=sum;
        sum2-=dp[ii][0][1]+dp[j][0][1]+dp[k][0][1];
        sum2+=dp[ii][0][0]+dp[j][1][1]+dp[k][0][2];
        sum2+=p[i];
        chmax(dp[i][1][2],sum2);
      }
    }
  }
  for(int ii=0;ii<int(v.size());ii++){
    for(int k=0;k<int(v.size());k++){
      if(k==ii) continue;
      ll sum2=sum;
      sum2-=dp[v[ii]][0][1]+dp[v[k]][0][1];
      sum2+=dp[v[ii]][0][0]+dp[v[k]][1][2];
      sum2+=p[i];
      chmax(dp[i][1][2],sum2);
    }
  }
  for(int k=0;k<int(v.size());k++){
    ll sum2=sum;
    sum2-=dp[v[k]][0][1];
    sum2+=dp[v[k]][1][2];
    sum2+=p[i];
    chmax(dp[i][1][2],sum2);
  }
  for(int ii=0;ii<int(v.size());ii++){
    for(int j=0;j<int(v.size());j++){
      for(int k=0;k<int(v.size());k++){
        if(ii==j||j==k||k==ii) continue;
        ll sum2=sum;
        sum2-=dp[v[ii]][0][1]+dp[v[j]][0][1]+dp[v[k]][0][1];
        sum2+=dp[v[ii]][0][0]+dp[v[j]][1][1]+dp[v[k]][0][2];
        sum2+=p[i];
        if(dp[i][1][2]==sum2&&way[i][1][2].size()==1){
          way[i][1][2]={};
          for(int l=0;l<v.size();l++){
            if(l!=ii&&l!=j&&l!=k) Merge(way[i][1][2],way[v[l]][0][1]);
          }
          Merge(way[i][1][2],way[v[ii]][0][0]);
          Merge(way[i][1][2],{i});
          Merge(way[i][1][2],way[v[j]][1][1]);
          Merge(way[i][1][2],way[v[k]][0][2]);
        }
      }
    }
  }
  for(int ii=0;ii<int(v.size());ii++){
    for(int k=0;k<int(v.size());k++){
      if(k==ii) continue;
      ll sum2=sum;
      sum2-=dp[v[ii]][0][1]+dp[v[k]][0][1];
      sum2+=dp[v[ii]][0][0]+dp[v[k]][1][2];
      sum2+=p[i];
      if(dp[i][1][2]==sum2&&way[i][1][2].size()==1){
        if(i==3){
        //  cout<<"IIK"<<" "<<v[ii]<<" "<<v[k]<<endl;
        }
        way[i][1][2]={};
        for(int l=0;l<v.size();l++){
          if(l!=ii&&l!=k) Merge(way[i][1][2],way[v[l]][0][1]);
        }
        Merge(way[i][1][2],way[v[ii]][0][0]);
        Merge(way[i][1][2],{i});
        Merge(way[i][1][2],way[v[k]][1][2]);
      }
    }
  }
  for(int k=0;k<int(v.size());k++){
    ll sum2=sum;
    sum2-=dp[v[k]][0][1];
    sum2+=dp[v[k]][1][2];
    sum2+=p[i];
    if(dp[i][1][2]==sum2&&way[i][1][2].size()==1){
      way[i][1][2]={};
      for(int l=0;l<int(v.size());l++){
        if(l!=k) Merge(way[i][1][2],way[v[l]][0][1]);
      }
      Merge(way[i][1][2],{i});
      Merge(way[i][1][2],way[v[k]][1][2]);
    }
  }
  way[i][0][2]={i};
  dp[i][0][2]=p[i];
  for(int j=0;j<int(v.size());j++){
    for(int k=0;k<int(v.size());k++){
      if(j==k) continue;
      ll sum2=sum;
      sum2-=dp[v[j]][0][1]+dp[v[k]][0][1];
      sum2+=dp[v[j]][1][1]+dp[v[k]][0][2];
      sum2+=p[i];
      chmax(dp[i][0][2],sum2);
    }
  }
  for(int j=0;j<int(v.size());j++){
    for(int k=0;k<int(v.size());k++){
      if(j==k) continue;
      ll sum2=sum;
      sum2-=dp[v[j]][0][1]+dp[v[k]][0][1];
      sum2+=dp[v[j]][1][1]+dp[v[k]][0][2];
      sum2+=p[i];
      if(dp[i][0][2]==sum2&&way[i][0][2].size()==1){
        way[i][0][2]={i};
        Merge(way[i][0][2],way[v[j]][1][1]);
        for(int l=0;l<v.size();l++){
          if(l!=j&&l!=k) Merge(way[i][0][2],way[v[l]][0][1]);
        }
        Merge(way[i][0][2],way[v[k]][0][2]);
      }
    }
  }
  for(int j=0;j<v.size();j++){
    if(chmax(dp[i][0][2],dp[v[j]][1][2]+p[i])){
      way[i][0][2]={i};
      Merge(way[i][0][2],way[v[j]][1][2]);
    }
  }
 /* cout<<i<<endl;
  for(auto e:way[i][1][2]) cout<<e<<" ";
  cout<<endl;
  for(auto e:way[i][0][2]) cout<<e<<" ";
  cout<<endl;
  for(auto e:way[i][0][0]) cout<<e<<" ";
  cout<<endl;
  for(auto e:way[i][1][1]) cout<<e<<" ";
  cout<<endl; */
}
int main() {
  cincout();
  ll n,k;
  cin>>n>>k;
  if(k==3){
    for(int i=0;i<n-1;i++){
      ll a,b;
      cin>>a>>b;
      a--;
      b--;
      g[a].pb(b);
      g[b].pb(a);
    }
    ll sum=0;
    for(int i=0;i<n;i++){
      ll x;
      cin>>x;
      sum+=x;
    }
    dfs(0,-1,0);
    cout<<sum<<endl;
    cout<<n<<endl;
    for(int i=0;i<n;i++) cout<<ans[i]+1<<" ";
    cout<<endl;
    return 0;
  }
  if(k==1){
    for(int i=0;i<n-1;i++){
      ll a,b;
      cin>>a>>b;
      a--;
      b--;
      g[a].pb(b);
      g[b].pb(a);
    }
    for(int i=0;i<n;i++){
      cin>>p[i];
    }
    dfs2(0,-1);
    ll m=-inf,idx=0;
    for(int i=0;i<n;i++) if(chmax(m,p[i])) idx=i;
    cout<<p[idx]<<endl;
    dfs3(0,-1,idx);
    cout<<ans.size()<<endl;
    rever(ans);
    for(auto e:ans) cout<<e+1<<" ";
    cout<<endl;
    return 0;
  }
  if(k==2){
    for(int i=0;i<n-1;i++){
      ll a,b;
      cin>>a>>b;
      a--;
      b--;
      g[a].pb(b);
      g[b].pb(a);
    }
    for(int i=0;i<n;i++){
      cin>>p[i];
    }
    solve(0,-1);
    cout<<dp[0][0][2]<<endl;
    cout<<way[0][0][2].size()<<endl;
    for(auto e:way[0][0][2]) cout<<e+1<<" ";
    cout<<endl;
  }
}

详细

Subtask #1:

score: 2
Accepted

Test #1:

score: 2
Accepted
time: 3ms
memory: 40732kb

input:

2 1
1 2
255959470 961356354

output:

1217315824
2
1 2 

result:

ok correct!

Test #2:

score: 0
Accepted
time: 3ms
memory: 40928kb

input:

1000 1
730 89
762 280
923 523
740 22
679 350
448 769
102 712
154 965
219 32
238 289
484 502
183 311
999 682
806 450
275 101
131 197
749 720
131 937
960 202
503 320
95 262
595 133
809 560
659 451
843 218
258 842
564 316
729 727
413 237
606 531
469 258
612 8
707 539
359 680
957 639
381 708
104 490
234...

output:

95535
17
1 173 449 472 396 545 668 270 981 489 852 836 763 6 218 843 758 

result:

ok correct!

Test #3:

score: 0
Accepted
time: 55ms
memory: 48392kb

input:

200000 1
111811 133538
179217 151840
171974 117009
187613 169656
64662 13136
132434 89348
52802 175565
194821 191312
196047 99457
40339 152969
29669 180026
147677 57771
119598 58048
80707 146623
72232 101624
48109 11800
71536 69
31573 129
24409 17263
1033 148614
66977 149926
138624 87653
141889 1178...

output:

221
35
1 145832 90178 52464 3517 55709 39776 67451 59386 143855 102872 38865 13093 177086 7366 190908 160039 69864 196809 13257 612 171083 182883 14221 93359 52156 27994 103745 151704 138607 5346 14735 29598 89600 128747 

result:

ok correct!

Test #4:

score: 0
Accepted
time: 65ms
memory: 48208kb

input:

200000 1
102636 78442
179388 84484
161437 35179
102313 154299
62439 71542
176361 125315
174129 186376
180886 54947
154823 114239
174647 112385
136495 187134
157035 96260
101101 192444
58209 23947
55494 191600
168007 162648
140149 73180
130665 180633
129328 67380
90262 134914
185905 104220
111321 154...

output:

21795891322
36
1 13557 199188 104317 71891 69787 1221 63258 191536 179446 83510 187880 124824 43888 83237 194602 59080 196038 195977 18490 43421 110298 60011 137785 140692 48345 68279 128780 198550 29394 56331 112092 192199 177180 16418 142142 

result:

ok correct!

Test #5:

score: 0
Accepted
time: 66ms
memory: 50312kb

input:

200000 1
682 75953
92444 160568
113369 93705
154622 193304
149619 128186
104784 48913
131684 161196
25886 151867
89191 19511
99233 137377
104650 120096
64347 93526
111350 71598
7568 120116
123497 76821
25436 190715
99884 33654
109438 69462
165464 2475
163215 34551
33926 85078
101208 193355
50705 828...

output:

99327575017
197
1 178606 82034 53029 10508 21404 203 109187 121716 142023 3901 36728 9916 192913 18250 170199 113960 179753 163922 179588 31797 31645 183321 83207 13973 128176 38001 160968 9055 62809 168173 43933 187373 123795 114656 2192 193151 25062 141855 133596 155793 64049 57320 93903 33957 139...

result:

ok correct!

Test #6:

score: 0
Accepted
time: 52ms
memory: 50872kb

input:

200000 1
91999 92900
195726 58991
132067 99937
168188 152017
188495 19779
105961 45241
53406 75757
85118 170259
46250 47585
132248 8609
195110 32777
164307 95643
133411 739
170952 145623
19297 14414
171045 97619
74663 193421
139543 189434
36319 56453
77520 91164
91469 30021
128798 62259
183807 15271...

output:

9098893435
13
1 164355 56677 150505 174723 115829 88068 105453 199874 190131 165416 182628 114943 

result:

ok correct!

Test #7:

score: 0
Accepted
time: 50ms
memory: 50156kb

input:

200000 1
189797 1
1 148138
1 95067
141831 1
168151 1
1 25692
95612 1
1 135979
1 141581
119622 1
1 131946
86508 1
98799 1
1 189104
1 117526
46338 1
1 166375
1 28026
165221 1
54204 1
1 98743
1 181414
1 34313
1 71302
1 161200
1 146339
1 47014
1 137258
1 57857
1 196493
1 99105
54487 1
104725 1
1 45203
1...

output:

1175349557
2
1 153544 

result:

ok correct!

Test #8:

score: 0
Accepted
time: 52ms
memory: 47252kb

input:

199999 1
56367 178046
1 156890
170478 1
111308 177326
1 188427
1 90169
126610 1
161930 167698
96500 126424
118330 158517
186608 1
95505 107863
1 142887
72279 27494
1 114700
118535 1
68584 63156
97555 19966
39239 1
128030 1
1 86200
66974 1
34616 47100
173578 1
1 117279
89769 43412
1 89670
103573 1
13...

output:

2999144210
3
1 52552 129910 

result:

ok correct!

Test #9:

score: 0
Accepted
time: 93ms
memory: 64308kb

input:

200000 1
95601 67789
174512 65854
198542 123861
153390 92355
141969 168754
177054 101194
25665 15524
131869 168080
171051 30732
97293 119758
103002 59019
141990 124310
161550 116618
2585 170410
132999 38200
99202 98733
73949 155033
144918 64086
1594 34916
37138 165382
13452 170885
136973 62178
15250...

output:

200000000000000
200000
1 47213 179780 132180 145558 41335 179095 156350 24912 104386 94658 54370 97034 108043 73905 141018 157563 199841 176455 147422 87545 190562 135095 24903 62484 36389 156106 45144 120321 4911 173474 102976 13602 68252 7332 141515 59337 182112 124040 38089 15458 161370 41901 144...

result:

ok correct!

Test #10:

score: 0
Accepted
time: 86ms
memory: 57732kb

input:

200000 1
122636 169264
76896 89915
72116 125306
186356 74852
84394 177419
21725 144848
106395 111991
189102 195804
6151 170169
185460 146764
6304 149801
147880 99539
6202 175326
104277 26515
39402 33436
116555 185545
44341 92305
197925 125286
28215 102176
182103 160554
105237 169007
105618 75618
190...

output:

49951940813408
100001
1 88700 18534 14218 21693 84470 150823 121376 192964 139616 11067 93019 188349 55336 13628 87630 31553 28945 29827 140175 179655 10038 38915 99968 89953 72978 102045 45280 176852 171879 100086 93399 183932 84482 111738 112608 136016 101850 19371 96135 54333 95939 2865 140685 13...

result:

ok correct!

Test #11:

score: 0
Accepted
time: 41ms
memory: 48760kb

input:

200000 1
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 53
27 54...

output:

13954593167
18
1 2 5 10 20 40 80 161 323 647 1295 2590 5181 10363 20727 41454 82908 165817 

result:

ok correct!

Subtask #2:

score: 7
Accepted

Test #12:

score: 7
Accepted
time: 3ms
memory: 40728kb

input:

2 2
2 1
243296356 635616793

output:

878913149
2
1 2 

result:

ok correct!

Test #13:

score: 0
Accepted
time: 5ms
memory: 40924kb

input:

10 2
6 4
3 7
5 10
6 10
8 2
3 9
3 5
4 2
1 4
2 4 2 5 5 4 2 3 4 2

output:

33
10
1 6 5 9 7 3 10 4 2 8 

result:

ok correct!

Test #14:

score: 0
Accepted
time: 3ms
memory: 40772kb

input:

200 2
150 170
21 33
96 152
143 26
136 70
92 159
34 164
163 182
74 115
93 61
151 83
81 119
10 146
114 170
39 83
139 4
173 41
193 96
87 57
14 164
107 51
45 15
157 17
43 183
96 30
11 137
55 18
138 81
87 12
112 122
159 82
195 185
75 71
16 191
33 88
70 195
149 114
106 160
96 118
92 44
9 141
107 143
151 2...

output:

57921623677
100
1 135 83 39 151 179 194 89 27 112 40 125 180 120 117 122 99 72 15 199 36 127 62 78 25 129 45 21 88 162 94 138 193 170 59 149 110 28 171 114 96 105 131 33 12 53 70 76 159 44 24 178 17 41 67 173 186 42 116 92 82 197 101 5 32 121 87 29 198 64 93 19 141 8 126 37 100 3 9 108 52 61 54 14 1...

result:

ok correct!

Test #15:

score: 0
Accepted
time: 2ms
memory: 40824kb

input:

200 2
33 5
171 115
70 64
38 42
123 154
167 183
152 177
36 102
98 116
125 187
61 148
143 136
62 169
102 142
86 189
115 100
85 172
136 50
158 113
133 5
10 108
90 178
90 21
127 28
122 189
115 18
83 109
197 11
53 70
191 141
166 90
70 9
74 148
160 7
186 151
197 86
147 82
107 161
122 140
110 58
179 25
107...

output:

47106979559
87
1 7 51 111 130 67 160 52 189 62 48 127 126 138 20 58 152 149 33 133 5 24 78 177 135 193 175 110 64 53 80 36 196 155 76 9 156 65 70 13 184 106 117 119 191 154 88 73 139 174 59 4 27 170 123 141 120 167 145 37 129 10 118 108 39 183 136 143 50 146 15 34 115 95 66 100 171 71 165 18 40 47 1...

result:

ok correct!

Test #16:

score: 0
Accepted
time: 0ms
memory: 40776kb

input:

200 2
139 197
14 69
160 138
115 60
1 141
176 33
94 88
108 26
106 20
96 60
126 180
171 110
140 91
138 63
57 183
42 62
126 163
126 64
87 167
22 142
190 112
27 120
187 109
83 111
23 196
95 47
105 177
96 170
192 113
136 188
24 198
116 137
53 177
178 38
30 158
125 64
123 132
36 114
77 192
125 165
194 7
9...

output:

73032451334
133
1 141 50 7 75 194 65 53 124 105 177 139 122 134 46 16 197 14 114 83 99 193 120 67 22 70 175 51 32 101 107 36 91 146 189 43 90 15 191 95 144 172 73 174 45 167 87 159 81 109 4 25 140 2 199 149 188 39 143 127 10 17 136 3 165 24 158 96 62 186 54 182 155 184 78 157 121 42 60 170 82 198 12...

result:

ok correct!

Test #17:

score: 0
Accepted
time: 4ms
memory: 40768kb

input:

200 2
182 43
15 179
37 173
45 38
62 4
131 151
83 188
84 58
183 148
155 59
141 133
128 19
191 170
129 87
67 156
120 199
94 11
162 27
175 86
73 50
143 94
81 103
84 120
12 19
59 38
48 34
127 41
196 87
135 69
43 119
54 176
180 112
89 60
67 117
149 18
53 61
12 1
46 67
25 38
8 52
119 51
162 197
12 31
166 ...

output:

63859058076
111
1 31 12 30 158 19 189 180 29 36 112 85 66 124 128 45 25 3 18 69 151 59 179 15 5 155 171 65 33 7 38 181 4 187 22 144 140 91 54 192 111 26 184 136 165 191 120 58 70 84 170 118 56 196 90 122 129 127 11 143 95 132 163 44 94 47 57 20 83 87 93 8 76 123 60 43 51 80 88 160 64 167 63 119 182 ...

result:

ok correct!

Test #18:

score: 0
Accepted
time: 0ms
memory: 40752kb

input:

200 2
12 76
61 106
151 109
163 180
11 135
109 179
35 199
86 104
82 109
80 70
15 123
180 154
134 91
187 81
167 4
27 71
174 101
124 127
154 29
173 175
172 61
59 109
53 55
76 55
174 67
50 169
180 32
1 182
126 3
148 146
58 127
26 181
189 47
10 156
120 112
157 149
136 166
146 122
59 17
99 136
55 138
49 1...

output:

59693686065
120
1 186 116 108 104 86 183 58 102 87 47 146 177 148 122 60 190 189 46 57 5 79 163 32 2 154 119 29 180 98 178 176 14 192 101 120 114 107 169 97 25 50 196 112 44 88 48 197 76 138 158 24 53 159 41 55 156 143 128 59 74 164 139 28 9 65 89 135 155 142 51 167 18 90 100 16 38 4 42 11 199 36 92...

result:

ok correct!

Test #19:

score: 0
Accepted
time: 3ms
memory: 38976kb

input:

200 2
33 83
16 197
177 12
71 47
85 60
34 49
96 78
30 39
63 122
95 17
168 74
89 83
62 134
45 166
48 6
178 91
151 72
153 47
104 174
86 140
33 134
24 51
129 71
48 94
141 93
64 118
155 50
43 28
182 92
31 142
105 56
156 100
83 69
179 90
140 127
186 148
16 47
175 4
123 173
27 50
154 186
107 98
200 20
66 6...

output:

61122293114
124
1 173 190 50 55 155 152 27 101 123 48 172 111 47 197 126 163 58 125 102 16 71 153 59 180 165 149 94 11 195 6 63 88 53 124 41 65 135 22 187 96 37 26 68 181 122 174 103 87 116 43 21 60 98 177 90 42 44 13 72 185 151 12 75 31 107 85 113 52 28 106 15 104 112 69 89 33 139 14 8 20 67 196 16...

result:

ok correct!

Test #20:

score: 0
Accepted
time: 4ms
memory: 40784kb

input:

200 2
91 28
137 24
181 33
82 19
90 182
180 77
2 6
190 176
100 181
13 140
52 77
85 189
28 29
176 22
7 180
55 176
99 113
6 93
28 51
117 44
180 127
114 174
102 92
13 14
129 181
80 24
95 28
181 195
162 4
28 188
55 162
59 131
47 45
145 176
136 197
145 57
159 117
143 106
192 106
126 28
43 23
51 73
109 28
...

output:

48771917800
98
1 91 29 51 95 188 109 64 79 126 135 21 166 113 99 26 46 36 130 40 104 103 28 190 22 55 145 97 12 117 11 133 62 13 63 172 198 19 143 192 49 165 125 50 106 82 90 160 155 69 158 176 6 24 151 136 8 92 37 131 59 102 81 84 65 17 30 93 129 48 23 43 181 25 96 199 132 67 41 78 71 180 184 154 1...

result:

ok correct!

Test #21:

score: 0
Accepted
time: 3ms
memory: 41092kb

input:

200 2
117 30
120 159
129 100
29 57
57 71
96 72
53 153
171 96
138 197
13 72
142 74
64 85
148 150
145 106
190 23
198 177
58 127
163 67
32 183
26 155
94 159
170 70
12 181
13 24
157 116
163 40
126 76
195 193
92 9
4 113
196 135
196 154
110 56
79 196
50 14
68 46
143 36
131 50
46 2
179 160
92 31
61 3
169 9...

output:

70064073402
147
1 197 18 165 6 168 98 180 136 122 47 121 167 103 48 138 123 104 163 73 162 81 67 21 161 174 189 119 145 170 16 193 93 175 141 8 76 63 34 159 105 44 143 172 65 36 82 94 200 126 137 155 195 70 75 106 129 116 157 182 7 100 128 144 37 64 23 160 140 150 111 110 56 125 41 97 148 133 190 43...

result:

ok correct!

Test #22:

score: 0
Accepted
time: 3ms
memory: 40800kb

input:

200 2
29 106
175 25
175 87
144 67
51 68
118 71
184 165
74 86
127 64
12 68
180 186
53 164
193 64
144 98
106 122
44 144
178 144
144 94
17 64
106 89
199 1
64 108
28 61
39 199
106 28
23 148
69 106
66 74
164 68
92 185
144 68
78 143
168 126
148 196
72 9
74 160
106 128
63 148
121 178
157 68
72 148
104 144
...

output:

64091222931
110
1 80 84 39 199 67 98 44 178 94 104 31 140 37 96 151 81 143 26 169 134 92 165 111 18 74 16 47 50 103 175 97 115 182 167 64 8 68 5 53 164 51 12 157 145 83 137 82 42 177 112 123 54 141 144 29 122 89 28 69 128 146 3 129 75 190 101 40 158 36 118 71 172 20 200 65 188 48 106 148 130 19 155 ...

result:

ok correct!

Test #23:

score: 0
Accepted
time: 4ms
memory: 40812kb

input:

200 2
161 12
189 84
46 61
69 75
139 170
146 21
162 91
20 125
40 78
152 25
81 140
15 138
39 184
85 183
29 59
166 126
127 24
125 56
94 26
92 37
33 196
168 16
75 64
148 57
112 142
185 46
49 195
76 18
88 79
70 125
194 136
12 154
77 195
10 2
86 155
90 170
83 67
38 179
172 175
198 191
11 51
67 42
25 93
18...

output:

82840243479
163
1 151 57 165 147 148 60 17 97 110 198 121 191 71 143 101 61 185 31 173 116 192 131 33 100 46 134 152 25 52 5 93 99 114 98 43 197 81 144 64 69 12 55 68 174 199 164 133 66 35 180 72 154 161 75 8 39 140 14 188 117 13 19 132 177 85 183 169 80 200 21 189 7 182 9 88 79 84 74 146 145 37 92 ...

result:

ok correct!

Test #24:

score: 0
Accepted
time: 7ms
memory: 40796kb

input:

200 2
19 106
54 55
83 185
106 178
78 194
51 66
133 200
106 58
106 35
163 150
50 104
96 105
124 105
41 66
124 22
54 106
27 93
106 133
196 124
58 83
106 193
124 110
194 165
150 124
194 13
42 149
127 154
121 159
106 26
100 181
124 82
1 80
177 45
69 100
54 189
61 19
70 106
134 175
168 134
6 112
44 100
1...

output:

60321563038
110
1 19 178 58 35 54 133 193 26 70 155 40 138 93 182 12 167 128 98 113 195 180 174 56 84 188 191 114 6 46 45 31 154 194 156 78 165 13 57 111 142 90 116 71 29 10 106 181 69 44 145 148 88 190 173 198 152 143 8 158 104 101 87 38 159 121 141 68 36 140 81 161 100 124 144 153 199 136 117 109 ...

result:

ok correct!

Test #25:

score: 0
Accepted
time: 3ms
memory: 40836kb

input:

200 2
104 32
163 164
138 166
140 114
144 134
193 184
94 25
196 140
119 160
29 34
170 7
175 60
122 185
85 133
9 53
95 89
171 158
34 155
67 32
73 125
167 128
27 48
157 119
105 2
13 142
134 120
71 118
66 117
182 59
156 43
84 91
126 80
55 192
34 68
64 194
131 75
81 151
117 102
145 104
99 4
3 65
91 35
79...

output:

80439812057
153
1 136 65 3 44 109 45 118 99 79 69 4 71 167 88 128 41 165 64 194 125 197 49 133 164 176 62 108 156 58 43 163 73 93 14 178 94 25 123 182 59 115 19 144 89 120 122 126 168 60 7 46 131 184 100 162 158 171 38 26 75 121 170 172 175 188 51 80 103 185 134 189 140 127 57 154 169 8 15 137 147 1...

result:

ok correct!

Test #26:

score: 0
Accepted
time: 5ms
memory: 40952kb

input:

200 2
105 64
190 149
84 15
184 93
52 80
182 129
160 51
108 184
105 167
9 77
61 80
109 84
161 188
121 2
121 20
175 60
80 154
105 88
25 60
88 10
41 123
105 135
99 184
100 98
152 105
1 75
184 199
163 102
63 88
56 184
83 13
101 123
107 50
120 42
8 78
105 45
105 121
184 92
105 129
136 124
123 139
88 19
7...

output:

51611310581
104
1 33 5 75 64 167 88 135 152 45 121 129 57 46 27 147 102 106 198 84 86 161 172 165 141 50 130 127 189 136 159 51 60 80 12 200 176 52 61 154 98 114 67 30 85 31 111 16 128 4 104 17 162 26 8 74 174 97 32 190 105 41 101 139 96 90 155 77 113 185 193 143 177 68 166 181 144 72 14 123 184 40 ...

result:

ok correct!

Test #27:

score: 0
Accepted
time: 45ms
memory: 38772kb

input:

200 2
8 1
1 22
39 1
168 1
136 1
197 1
1 142
1 4
18 1
187 1
1 74
156 1
1 94
118 1
1 86
1 76
30 1
52 1
1 42
144 1
105 1
64 1
1 9
137 1
112 1
101 1
75 1
1 113
1 164
1 29
1 60
1 167
1 135
1 192
196 1
48 1
1 179
170 1
158 1
1 145
47 1
1 98
143 1
184 1
84 1
72 1
20 1
109 1
1 106
1 3
1 79
55 1
1 77
102 1
1...

output:

89576768884
200
1 8 39 168 136 197 142 4 18 187 74 156 94 118 86 76 30 52 42 144 105 64 9 137 112 101 75 113 164 29 60 167 135 192 196 48 179 170 158 145 47 98 143 184 84 72 20 109 106 3 79 55 77 102 126 7 138 175 120 115 17 159 63 161 181 163 6 70 23 176 93 38 173 160 5 125 186 153 26 28 46 189 41 ...

result:

ok correct!

Test #28:

score: 0
Accepted
time: 13ms
memory: 40944kb

input:

199 2
1 106
198 165
176 34
59 39
1 34
151 36
78 85
1 109
48 4
1 13
165 1
73 163
159 126
150 106
1 33
82 103
17 180
1 151
46 87
1 111
195 1
1 164
25 23
135 161
1 107
1 2
11 58
97 1
170 1
71 57
72 157
1 158
1 186
153 1
1 60
29 1
27 52
50 1
162 122
64 1
95 1
1 75
160 142
134 81
77 155
79 1
1 119
30 169...

output:

101902858721
102
1 121 181 106 34 109 13 165 33 151 111 195 164 107 2 97 170 158 186 153 60 29 50 64 95 75 79 119 157 120 132 128 183 77 90 144 35 168 141 83 45 103 184 161 126 171 99 18 48 180 174 163 118 160 78 112 169 96 52 193 134 136 67 140 69 137 20 76 23 89 162 91 190 56 93 125 177 80 84 131 ...

result:

ok correct!

Test #29:

score: 0
Accepted
time: 3ms
memory: 40772kb

input:

197 2
24 1
65 24
129 58
92 96
61 1
42 18
95 3
167 168
147 110
2 172
143 156
115 110
1 67
158 127
99 134
126 89
30 95
85 13
1 149
128 106
81 118
137 100
146 88
105 1
76 105
153 9
96 123
67 49
61 186
1 9
120 46
51 79
79 1
77 195
17 11
117 7
114 106
135 21
59 1
100 122
179 67
158 184
16 83
96 1
191 75
...

output:

55959842378
56
1 78 181 133 23 24 61 67 149 105 9 79 59 96 121 110 10 100 75 126 158 42 143 88 93 188 13 169 16 53 29 167 46 17 108 182 58 7 197 187 2 118 36 99 21 40 106 162 195 90 95 161 32 97 163 107 

result:

ok correct!

Test #30:

score: 0
Accepted
time: 4ms
memory: 40968kb

input:

196 2
83 40
1 26
46 179
44 181
73 123
46 128
150 168
150 151
134 48
91 48
47 79
161 46
114 35
120 35
183 48
47 66
154 69
150 45
74 40
32 63
48 1
22 18
41 26
1 46
78 47
88 40
152 47
191 44
60 46
57 48
67 73
150 38
48 10
126 89
44 23
44 56
31 126
196 150
80 35
46 25
129 32
20 22
75 44
73 145
170 154
2...

output:

26055322292
42
1 129 158 65 54 193 5 8 37 111 2 102 106 189 63 32 26 48 46 154 126 35 22 44 47 73 40 150 168 45 38 196 93 135 98 166 104 15 115 109 124 151 

result:

ok correct!

Test #31:

score: 0
Accepted
time: 0ms
memory: 41432kb

input:

200 2
119 95
47 18
176 194
73 36
90 105
24 29
79 39
53 98
130 111
42 125
158 15
100 60
128 149
76 41
134 1
108 2
94 157
196 43
145 100
11 9
144 175
37 40
5 120
49 117
165 134
158 84
142 51
82 167
157 108
175 161
50 22
177 35
95 118
77 116
33 131
194 27
116 128
189 72
28 192
130 112
26 4
187 121
97 4...

output:

200000000000
200
1 134 165 110 89 187 121 78 61 122 9 11 173 186 56 30 20 74 69 168 6 93 198 12 191 144 175 161 32 79 39 8 27 194 176 113 148 10 52 150 181 124 99 57 73 36 13 88 192 28 23 183 15 158 84 70 71 166 188 151 140 169 98 53 64 139 43 196 50 22 87 54 156 162 109 189 72 199 159 179 25 40 37 ...

result:

ok correct!

Test #32:

score: 0
Accepted
time: 3ms
memory: 41180kb

input:

200 2
7 176
162 197
197 66
22 23
177 157
49 22
65 171
119 124
155 193
15 41
34 105
61 102
126 31
36 195
14 192
173 57
75 4
104 174
141 20
185 123
199 145
18 9
110 200
148 9
90 137
35 19
106 139
150 172
91 47
168 180
104 70
169 200
161 66
129 114
66 118
71 200
160 133
31 196
36 11
195 49
112 51
22 15...

output:

99918618520
200
1 189 171 65 102 24 199 183 34 81 137 150 124 68 170 74 73 11 195 198 22 55 188 109 91 159 173 154 19 83 86 129 63 33 139 108 160 100 194 134 193 136 64 187 200 80 111 44 175 141 54 3 31 87 28 78 15 98 12 178 9 69 4 95 104 5 142 128 132 153 14 177 130 39 66 79 162 158 85 48 138 17 30...

result:

ok correct!

Test #33:

score: 0
Accepted
time: 0ms
memory: 40988kb

input:

200 2
108 103
141 45
176 16
96 38
130 106
18 176
61 23
38 22
154 198
83 123
77 52
102 188
133 125
123 116
120 45
164 195
174 48
163 54
74 31
199 175
79 110
137 173
182 153
22 1
65 54
60 16
187 144
45 188
99 152
17 118
64 118
75 163
74 141
181 184
39 175
172 117
118 100
138 164
172 99
52 162
200 80
1...

output:

97817235416
200
1 55 76 3 38 66 112 192 174 61 127 2 99 117 168 40 19 187 78 178 180 47 151 15 200 60 128 160 176 93 90 105 134 108 179 10 133 140 183 98 118 106 104 86 81 87 88 150 25 49 147 42 123 28 119 70 173 153 56 185 142 77 162 53 197 92 91 167 199 39 171 156 154 121 94 89 181 95 190 26 110 1...

result:

ok correct!

Test #34:

score: 0
Accepted
time: 3ms
memory: 40996kb

input:

200 2
185 93
20 134
91 82
108 129
123 164
104 56
146 113
110 5
83 87
106 63
67 199
41 108
114 133
172 99
57 132
46 199
32 45
170 191
123 200
53 141
124 186
44 162
65 159
85 195
196 19
7 134
64 35
88 58
23 28
30 20
76 11
176 167
36 124
88 148
175 29
31 151
128 4
103 171
50 79
71 127
84 8
36 4
175 109...

output:

92546968269
200
1 70 137 78 161 40 147 179 109 33 56 104 175 111 86 29 14 72 153 177 168 197 83 87 73 38 146 113 67 126 65 159 199 66 13 46 16 122 18 62 51 181 80 74 171 125 98 103 188 55 85 195 20 160 6 30 134 116 35 64 7 68 99 172 102 118 71 127 136 101 52 120 157 22 176 167 91 144 48 193 82 156 1...

result:

ok correct!

Test #35:

score: 0
Accepted
time: 5ms
memory: 41088kb

input:

200 2
186 20
197 94
138 143
75 2
6 102
114 98
195 131
151 62
33 77
85 149
158 164
30 38
21 93
177 133
72 188
145 52
68 176
194 57
118 103
91 112
178 81
63 169
31 155
92 133
29 166
99 15
65 75
159 147
79 55
45 23
139 180
38 119
3 75
114 127
117 112
146 161
99 48
37 132
148 193
178 179
71 116
140 11
1...

output:

82875113284
152
1 75 103 118 35 3 64 33 183 150 113 184 46 96 19 182 191 5 157 49 37 132 175 115 84 57 161 86 53 146 119 136 16 141 105 142 38 12 151 62 40 47 30 11 102 6 160 140 27 55 167 120 50 79 83 131 67 90 22 195 130 23 68 176 101 185 61 158 116 71 154 124 156 171 152 56 129 174 92 169 177 123...

result:

ok correct!

Test #36:

score: 0
Accepted
time: 0ms
memory: 41036kb

input:

200 2
140 198
32 90
73 76
75 155
54 65
192 80
60 37
103 28
120 118
87 118
174 30
174 191
156 138
187 47
200 17
106 179
80 2
137 71
18 75
146 80
53 153
128 82
31 89
180 110
36 82
129 186
180 36
125 53
31 94
124 189
133 83
151 94
175 48
172 97
34 74
64 87
157 139
155 9
33 126
90 160
199 48
25 86
156 2...

output:

79408775618
143
1 140 129 143 91 136 186 130 76 62 145 132 158 92 164 53 189 124 194 154 125 68 16 86 25 46 23 141 40 89 94 151 127 152 31 65 190 134 197 147 184 54 38 139 74 34 84 70 66 166 60 83 88 111 183 133 52 174 165 176 56 77 10 55 99 168 13 169 114 135 96 90 200 17 8 182 14 167 48 126 33 50 ...

result:

ok correct!

Test #37:

score: 0
Accepted
time: 5ms
memory: 40732kb

input:

200 2
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 53
27 54
27...

output:

31861270500
55
1 7 6 27 26 107 106 53 52 13 12 3 2 8 9 39 38 153 152 76 77 19 18 4 5 22 23 94 95 190 191 47 46 11 10 40 41 167 166 83 82 20 21 85 84 168 169 42 43 173 172 86 87 174 175 

result:

ok correct!

Test #38:

score: 0
Accepted
time: 4ms
memory: 40768kb

input:

200 2
1 2
1 3
1 4
2 5
2 6
2 7
3 8
3 9
3 10
4 11
4 12
4 13
5 14
5 15
5 16
6 17
6 18
6 19
7 20
7 21
7 22
8 23
8 24
8 25
9 26
9 27
9 28
10 29
10 30
10 31
11 32
11 33
11 34
12 35
12 36
12 37
13 38
13 39
13 40
14 41
14 42
14 43
15 44
15 45
15 46
16 47
16 48
16 49
17 50
17 51
17 52
18 53
18 54
18 55
19 56...

output:

26748477707
43
1 11 13 12 105 106 104 35 36 37 4 3 2 18 19 17 153 154 152 51 50 52 6 7 5 47 48 49 146 147 148 16 14 15 132 133 131 44 46 45 134 136 135 

result:

ok correct!

Subtask #3:

score: 0
Time Limit Exceeded

Dependency #2:

100%
Accepted

Test #39:

score: 3
Accepted
time: 6ms
memory: 41656kb

input:

2000 2
1653 466
455 1262
319 394
823 998
1135 313
244 809
563 850
1865 1303
609 1531
302 1084
504 163
1475 1799
534 258
1597 413
1161 330
676 1694
1315 1619
1646 32
1629 161
280 1765
102 877
474 503
1162 491
1182 1505
532 1820
525 1836
1682 808
1026 80
809 1334
1376 1783
401 708
1323 1443
1242 1215
...

output:

176031446963
333
1 1438 239 459 410 1805 937 1479 605 1216 1325 313 1818 198 242 126 423 1142 1101 438 838 467 512 1133 1471 872 375 783 1912 915 1100 1719 435 877 142 1892 334 325 632 457 1411 658 1284 525 482 287 18 374 82 1574 1003 1870 1452 1046 148 1208 338 660 326 1766 1919 652 97 1726 1161 15...

result:

ok correct!

Test #40:

score: 0
Accepted
time: 0ms
memory: 41500kb

input:

2000 2
892 750
281 1593
1698 1268
1500 653
348 1393
1617 797
1044 680
1517 1883
1081 1003
293 948
412 478
1733 690
1785 1377
1902 1304
1674 1565
1350 131
242 573
1778 275
296 1177
1090 1862
1503 1175
1620 207
1441 323
181 449
219 1911
671 1713
606 1360
1558 834
562 1576
1212 1077
257 1606
790 1496
1...

output:

202483759818
403
1 25 186 1506 1577 563 629 762 1100 1452 687 801 381 1190 1638 36 1952 560 1098 1461 108 668 1095 787 1726 1042 1068 915 1569 772 430 1572 552 1384 348 1157 1393 784 1197 553 650 1680 1868 1787 691 1462 1287 1437 1798 1775 897 808 1586 1729 1199 524 999 439 1196 1792 565 1478 1596 9...

result:

ok correct!

Test #41:

score: 0
Accepted
time: 4ms
memory: 41480kb

input:

2000 2
1581 867
670 1948
1286 1189
292 1357
1538 951
691 1646
502 1385
1071 812
482 469
1853 1303
614 774
363 62
506 91
718 951
1327 306
170 23
128 495
1841 263
178 588
271 252
930 1147
552 1150
1550 1584
685 1699
405 1353
1948 510
1632 327
1854 1167
1327 591
112 800
482 305
598 7
922 1645
1737 1811...

output:

184825610246
359
1 172 394 1959 1661 1191 1453 241 1811 1449 415 1773 934 13 1737 1304 59 1621 1152 323 924 670 598 1810 1558 324 936 510 931 158 1860 827 1630 1952 247 805 574 697 1491 1377 1484 1609 1042 336 1595 254 647 1891 1948 1781 86 1041 90 1060 1032 58 3 992 1770 1641 1124 839 1655 45 1711 ...

result:

ok correct!

Test #42:

score: 0
Accepted
time: 5ms
memory: 41388kb

input:

2000 2
1217 1905
1210 453
765 261
1635 1637
1867 1564
1876 1141
1867 283
1093 1385
677 1050
284 1377
228 1393
541 1985
884 242
1714 1304
118 15
1992 1098
449 181
1549 246
84 1198
913 1522
666 1685
1704 263
589 1407
1870 906
1411 561
1252 562
282 17
1137 372
764 1171
1721 172
1990 1755
1231 1948
201 ...

output:

222905521782
416
1 1544 1036 1655 549 1787 1958 1080 830 763 1901 1414 1617 189 561 1647 1290 982 1694 470 1932 1012 695 1411 1371 620 434 602 593 1986 813 257 83 1085 1457 100 1733 1899 1322 1974 1011 1554 1994 970 818 14 1340 1403 5 1213 687 1305 193 1072 1171 372 215 1043 1422 683 141 1970 1511 1...

result:

ok correct!

Test #43:

score: 0
Accepted
time: 3ms
memory: 41668kb

input:

2000 2
989 1552
460 285
670 1653
190 1210
736 941
1555 647
648 363
1500 1908
241 1143
1702 1181
266 1622
409 955
1442 1033
1236 447
194 1312
463 1304
1994 397
835 564
22 982
1214 562
813 1812
1396 783
191 1449
1760 691
103 1289
493 439
333 1401
283 884
1419 832
1561 277
1582 294
1183 925
7 529
191 1...

output:

176264452857
344
1 1542 146 397 680 376 1823 469 1994 1497 527 309 1688 1734 1766 384 618 30 4 742 22 1684 604 982 943 1136 1595 940 1798 1302 959 776 733 1758 1547 143 554 144 685 1723 1333 339 1299 1086 682 353 1166 1517 1783 657 531 343 1594 1241 662 129 96 190 1300 1487 1733 1597 522 510 857 467...

result:

ok correct!

Test #44:

score: 0
Accepted
time: 8ms
memory: 42712kb

input:

2000 2
1900 687
259 1748
582 1542
1844 470
1752 1845
202 37
1206 807
646 269
1687 681
1482 1630
930 446
391 617
1424 1798
1481 1762
820 295
1263 1766
474 210
372 1407
117 1854
199 216
1779 789
937 555
1494 1909
1824 1319
1001 1938
144 45
785 196
1135 636
390 1866
1404 206
1790 524
1734 663
1604 1767...

output:

362696256044
704
1 1488 461 1747 1736 1234 1316 324 1677 1366 1981 819 1350 448 1561 1149 831 1933 1698 1974 527 796 951 218 1450 869 1398 1069 920 1723 361 911 455 826 1188 1273 1759 241 506 85 1639 697 125 1646 629 1419 1567 1826 55 1493 207 519 1787 1363 862 159 651 1514 372 1964 1407 1208 1459 7...

result:

ok correct!

Test #45:

score: 0
Accepted
time: 8ms
memory: 41236kb

input:

2000 2
284 498
512 963
418 534
206 1186
1506 1397
1511 459
992 742
1644 1013
1474 1397
1942 1941
1673 1229
1384 442
1397 1756
1876 280
2000 1932
1397 1993
1217 1474
1774 1204
737 1785
1356 1384
1473 1116
2000 1812
1617 1739
17 1979
229 1979
723 492
621 227
358 550
206 376
440 1675
1393 1790
909 341
...

output:

203246075730
402
1 532 1248 1778 1610 423 1886 988 1047 1672 1192 104 15 87 437 810 1055 1619 1470 927 140 932 1606 1331 1737 686 362 1811 530 277 477 1004 1239 1467 1608 1009 701 468 1488 847 1961 1648 1142 812 378 454 1255 1084 1771 1638 1048 906 347 440 417 1426 1432 193 1861 487 819 411 108 7 12...

result:

ok correct!

Test #46:

score: 0
Accepted
time: 6ms
memory: 42704kb

input:

2000 2
1237 1826
571 1212
1932 1106
88 1218
764 916
1880 854
700 1803
585 679
891 1587
712 1921
233 738
668 1927
1167 918
432 1789
1377 1585
1344 916
692 1546
1749 1947
1571 1869
1484 1846
1531 1997
694 1957
758 567
1649 181
3 1062
987 1320
533 1487
1402 1085
936 1807
1526 752
183 1513
403 187
1796 ...

output:

404938855945
815
1 1556 348 1319 279 523 727 634 1272 755 175 1938 886 1429 1840 952 1315 1416 1914 1793 1311 613 200 812 796 1637 152 383 339 1002 1343 1522 535 392 364 210 1375 1304 178 370 1799 399 1967 938 287 1544 1716 198 121 442 1626 1043 734 1957 1723 581 911 1452 58 262 887 231 1194 846 258...

result:

ok correct!

Test #47:

score: 0
Accepted
time: 25ms
memory: 41252kb

input:

2000 2
593 1134
610 1128
274 1314
1799 123
1738 1823
523 1117
1272 529
1439 225
1275 450
286 1117
34 365
935 1460
1200 1008
475 1622
854 819
1632 890
996 1743
237 1665
1669 1985
1767 1934
1799 783
12 1601
342 1623
924 144
1269 146
1799 340
1280 1669
1270 1128
950 1245
1686 1730
1117 1202
178 393
180...

output:

273811282141
553
1 627 1219 1386 403 1720 1169 1791 1744 766 1344 1288 1524 1976 1501 968 317 70 729 912 1142 1685 1332 226 641 1018 795 1380 334 573 602 1126 1348 435 1793 1617 129 812 577 903 1162 1051 1559 1748 52 438 199 582 1000 181 493 674 1969 967 592 1337 407 1743 237 1910 1296 225 1439 664 ...

result:

ok correct!

Test #48:

score: -3
Time Limit Exceeded

input:

2000 2
1383 1
1 1410
1 1106
1154 1
1 1202
1794 1
1512 1
1744 1
221 1
1 917
1637 1
1 118
1 423
164 1
1 1881
479 1
1 1029
1 567
1 193
1 1364
1 45
1458 1
692 1
1765 1
807 1
897 1
43 1
1243 1
1 681
1272 1
1 579
122 1
1 1241
1299 1
1558 1
1 88
726 1
1 654
1900 1
1895 1
1 384
1 661
223 1
1 956
1 1112
38 1...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 4
Accepted

Test #83:

score: 4
Accepted
time: 5ms
memory: 40928kb

input:

2000 3
1359 90
1703 163
158 188
360 1501
195 664
1414 215
1546 1756
536 1096
1726 1223
1150 104
1757 703
1982 282
1023 998
1180 419
576 1759
1496 1993
44 670
1703 952
855 849
1998 1399
1280 980
1533 1090
1270 678
1680 387
469 1734
1799 263
473 588
303 226
5 295
1489 1471
1094 1667
1912 210
1368 1360...

output:

1008611451196
2000
1 379 1954 1539 605 1300 1823 1866 1840 867 709 88 916 1526 1238 773 1919 816 1788 832 297 1349 1808 1428 183 863 951 1522 301 775 1265 936 1087 1672 565 1963 1330 926 1325 524 1334 36 46 1231 240 665 1376 289 1427 1319 1076 1880 1668 81 1504 1561 1987 1404 1630 1809 1354 295 1084...

result:

ok correct!

Test #84:

score: 0
Accepted
time: 7ms
memory: 40784kb

input:

2000 3
1727 567
1783 1850
205 985
323 1094
1153 821
1756 117
377 1928
1026 1303
1343 1814
268 745
242 948
1140 1218
7 1675
101 1798
1403 1752
1184 671
87 248
1953 30
1580 1441
507 1438
525 419
901 421
1585 1405
1575 883
1952 1930
1988 1325
615 722
994 1202
178 474
1978 1500
899 481
216 409
999 1817
...

output:

1012330476243
2000
1 1789 369 598 525 419 422 269 1079 202 694 88 1832 1589 131 872 1057 1532 345 1634 761 67 1174 1807 719 650 841 234 1935 175 997 1530 1315 92 1257 1885 399 750 838 1479 1326 1333 722 615 449 477 1580 517 1441 1561 1347 1449 676 522 1993 1342 1466 778 880 84 1405 571 1902 1585 175...

result:

ok correct!

Test #85:

score: 0
Accepted
time: 10ms
memory: 40816kb

input:

2000 3
1213 130
101 508
72 1199
1550 1096
1099 861
1515 627
1299 1672
1338 105
1444 1019
15 1560
1949 971
52 1312
30 529
186 1687
1917 484
1971 349
537 1223
1955 1377
300 1060
1786 1811
1960 90
1959 1353
1831 1548
303 511
1073 1197
863 1527
1379 994
31 9
1247 1707
1395 1532
29 1544
119 296
1919 1554...

output:

1001405462082
2000
1 810 1721 1487 1976 605 1365 1986 1255 830 1002 513 1369 1940 668 1557 1658 1802 574 1774 1836 751 1491 1292 374 1010 640 33 1085 1261 1450 435 1610 381 93 222 650 1809 1127 1527 1899 863 1356 1067 384 181 1475 854 570 78 358 486 1680 674 63 948 1367 1709 1639 1265 1357 625 150 1...

result:

ok correct!

Test #86:

score: 0
Accepted
time: 4ms
memory: 38700kb

input:

2000 3
532 64
99 960
1271 519
1141 1056
1986 1889
930 817
639 1188
841 771
1334 179
1336 1163
1687 1909
281 1300
1410 207
1018 1471
1645 972
711 1504
623 1739
1905 1959
1423 738
1747 34
1684 204
61 1012
1092 1350
1977 1130
62 473
1623 1021
1157 227
427 832
1900 1792
1910 584
265 330
1874 1186
1797 1...

output:

1002207066842
2000
1 1348 1948 1011 1848 864 719 1619 1659 1093 217 59 838 1772 1667 313 416 488 103 1178 1762 1068 225 804 1901 1074 233 652 1293 228 345 992 1839 351 1430 1913 713 994 778 618 1742 389 403 352 1088 78 1519 63 1218 157 1166 67 1468 1971 591 731 754 1840 1396 1985 1972 1605 667 946 1...

result:

ok correct!

Test #87:

score: 0
Accepted
time: 4ms
memory: 38748kb

input:

2000 3
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 53
27 54
2...

output:

995663027103
2000
1 8 64 512 1024 1025 513 1026 1027 256 514 1028 1029 515 1030 1031 257 128 258 1032 1033 516 1034 1035 517 259 1036 1037 518 1038 1039 519 129 65 520 1040 1041 521 1042 1043 260 522 1044 1045 523 1046 1047 261 130 262 1048 1049 524 1050 1051 525 263 1052 1053 526 1054 1055 527 131 ...

result:

ok correct!

Test #88:

score: 0
Accepted
time: 3ms
memory: 40864kb

input:

2000 3
1 2
1 3
1 4
2 5
2 6
2 7
3 8
3 9
3 10
4 11
4 12
4 13
5 14
5 15
5 16
6 17
6 18
6 19
7 20
7 21
7 22
8 23
8 24
8 25
9 26
9 27
9 28
10 29
10 30
10 31
11 32
11 33
11 34
12 35
12 36
12 37
13 38
13 39
13 40
14 41
14 42
14 43
15 44
15 45
15 46
16 47
16 48
16 49
17 50
17 51
17 52
18 53
18 54
18 55
19 5...

output:

1000109641799
2000
1 14 365 1094 1095 1096 366 1097 1098 1099 367 1100 1101 1102 122 368 1103 1104 1105 369 1106 1107 1108 370 1109 1110 1111 123 371 1112 1113 1114 372 1115 1116 1117 373 1118 1119 1120 124 41 125 1121 1122 1123 374 1124 1125 1126 375 1127 1128 1129 376 126 1130 1131 1132 377 1133 1...

result:

ok correct!

Test #89:

score: 0
Accepted
time: 0ms
memory: 38700kb

input:

2 3
1 2
820567835 309877233

output:

1130445068
2
1 2 

result:

ok correct!

Test #90:

score: 0
Accepted
time: 5ms
memory: 40956kb

input:

50 3
28 1
40 30
17 31
41 25
1 30
38 6
19 9
50 6
37 4
5 44
13 31
21 46
35 14
25 10
36 41
42 32
37 11
27 20
48 45
31 10
42 17
29 40
26 35
43 3
23 24
27 34
42 39
25 5
7 18
35 48
15 31
30 23
20 17
42 12
39 16
7 32
17 3
41 38
31 47
13 8
33 9
22 33
49 48
29 11
31 19
26 31
41 2
40 17
20 21
4 4 10 2 7 6 3 4...

output:

270
50
1 28 40 37 4 11 29 31 8 13 25 36 6 50 38 2 41 44 5 10 15 47 9 22 33 19 35 14 45 49 48 26 42 18 7 32 16 39 12 20 34 27 46 21 3 43 17 23 24 30 

result:

ok correct!

Test #91:

score: 0
Accepted
time: 0ms
memory: 40852kb

input:

2000 3
1651 76
620 463
764 704
1648 768
1235 1183
915 523
1417 75
758 442
1952 271
1018 947
659 320
1976 562
337 965
1184 35
1234 1609
664 1444
580 737
1331 720
1314 973
945 1890
1760 1986
210 567
186 12
1306 1774
224 1073
1885 314
641 1144
1524 446
1148 1576
859 1438
1991 343
89 1665
140 537
183 14...

output:

994118359072
2000
1 1998 917 681 1429 55 1051 1216 1829 1006 802 1575 1666 1291 1047 1634 1848 41 1587 403 735 1241 1895 1932 421 1220 748 489 1726 843 1064 1209 305 13 1012 334 1677 1941 318 1927 1905 895 977 1710 303 892 120 853 1798 1324 1321 59 118 1674 1925 1966 553 412 516 296 662 393 1614 132...

result:

ok correct!

Test #92:

score: 0
Accepted
time: 11ms
memory: 40840kb

input:

2000 3
574 1963
1305 849
1271 853
1365 1853
12 1402
1010 1462
1353 494
74 1688
1786 1435
405 1012
1229 924
1085 1565
713 1742
796 1929
1844 1725
801 79
1089 1137
1255 1331
1659 754
341 1929
1233 956
615 1455
1798 867
1105 1943
196 790
1357 678
1160 1797
1310 1963
857 792
35 1464
1576 1251
1628 913
1...

output:

1002312168974
2000
1 231 1959 1795 1885 307 1256 27 468 202 1467 179 1418 1101 843 1592 676 1680 810 1842 1911 678 1669 1218 397 1312 701 1726 1154 1275 465 711 1804 1710 1441 724 12 175 1222 376 1277 149 1341 628 817 1103 249 1457 1083 1402 990 184 526 48 1624 14 222 704 41 639 1877 90 925 332 1255...

result:

ok correct!

Test #93:

score: 0
Accepted
time: 0ms
memory: 38796kb

input:

2000 3
684 1375
1184 445
1723 1722
473 1351
1019 941
1595 1572
718 56
974 696
308 1015
650 1134
338 1313
210 277
1735 1134
1053 283
1112 1862
90 450
1762 1042
1903 1927
1472 337
312 1925
815 1234
1226 206
1371 994
108 1604
1249 674
1509 1501
1232 1669
1519 1474
1368 780
953 749
1201 1422
351 325
101...

output:

1000468940262
2000
1 560 1868 184 769 867 427 1582 54 925 1033 1589 1587 1956 1694 557 26 1096 204 187 1903 145 659 1818 318 1767 1255 1347 1003 1321 1227 1529 104 1433 1151 543 271 1465 947 835 3 98 476 1518 331 1839 411 1383 517 114 767 1411 1709 999 581 1325 1624 1431 1220 136 750 37 1650 1897 15...

result:

ok correct!

Test #94:

score: 0
Accepted
time: 0ms
memory: 40796kb

input:

2000 3
1317 1228
1811 1659
491 1756
1622 1016
730 1196
873 59
1567 441
144 1469
1726 647
698 1631
1985 1711
1005 616
1286 964
1408 625
246 1404
125 1488
16 982
1576 1223
750 1845
1831 604
1502 458
1043 1552
1360 921
180 1800
266 1261
1021 1308
1421 625
99 403
891 1500
602 482
1520 610
486 1899
843 1...

output:

977343950277
2000
1 1996 1964 1563 1947 1638 1258 1456 951 259 913 168 1205 1733 113 1597 464 889 350 17 1860 684 1621 1849 631 993 877 1225 1702 1430 313 1444 985 452 1558 451 1163 258 544 1923 319 119 1091 521 1904 1914 898 1825 286 1300 61 823 1417 1928 720 1554 1048 390 1512 1089 1292 371 39 467...

result:

ok correct!

Test #95:

score: 0
Accepted
time: 4ms
memory: 40840kb

input:

2000 3
1188 1181
1574 1619
944 1974
626 789
1798 27
159 547
1759 1110
1304 1360
1172 997
1815 1043
1496 1948
1781 1513
1884 993
652 1079
1983 1436
88 1953
1221 174
383 1741
48 814
1532 1319
1039 1401
1737 1829
996 920
222 1902
590 1270
692 1504
1918 654
928 1602
208 1165
1251 1596
329 856
1068 577
2...

output:

985678197158
2000
1 731 1659 83 708 809 699 388 1676 1219 306 859 816 1716 1846 641 31 1806 478 1205 364 1277 486 1766 700 553 1927 748 1706 577 1068 92 1484 1751 1827 1588 496 439 1593 223 1428 116 373 1524 109 1574 300 366 1482 661 416 1376 879 882 876 1553 558 1721 1330 578 522 671 572 1957 1739 ...

result:

ok correct!

Test #96:

score: 0
Accepted
time: 0ms
memory: 38984kb

input:

2000 3
892 807
1866 64
123 674
1147 1184
1897 1873
385 1877
7 1697
1753 234
191 1453
625 850
91 1195
320 1560
1827 43
426 1801
1338 1775
55 1070
1138 127
627 1985
225 882
232 1144
124 1208
1665 54
819 898
1038 1676
1642 327
1827 1548
559 1243
69 854
1806 195
943 654
1426 905
691 1598
532 1304
235 53...

output:

1023444069399
2000
1 1705 1447 1166 1830 4 1025 1356 781 1519 1299 1256 1544 1037 171 1431 590 510 577 301 408 1529 362 154 1109 218 241 248 1516 1143 991 1711 475 943 654 1780 1940 337 1521 438 941 141 1323 1949 117 679 582 818 1828 873 1090 318 379 1011 1364 192 424 924 1061 1302 1045 1574 1663 90...

result:

ok correct!

Test #97:

score: 0
Accepted
time: 0ms
memory: 40876kb

input:

2000 3
1367 159
1497 1532
1105 440
1955 1658
129 1964
272 956
1165 1745
625 1694
257 726
645 476
623 1098
648 303
665 847
1304 1665
307 926
319 1098
619 1582
1920 1770
874 1257
1443 815
121 578
1280 943
555 1602
1575 583
545 447
1708 1104
911 146
347 1466
1108 1412
1548 567
451 1182
1449 813
634 168...

output:

1010882805670
2000
1 700 977 1394 743 652 1414 293 194 495 1540 1483 955 856 341 1518 1893 915 1109 331 579 1986 51 1585 935 717 1343 1240 1835 1063 1061 1756 157 1563 1969 893 869 1204 1110 474 719 1118 931 1639 649 91 526 467 1692 390 542 1380 305 1579 334 2000 595 1622 725 1868 1836 118 1786 186 ...

result:

ok correct!

Test #98:

score: 0
Accepted
time: 8ms
memory: 38732kb

input:

2000 3
1611 477
1551 698
1677 1706
712 1391
685 1755
1645 749
1510 671
1952 809
1398 368
213 1597
361 1006
651 971
437 409
1563 1815
704 16
42 404
930 26
1857 1089
1832 173
877 850
1876 1304
349 628
515 241
1700 787
1627 1311
1106 1040
1527 1685
591 1374
1350 359
240 359
456 1245
397 637
297 972
83 ...

output:

1014963178537
2000
1 1787 807 1785 1932 1360 1237 1483 1193 1024 1861 104 1292 1023 1733 862 1151 375 793 1045 339 78 301 946 77 521 198 1936 1306 1564 1772 1361 1902 1731 463 1268 1771 1610 260 1798 706 938 479 1510 671 610 411 1480 1757 9 1081 1835 1513 192 837 1491 1670 395 766 188 427 560 190 77...

result:

ok correct!

Test #99:

score: 0
Accepted
time: 3ms
memory: 40856kb

input:

2000 3
1595 236
1251 497
809 946
633 735
282 191
1643 1997
1563 640
366 1468
640 1510
1781 1617
1157 1659
535 1144
990 1887
687 1221
675 931
214 809
196 724
330 427
596 271
221 1994
947 841
520 640
1251 1215
1331 1042
640 149
1617 1887
202 1223
1400 1429
1127 898
106 1015
615 1707
968 1043
490 1299
...

output:

1003217858982
2000
1 609 1144 522 279 546 602 1183 1432 1072 186 554 1156 738 960 1551 171 889 255 424 271 928 75 113 1332 1442 638 1509 416 1002 763 1582 1371 614 392 1718 1046 538 48 1073 1384 1234 905 118 291 1389 529 1555 1542 1687 1414 347 841 1068 1488 298 100 1118 467 155 1151 1023 1957 1474 ...

result:

ok correct!

Test #100:

score: 0
Accepted
time: 7ms
memory: 40780kb

input:

2000 3
988 1
204 1
1 1855
1 226
26 1
1 1079
1 1825
572 1
50 1
1 1215
1 1532
1 1118
1 770
108 1
1 1207
1845 1
432 1
1369 1
1 879
1 203
460 1
154 1
135 1
492 1
1 873
1 1625
1212 1
1 107
1321 1
1818 1
1 292
1 1427
49 1
1 1233
1 1712
1579 1
418 1
1 793
1 1090
1 1842
1302 1
1 227
201 1
1 912
654 1
1 69
1...

output:

996901666648
2000
1 988 204 1855 226 26 1079 1825 572 50 1215 1532 1118 770 108 1207 1845 432 1369 879 203 460 154 135 492 873 1625 1212 107 1321 1818 292 1427 49 1233 1712 1579 418 793 1090 1842 1302 227 201 912 654 69 51 746 1953 354 1172 1656 896 1550 125 1729 297 1234 1940 1336 186 1515 14 1823 ...

result:

ok correct!

Test #101:

score: 0
Accepted
time: 3ms
memory: 38740kb

input:

1999 3
1773 1351
1 1076
1754 1646
1267 1
1157 983
1 978
1 1751
1392 1119
379 1
1 5
1 360
613 769
1 1472
1 1447
851 1
1867 1319
175 1
976 1
1760 1519
1 1718
1 1919
1 835
757 1060
1000 1
1331 1412
338 1
1341 11
1563 1415
1713 1127
772 477
1855 1
168 1248
600 1
335 1825
704 928
236 919
1815 1692
729 57...

output:

1997213132735
1999
1 842 1076 1719 1267 1100 978 1798 1751 1375 379 858 5 1110 360 746 1472 1475 1447 1621 851 216 175 1477 976 1602 1718 1018 1919 1282 835 637 1000 1796 338 532 1855 1770 600 1483 1592 1074 1869 49 1517 899 1874 1382 392 878 1935 856 85 1129 492 1309 953 1740 1205 1817 239 370 1009...

result:

ok correct!

Test #102:

score: 0
Accepted
time: 0ms
memory: 39020kb

input:

1997 3
1399 516
1 716
1426 1537
965 594
1856 855
1284 1479
1566 927
1454 1924
890 1748
84 1373
95 1672
185 1374
1 1082
34 1
211 782
1298 176
1310 776
1661 594
1931 428
980 916
693 1664
1598 91
981 1
30 1
536 121
154 1558
668 641
1637 1
777 13
302 673
889 360
1 1282
929 1
1035 204
1168 1923
190 151
8...

output:

1995219549052
1997
1 522 968 40 716 1350 5 27 1082 1600 511 181 34 1055 584 1384 981 1451 565 1332 30 933 1484 1404 1637 680 65 1977 1282 1010 313 529 929 18 887 954 1478 451 1004 429 996 1708 1922 477 1492 1379 107 825 873 1363 385 679 393 668 1789 1711 641 1894 250 1299 1495 1482 1160 1131 10 311 ...

result:

ok correct!

Test #103:

score: 0
Accepted
time: 3ms
memory: 41088kb

input:

1936 3
341 1240
946 1597
1195 959
1733 1240
615 937
184 592
1258 1799
1601 1409
880 1258
91 1718
1417 1139
916 1592
184 911
1852 180
452 1793
803 1343
180 1895
575 1888
171 1778
1176 1912
1173 107
1173 372
1108 1094
1066 1293
1139 1561
771 1835
651 1675
1637 1675
41 1879
1396 771
1772 497
1687 752
1...

output:

959283331124
1936
1 1793 643 677 1114 112 371 65 1320 1869 1000 433 1198 1167 971 1825 522 1149 855 1911 1111 670 977 986 1326 168 1539 1665 1215 1685 1758 1373 962 856 1517 1744 486 1366 879 380 219 1183 722 461 994 452 206 736 1112 352 1355 884 1818 1152 832 10 1210 396 998 674 1786 1137 6 930 862...

result:

ok correct!

Test #104:

score: 0
Accepted
time: 3ms
memory: 41012kb

input:

2000 3
1370 1319
6 1661
982 1460
654 816
1368 70
841 1391
332 1111
107 46
387 1390
928 196
369 1792
742 337
1906 1604
1278 672
154 1991
1518 308
849 846
705 158
1835 1612
780 1779
881 1867
597 1965
1956 409
1099 1242
828 1821
1662 344
760 1126
911 306
948 1909
1296 830
1642 892
516 1614
957 796
1038...

output:

2000000000000
2000
1 1784 1065 449 1616 369 616 85 383 1598 690 209 1749 1307 1571 816 1267 1311 729 849 507 76 1430 1658 937 935 46 880 1982 1161 241 653 16 1254 1150 1504 673 1627 739 867 1621 213 596 1082 1639 240 1495 1242 1607 1482 1613 1593 1356 1921 1132 351 1077 60 929 1028 565 477 632 918 7...

result:

ok correct!

Test #105:

score: 0
Accepted
time: 3ms
memory: 40932kb

input:

2000 3
531 824
1828 527
489 1172
118 1355
370 562
1080 1962
535 1707
1302 1749
1996 347
424 1282
236 30
1937 1327
395 1060
672 1730
850 1700
19 1215
1989 1284
762 1946
646 1551
1478 249
446 1426
906 1103
1765 267
177 785
1231 699
410 415
1905 1059
1518 1948
219 987
825 1030
1812 995
1260 962
149 786...

output:

987613898700
2000
1 1961 1554 139 29 1112 1465 683 839 1456 1660 884 582 117 270 10 793 1644 137 201 185 781 100 28 40 1553 356 1962 1407 12 50 544 1051 888 1653 1290 1570 496 1929 789 1601 497 1688 1067 1843 883 1062 520 1076 38 862 30 1323 1107 9 590 541 369 202 1585 1223 407 272 1813 1682 1603 59...

result:

ok correct!

Subtask #6:

score: 5
Accepted

Dependency #5:

100%
Accepted

Test #106:

score: 5
Accepted
time: 85ms
memory: 49776kb

input:

200000 3
147012 182751
154277 181776
95094 76426
30313 86629
126223 49995
166060 157842
122541 40371
6521 182375
175030 110447
78367 175134
131250 97285
132337 99771
133031 2158
102720 163461
104670 46325
70722 156875
99733 7253
130400 31525
38020 23547
104556 120340
152061 174001
112957 138331
6972...

output:

99966483941576
200000
1 43786 61368 141601 27342 58507 176539 111660 178830 181337 112530 71702 34966 13484 14314 125180 82821 140683 37316 15351 9486 113272 27399 10792 87198 120906 126290 163260 109219 27536 122694 45724 23180 40031 101123 34236 45844 197484 157652 38555 75696 93617 80568 143826 1...

result:

ok correct!

Test #107:

score: 0
Accepted
time: 75ms
memory: 49788kb

input:

200000 3
88318 81002
165280 125130
123213 158997
170916 134482
177516 24669
83023 47275
56744 198831
61378 114675
142731 71814
37961 109617
197131 149557
68375 143769
129315 188798
47241 2192
45374 89479
141586 98813
117482 28948
47723 198356
153753 15033
74174 89660
120110 20697
166201 153612
56703...

output:

100200484512997
200000
1 133121 122564 79926 132880 152822 180885 5442 123751 165926 149053 126422 115469 185238 18933 61519 179334 84740 113559 188187 34904 70628 118993 72988 3638 167092 5614 165640 175573 132793 184160 137049 87835 153829 110350 75313 112962 29622 192100 35054 128743 67578 32252 ...

result:

ok correct!

Test #108:

score: 0
Accepted
time: 79ms
memory: 49848kb

input:

200000 3
158080 150707
87713 27325
92660 116209
54409 23694
2943 189354
174240 164818
63040 89575
78660 136513
161745 60054
17228 137313
33135 77303
46614 163540
176388 144256
20069 160599
164840 98121
163973 193193
93832 65863
151238 29299
13510 176374
95565 29436
172499 151626
4052 2523
149429 151...

output:

99876819168945
200000
1 123803 199151 191267 57281 78719 47246 49778 36748 46197 176040 75819 132601 167651 112505 122093 64819 149225 98228 106394 103825 89318 186423 179479 153121 175233 165448 34517 123835 30991 962 178947 130952 190733 165889 194629 198494 183005 179548 43914 107871 13737 124560...

result:

ok correct!

Test #109:

score: 0
Accepted
time: 70ms
memory: 47812kb

input:

200000 3
13458 31389
54935 62559
19438 94761
190500 137721
133057 27282
118646 10976
158688 189150
50966 88936
64367 138380
1248 98893
70840 18433
7913 117595
102418 46367
54395 8227
170625 128662
95469 29899
156391 75448
147167 88351
146838 184391
77624 107403
24058 128408
178325 168636
48464 73268...

output:

99910494745784
200000
1 182149 15678 110982 191608 138065 161591 169389 174566 75938 53081 64228 56334 105987 56453 31491 93436 109029 172128 62429 178222 22289 85191 171140 20735 59766 185203 115099 48929 176355 157237 3160 89222 157476 153718 148884 76366 5076 156327 197605 59081 56522 187648 1704...

result:

ok correct!

Test #110:

score: 0
Accepted
time: 71ms
memory: 49772kb

input:

200000 3
57046 131800
29987 88605
171474 148623
99129 28902
45321 30680
75505 16586
12530 86028
120454 7164
33933 150164
82906 37260
121117 104053
192033 47278
37159 45570
153727 27709
16556 116173
105577 75450
55530 147064
27341 46913
36453 101815
29637 43794
123623 61867
3629 59534
75839 5762
3583...

output:

100006037268766
200000
1 153415 182427 199271 95837 23561 183498 165677 146327 143132 196486 99599 92625 84320 184179 17274 36052 147240 158882 37817 169829 111591 102926 97695 63070 164757 154592 118047 42603 165624 110328 61247 169744 67344 121274 77839 122836 26883 195663 96494 109219 49341 1462 ...

result:

ok correct!

Test #111:

score: 0
Accepted
time: 78ms
memory: 49836kb

input:

200000 3
139477 43272
191114 76077
179020 189948
28137 1021
65951 108562
103570 145873
115851 178975
178592 72360
173350 154567
84335 161076
142716 153606
185307 176576
104994 143521
73511 116320
168667 92228
160372 179510
78166 57346
137423 155483
76454 179369
194690 69013
2700 101118
100200 94223
...

output:

99890707584446
200000
1 120008 25269 59226 179451 120738 30188 11895 57067 20458 54107 54517 78185 68419 59363 154633 17703 62649 64910 6879 76027 175049 23086 151883 4017 151253 12541 173685 161247 154676 6488 78733 50062 144197 79811 70380 116864 103928 112251 45454 99631 145635 58961 114350 70441...

result:

ok correct!

Test #112:

score: 0
Accepted
time: 58ms
memory: 48392kb

input:

200000 3
179253 61326
193064 25770
101250 104257
127308 168366
75652 156351
48789 45946
3246 138024
161405 143701
41976 91073
162591 27995
104694 9725
96951 60586
170891 35876
127049 121655
51111 162908
75978 187533
87785 85717
12359 132567
161307 112872
153158 48573
98012 48629
103902 196093
99788 ...

output:

99804652763041
200000
1 157756 162801 158751 172921 1591 105368 166157 161125 123631 25430 143259 61669 85541 149651 9707 77934 70938 44782 132294 7433 159486 7192 65812 53577 123700 198332 19361 193650 174620 156239 120843 137493 194950 85930 140172 179647 15550 92791 141269 142282 65527 22418 1503...

result:

ok correct!

Test #113:

score: 0
Accepted
time: 82ms
memory: 47576kb

input:

200000 3
62838 75939
87826 180015
72625 160066
31793 97154
87330 68381
163447 73473
12778 146477
175129 158989
171461 14472
86022 120141
194508 29080
158722 75883
50290 83476
106106 21819
178861 182937
166058 96930
179108 125006
199570 132827
170051 193208
121118 189720
86617 54823
184821 60430
8819...

output:

100006003713207
200000
1 103467 188640 3132 68471 39710 48343 46025 42342 176553 187063 49806 13336 19633 48094 23805 30283 74490 189901 26201 76196 99889 351 840 36797 69980 193478 52461 116230 147086 41042 104 182351 170363 131892 159474 68371 39369 176423 77525 117920 31234 25116 149920 66365 820...

result:

ok correct!

Test #114:

score: 0
Accepted
time: 61ms
memory: 50584kb

input:

200000 3
153989 10517
27314 72036
93500 132724
93638 100042
192943 181118
59968 98240
154528 61181
20366 181919
7218 87940
38589 133947
154187 77410
116666 2957
70560 16300
128562 51840
109869 105397
60196 3012
161863 18667
36797 61682
180020 54807
127767 42942
90184 125480
96410 114460
178356 14309...

output:

100132596896132
200000
1 7430 142609 159716 184842 79687 50215 76962 159804 47453 18647 194348 100597 170251 106890 34147 21220 165670 185504 154158 119720 32039 56711 56501 162236 69862 172751 116616 104123 82910 116155 15167 192097 41432 195434 86612 137609 116658 74369 147470 31975 654 106949 750...

result:

ok correct!

Test #115:

score: 0
Accepted
time: 76ms
memory: 49636kb

input:

200000 3
193823 30011
91709 11809
501 45254
82025 86617
184348 23880
103950 119507
37454 8974
174384 115451
23634 107320
97650 182412
42066 177636
111315 60332
130053 54528
1558 155819
7733 158979
164488 110559
46281 59042
72138 22510
13718 2327
133303 92964
105935 168350
39293 164483
15208 86000
84...

output:

99823050174586
200000
1 76871 126235 95662 54528 83526 134669 117111 44975 130053 64714 33183 80841 26273 141431 146341 161892 198789 30077 99570 59600 177827 85098 35660 189819 197663 123609 55814 64424 22761 100789 55113 28417 34775 130212 175669 45995 121694 154722 32897 196620 56636 12279 112684...

result:

ok correct!

Test #116:

score: 0
Accepted
time: 80ms
memory: 50644kb

input:

200000 3
167904 154479
99791 26520
66032 21354
89797 127514
81807 174766
2597 165492
80439 48156
101761 132200
96442 63449
199372 164659
160562 84653
92296 7081
71393 42324
196440 127414
61112 184736
80407 46397
193310 58007
189525 22158
112277 132008
187852 91575
33497 40060
121384 1910
174332 7252...

output:

100032502601811
200000
1 71912 15635 52491 130139 157470 129176 116375 38460 156962 55827 191493 118737 6313 45963 51862 54720 195138 144913 150329 175456 176897 149266 94206 528 40203 139095 96987 181315 130599 19714 197907 113414 127849 133548 125077 31031 68281 160809 171459 11290 40520 64088 343...

result:

ok correct!

Test #117:

score: 0
Accepted
time: 64ms
memory: 51036kb

input:

200000 3
57696 1
1 118308
1 63302
143342 1
1 32977
169723 1
1 99113
1 20536
104991 1
1 176676
1 35771
1 199270
1 140871
1 71858
77751 1
133782 1
1 116525
63323 1
1 82450
125231 1
1 57698
1 192616
1 127854
168916 1
25125 1
73904 1
38396 1
1 4002
192295 1
150580 1
1 159320
1 62139
46661 1
1 150820
1 4...

output:

100188092398438
200000
1 57696 118308 63302 143342 32977 169723 99113 20536 104991 176676 35771 199270 140871 71858 77751 133782 116525 63323 82450 125231 57698 192616 127854 168916 25125 73904 38396 4002 192295 150580 159320 62139 46661 150820 44895 161850 81349 77478 196641 142082 54519 85648 1246...

result:

ok correct!

Test #118:

score: 0
Accepted
time: 62ms
memory: 49340kb

input:

199999 3
85151 130580
91456 1
1 126463
75828 52651
1 166438
97319 1
142822 72349
86125 191843
42036 15244
79975 99266
1 43347
1 136116
144573 104329
70554 1
154747 1
36845 1805
44410 1
182186 83316
155755 1
71223 129018
1 127862
1 78098
195817 18601
1 194275
1 85673
12603 92383
14771 191475
112155 1...

output:

199823206822200
199999
1 44657 91456 108452 126463 118937 166438 94576 97319 132319 43347 127963 136116 183123 70554 5003 154747 181730 44410 172396 155755 162404 127862 112742 78098 119131 194275 139728 85673 75012 112155 42969 121815 151737 179498 135199 75557 100511 100382 2682 86774 100921 18704...

result:

ok correct!

Test #119:

score: 0
Accepted
time: 67ms
memory: 47896kb

input:

199997 3
131613 140540
69978 138510
168678 157222
178811 3528
18491 28791
101558 152962
181277 930
134819 58137
2395 48734
147095 1
186977 95913
8298 1
179118 19885
27772 137115
62062 22064
27659 63226
91886 588
2211 1
1 2193
27574 1
96584 59043
46821 111679
6754 156644
140820 130625
114787 1
57183 ...

output:

199821436893275
199997
1 40782 176347 142331 147095 56817 146032 180790 8298 80154 180695 73637 2211 111989 94187 156535 2193 195744 186581 6555 27574 130951 101135 199314 114787 176865 64820 42143 17971 28292 82328 131214 197493 15050 60959 90998 1784 135194 167448 193506 159388 174311 195359 13931...

result:

ok correct!

Test #120:

score: 0
Accepted
time: 64ms
memory: 50364kb

input:

199809 3
94685 130894
41571 74291
26864 192447
123025 103411
12655 63756
121771 108019
65438 48656
176986 96765
10202 194287
108921 26742
51953 110771
87549 119680
133398 172870
85286 49434
144205 158162
157948 108072
59452 52518
103411 185204
170486 73773
140828 61920
160006 153902
186600 142638
33...

output:

100198293228920
199809
1 39501 1535 89809 61038 131591 84703 3727 125941 20201 150372 132357 65559 37827 69367 92864 162664 86958 71616 116492 14866 8890 12284 42665 172420 93976 53591 11690 52188 86643 138337 60519 118388 180651 98722 167735 117061 141151 143010 14670 53590 79352 136487 132199 3849...

result:

ok correct!

Test #121:

score: 0
Accepted
time: 88ms
memory: 67724kb

input:

200000 3
9586 193144
171563 40905
6622 65112
70106 27821
188019 98031
47484 179201
43370 65160
62820 27032
152546 143501
125446 69794
135672 118195
27893 16069
172623 134805
164806 148766
108617 14368
66935 108798
159549 983
14719 163836
173818 163624
24054 100996
151308 144701
130442 142208
142769 ...

output:

200000000000000
200000
1 94198 179585 183667 188525 80719 89783 125238 184882 61224 178895 94443 128769 54179 64237 153529 95403 55562 122411 32700 369 31378 4291 131786 91034 183709 61817 13172 146022 179053 6988 156998 159497 77946 154975 144395 71359 124051 126703 169954 19356 103534 27375 129259...

result:

ok correct!

Test #122:

score: 0
Accepted
time: 77ms
memory: 60328kb

input:

200000 3
5381 142906
195916 107149
28028 86513
140805 179412
120296 155640
88810 138241
67680 36075
18302 103548
197422 113736
107225 185275
96224 191998
71426 84989
148160 128735
7180 115757
72027 78126
132940 2260
68261 167840
11075 11586
136344 159122
71717 66896
3688 131894
188506 19576
177339 4...

output:

99938006915289
200000
1 138973 34556 7887 148746 842 27491 649 44775 167691 103466 142472 42907 173910 127703 36233 112133 66353 168822 90077 86388 80321 25845 75424 157334 91048 165487 108868 138108 158134 5101 153193 73021 163162 171633 192086 159617 23372 82017 51806 12334 13824 73338 165249 6794...

result:

ok correct!

Test #123:

score: 0
Accepted
time: 81ms
memory: 54180kb

input:

200000 3
81359 23709
47617 60906
88252 102848
98019 112549
30197 80744
65659 97659
158878 19909
94219 11691
86418 94004
59681 135769
143977 151753
77274 138576
30461 150335
85619 146257
168877 47780
141821 36612
36628 12386
3027 198618
98013 74369
156285 199585
5968 75053
144088 37775
44797 3792
133...

output:

100070095386096
200000
1 141962 118600 82149 161437 164092 137537 93202 189414 175092 53129 4313 7312 122304 24754 156966 86939 68610 152692 54103 59957 34633 135195 9051 9085 96183 20655 9425 166337 59809 117432 65706 199198 115739 32237 14722 118563 39972 187230 152144 59178 74221 18121 181742 281...

result:

ok correct!

Test #124:

score: 0
Accepted
time: 71ms
memory: 53656kb

input:

200000 3
44823 19469
157522 45675
35223 33063
48384 43574
153370 51203
50021 198093
2217 130181
148628 37413
65646 9542
12916 145699
99195 110491
55343 51767
71138 8376
188306 160428
198328 139379
70854 18315
48129 43378
142336 95958
25165 189153
174301 27234
184222 93794
179422 38902
76681 78714
11...

output:

100106249361173
200000
1 72519 192477 20072 68073 63583 100340 121975 173750 766 107543 194409 17970 198631 8234 143622 108913 93696 33560 113369 58344 49556 190273 194653 182144 199323 189207 158015 133830 113097 154619 132830 199557 168819 199751 58337 147607 56978 58803 104283 158221 75509 176556...

result:

ok correct!

Test #125:

score: 0
Accepted
time: 75ms
memory: 53196kb

input:

200000 3
66925 159827
183145 173667
142615 151805
40331 125850
86779 21981
193285 55703
16332 64097
128674 29528
54281 177585
19905 93782
8189 66728
71597 107045
32330 126864
156780 162970
13291 153811
79967 4617
56093 197260
58256 844
51390 86594
192713 154318
161746 34026
127522 198605
36672 18301...

output:

100002327466724
200000
1 149924 188758 188596 48421 28287 198221 50164 110268 182419 16264 173228 178228 93563 10102 67468 62713 192168 37632 7723 186710 101235 185990 174046 148065 54474 172974 98815 81851 92007 121053 109339 28603 196958 151036 131212 126678 69047 84969 135933 108716 98017 13512 1...

result:

ok correct!

Test #126:

score: 0
Accepted
time: 68ms
memory: 51936kb

input:

200000 3
50618 142550
5660 103232
108320 43974
83591 71194
150884 191741
143985 51298
153093 87002
46612 90512
140403 27213
68268 191693
192026 183039
4113 198531
149099 49121
21431 59973
76644 153024
66828 94440
178145 174081
162793 31269
101449 54928
110314 93043
58967 49470
136375 71440
174999 11...

output:

99965628723367
200000
1 113307 97802 108491 103766 119940 82909 92524 193488 83983 18765 187395 173916 128219 19287 145743 183833 154883 103283 152389 171683 21068 196674 137771 29846 35649 7856 52556 199514 180012 190280 50514 109904 120003 145397 81993 28960 18798 5739 77451 7839 116767 95425 7390...

result:

ok correct!

Test #127:

score: 0
Accepted
time: 59ms
memory: 50188kb

input:

200000 3
1 2
1 3
2 4
2 5
3 6
3 7
4 8
4 9
5 10
5 11
6 12
6 13
7 14
7 15
8 16
8 17
9 18
9 19
10 20
10 21
11 22
11 23
12 24
12 25
13 26
13 27
14 28
14 29
15 30
15 31
16 32
16 33
17 34
17 35
18 36
18 37
19 38
19 39
20 40
20 41
21 42
21 43
22 44
22 45
23 46
23 47
24 48
24 49
25 50
25 51
26 52
26 53
27 54...

output:

99887916695349
200000
1 8 64 512 4096 32768 131072 131073 65536 131074 131075 65537 32769 131076 131077 65538 131078 131079 65539 16384 32770 131080 131081 65540 131082 131083 65541 32771 131084 131085 65542 131086 131087 65543 16385 8192 16386 131088 131089 65544 131090 131091 65545 32772 65546 131...

result:

ok correct!

Test #128:

score: 0
Accepted
time: 50ms
memory: 49736kb

input:

200000 3
1 2
1 3
1 4
2 5
2 6
2 7
3 8
3 9
3 10
4 11
4 12
4 13
5 14
5 15
5 16
6 17
6 18
6 19
7 20
7 21
7 22
8 23
8 24
8 25
9 26
9 27
9 28
10 29
10 30
10 31
11 32
11 33
11 34
12 35
12 36
12 37
13 38
13 39
13 40
14 41
14 42
14 43
15 44
15 45
15 46
16 47
16 48
16 49
17 50
17 51
17 52
18 53
18 54
18 55
19...

output:

100298991530485
200000
1 14 365 9842 88574 88575 88576 29525 88577 88578 88579 29526 88580 88581 88582 29527 9843 88583 88584 88585 29528 88586 88587 88588 29529 88589 88590 88591 29530 9844 88592 88593 88594 29531 88595 88596 88597 29532 88598 88599 88600 29533 3281 9845 88601 88602 88603 29534 886...

result:

ok correct!