QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#851804#7631. InvertedtoamAC ✓568ms4044kbC++202.0kb2025-01-11 00:35:152025-01-11 00:35:15

Judging History

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

  • [2025-01-11 00:35:15]
  • 评测
  • 测评结果:AC
  • 用时:568ms
  • 内存:4044kb
  • [2025-01-11 00:35:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep2(i, l, r) for(ll i = l; i < r; i++)

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

#define all(A) A.begin(), A.end()
#define elif else if
using pii = pair<ll, ll>;

bool chmin(auto &a, auto b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto &a, auto b) { return a < b ? a = b, 1 : 0; }

struct IOSetup {
  IOSetup() {
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
} iosetup;

template<class T>
void print(vector<T> a) {
  for(auto x : a) cout << x << ' ';
  cout << endl;
}

void print(auto x) { cout << x << endl; }

template<class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
  cout << head << ' ';
  print(forward<Tail>(tail)...);
}

const ll mod=998244353;
int n;
vvi G;
vi inv;

using S=array<ll,3>;

S dfs(int v,int p,int i){
  S dp={0,0,0};
  if(inv[v]!=-1&&inv[v]<=i)dp[1]=1;
  else dp[0]=1;
  for(auto u:G[v]){
    if(u!=p){
      S dpu=dfs(u,v,i);
      S ndp={0,0,0};
      
      // 両方操作前
      ndp[0]+=dp[0]*dpu[0]%mod;

      // u だけ操作
      ndp[0]+=dp[0]*dpu[1]%mod;
      ndp[0]+=dp[0]*dpu[2]*2%mod;

      // v だけ操作
      ndp[1]+=dp[1]*dpu[0]*2%mod;
      ndp[2]+=dp[1]*dpu[0]%mod;
      ndp[2]+=dp[2]*dpu[0]*2%mod;

      // 両方操作後
      ndp[1]+=dp[1]*dpu[1]%mod;
      ndp[2]+=dp[2]*dpu[1]%mod;
      ndp[1]+=dp[1]*dpu[2]*2%mod;
      ndp[2]+=dp[1]*dpu[2]%mod;
      ndp[2]+=dp[2]*dpu[2]*2%mod;

      dp[0]=ndp[0]%mod;
      dp[1]=ndp[1]%mod;
      dp[2]=ndp[2]%mod;
    }
  }
  return dp;
};


int main(){
  cin>>n;
  G.resize(n);
  inv.assign(n,-1);
  rep(i,n-1){
    int u,v;
    cin>>u>>v;
    u--;v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  rep(i,n-1){
    int b;
    cin>>b;
    b--;
    inv[b]=i;
  }

  int root;
  rep(i,n){
    if(inv[i]==-1)root=i;
  }

  rep(i,n-1){
    S ans=dfs(root,-1,i);
    cout<<ans[0]<<"\n";
  }
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3608kb

input:

5
1 2
1 3
2 4
2 5
1 5 2 3

output:

4
4
6
1

result:

ok 4 lines

Test #2:

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

input:

1

output:


result:

ok 0 lines

Test #3:

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

input:

2
2 1
2

output:

1

result:

ok single line: '1'

Test #4:

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

input:

3
1 2
2 3
2 1

output:

4
1

result:

ok 2 lines

Test #5:

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

input:

4
4 2
4 1
2 3
2 4 1

output:

4
6
1

result:

ok 3 lines

Test #6:

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

input:

5
5 2
2 4
2 3
4 1
5 2 3 1

output:

1
4
1
1

result:

ok 4 lines

Test #7:

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

input:

6
1 5
5 3
5 4
4 2
2 6
6 5 2 4 1

output:

1
12
12
4
1

result:

ok 5 lines

Test #8:

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

input:

7
2 7
7 1
1 3
2 6
7 5
6 4
6 4 2 7 1 5

output:

4
1
1
4
6
1

result:

ok 6 lines

Test #9:

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

input:

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

output:

12
12
4
4
4
6
1

result:

ok 7 lines

Test #10:

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

input:

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

output:

12
4
20
20
20
6
6
1

result:

ok 8 lines

Test #11:

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

input:

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

output:

1
1
12
48
72
12
12
4
1

result:

ok 9 lines

Test #12:

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

input:

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

output:

4
4
1
1
32
12
4
6
1

result:

ok 9 lines

Test #13:

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

input:

20
16 8
16 10
8 3
10 2
2 20
20 5
3 6
2 12
16 1
5 18
3 9
3 11
16 7
6 4
9 19
8 17
7 13
17 15
12 14
9 7 4 1 11 10 16 8 13 12 18 3 6 2 15 19 20 17 5

output:

4
16
16
16
16
64
128
640
112
448
448
928
240
424
424
56
80
8
1

result:

ok 19 lines

Test #14:

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

input:

30
6 10
6 8
10 22
6 9
22 2
9 7
22 25
7 30
22 23
6 13
10 11
6 21
10 3
9 17
2 19
30 4
10 16
21 18
23 20
16 24
22 28
30 27
3 15
20 29
20 14
18 1
17 12
8 5
14 26
1 22 7 14 25 15 23 24 21 30 28 8 26 16 29 2 11 6 20 5 19 9 18 10 12 3 4 13 17

output:

1
80
320
1280
512
512
896
896
3584
17920
6400
25600
6400
6400
6400
10240
10240
163840
30720
6720
1120
2368
496
800
800
152
44
8
1

result:

ok 29 lines

Test #15:

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

input:

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

output:

192
768
1408
1408
1408
16896
16896
28160
28160
28160
28160
28160
112640
28160
28160
28160
28160
5632
31744
31744
126976
126976
51200
51200
12800
4864
19456
121856
35840
35840
35840
8960
2240
464
464
96
28
4
1

result:

ok 39 lines

Test #16:

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

input:

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

output:

4
1
1
4
4
4
4
16
4
20
20
240
240
960
960
960
3840
3840
960
1536
1536
6144
1152
384
384
384
384
64
2304
2304
2304
32256
12544
4480
445440
186880
75520
75520
75520
26240
41984
7872
2976
4224
816
120
36
6
1

result:

ok 49 lines

Test #17:

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

input:

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

output:

12
12
48
48
1536
1536
49152
49152
49152
49152
196608
196608
196608
1048576
1048576
4194304
1310720
18350080
6881280
12042240
144506880
144506880
144506880
202309632
43352064
43352064
635830272
181665792
38928384
467140608
155713536
38928384
4866048
19464192
6488064
207618048
494927870
934281216
3114...

result:

ok 59 lines

Test #18:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

70
1 6
6 43
1 17
43 62
17 56
43 61
62 31
61 70
6 59
17 40
43 10
43 51
1 9
70 33
56 41
17 24
43 50
41 39
51 27
51 53
1 29
17 12
31 58
10 55
12 4
51 5
10 49
29 48
40 34
61 65
39 67
41 60
27 28
6 54
51 20
28 3
3 26
10 22
10 35
56 66
10 2
54 14
10 32
54 57
43 16
31 47
58 68
39 25
4 63
34 21
20 23
59 30
...

output:

1
4
4
48
48
48
16
16
64
64
256
256
1024
1024
1024
1024
1024
4096
6144
6144
1536
384
384
4608
4608
4608
23040
122880
199680
59904
59904
14976
22464
269568
1078272
1078272
4313088
178274304
178274304
54853632
79626240
143327232
573308928
573308928
573308928
828112896
207028224
276037632
69009408
69009...

result:

ok 69 lines

Test #19:

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

input:

80
74 53
53 8
8 62
8 42
74 67
62 68
74 60
8 38
74 35
74 61
68 33
74 73
42 27
67 58
74 15
42 2
68 54
73 64
67 25
2 65
2 11
2 57
65 63
35 29
27 21
67 56
57 55
33 50
55 44
62 72
67 79
8 13
33 76
50 31
27 37
56 39
65 80
68 41
55 34
57 77
76 1
60 6
31 46
80 5
33 10
62 20
44 17
35 75
33 69
57 47
57 12
17 ...

output:

1
80
960
960
960
11520
2211840
2211840
8847360
8847360
3538944
3538944
3538944
3538944
1474560
1474560
1474560
1474560
552960
6635520
6635520
6635520
100859904
403439616
134479872
537919488
465567738
775946230
775946230
693108734
168296442
280494070
947910731
947910731
50330922
50330922
50330922
721...

result:

ok 79 lines

Test #20:

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

input:

90
6 53
6 26
26 4
53 71
4 57
71 84
57 51
4 7
57 22
6 74
22 19
26 21
21 24
53 23
4 59
59 62
24 85
59 32
32 5
26 41
71 44
6 52
51 14
4 56
14 55
19 78
22 67
41 30
5 60
6 82
57 17
78 79
21 42
55 20
59 70
21 69
59 64
19 45
5 1
82 86
24 83
62 61
5 8
45 58
78 37
5 73
53 43
64 9
78 3
84 2
70 13
2 75
2 72
59...

output:

12
12
12
960
960
11520
46080
184320
5898240
23592960
23592960
23592960
94371840
377487360
94371840
94371840
94371840
94371840
528482301
528482301
939523984
939523984
176160723
176160723
704642892
763363261
536870464
536870464
150993150
150993150
536870464
511704939
989854714
989854714
167771756
1677...

result:

ok 89 lines

Test #21:

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

input:

100
11 95
11 52
11 94
95 61
61 76
61 33
76 5
95 44
44 20
11 63
20 79
61 65
76 86
33 2
61 64
20 98
65 56
95 60
86 82
82 9
11 49
94 50
33 62
62 53
62 36
49 51
62 10
63 41
86 85
98 71
33 91
49 4
5 6
79 78
9 89
76 80
5 24
49 23
5 29
5 72
24 14
91 27
49 30
63 35
10 18
78 17
2 15
9 43
18 45
71 46
79 69
27...

output:

1
4
16
16
16
192
768
3072
36864
1179648
294912
1179648
4718592
56623104
56623104
226492416
905969664
905969664
41943011
343931999
343931999
394259465
796916057
696251909
545255687
184534042
184534042
713020819
570421724
285198190
494923613
276801063
276801063
276801063
461252161
863996305
947901335
...

result:

ok 99 lines

Test #22:

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

input:

100
100 4
100 75
100 50
4 53
100 2
53 37
53 5
75 43
43 23
53 76
4 74
4 92
53 56
75 38
92 88
56 54
5 79
79 57
74 62
92 66
23 40
92 89
2 70
74 17
50 84
5 51
56 41
79 6
75 86
79 27
53 72
43 13
53 77
51 61
27 52
37 9
38 95
66 3
5 99
77 22
38 45
41 39
45 48
6 82
74 29
45 20
53 97
4 35
50 80
39 7
52 42
23...

output:

1
1
1
4
4
4
4
4
16
16
16384
16384
16384
16384
16384
196608
196608
196608
196608
327680
327680
491520
491520
1966080
62914560
62914560
62914560
62914560
754974720
754974720
754974720
754974720
754974720
494927843
134217232
134217232
713028835
713028835
713028835
713028835
427803357
142528079
77893169...

result:

ok 99 lines

Test #23:

score: 0
Accepted
time: 1ms
memory: 3632kb

input:

200
131 73
131 100
73 172
172 35
100 56
172 188
188 65
172 92
65 158
65 57
92 127
35 162
188 177
57 36
172 130
92 134
131 55
134 17
73 25
158 144
73 106
127 42
144 90
57 169
106 196
92 153
196 84
127 78
36 143
144 26
25 116
35 21
65 76
42 63
76 18
84 7
169 43
78 185
42 112
106 109
134 83
100 175
43 ...

output:

1
4
4
16
16
16
64
64
64
64
64
64
64
64
256
256
256
256
256
1024
4096
4096
4096
49152
589824
2359296
9437184
14155776
14155776
235929600
943718400
235929600
235929600
943718400
943718400
343932917
377487315
377487315
377487315
293600645
293600645
293600645
176158227
176158227
704632908
704632908
8220...

result:

ok 199 lines

Test #24:

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

input:

300
41 100
100 48
100 295
48 207
48 131
295 51
207 85
85 138
207 165
138 206
48 62
85 237
165 84
41 186
207 290
41 8
131 221
62 253
207 86
221 32
100 181
41 103
207 192
85 242
242 114
206 14
295 175
192 157
157 158
175 226
100 142
86 79
114 223
138 218
221 68
242 34
206 53
253 184
218 259
157 191
13...

output:

4
16
512
6144
1536
49152
49152
589824
2359296
452984832
452984832
813694975
813694975
260046841
260046841
41943011
562036693
343932863
25163733
100654932
402619728
100654932
100654932
100654932
778333899
118602537
474410148
899396239
810311338
739536879
651667962
651667962
651667962
651667962
651667...

result:

ok 299 lines

Test #25:

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

input:

400
257 240
257 164
257 329
164 92
164 8
164 21
21 302
329 246
92 121
329 149
329 326
240 119
121 298
92 369
369 218
21 273
164 158
240 223
121 265
369 182
223 174
21 154
182 97
240 296
164 212
8 196
326 379
196 60
273 128
257 241
240 105
212 29
296 285
21 35
212 165
296 213
154 386
158 78
149 68
22...

output:

12
144
144
1728
6912
6912
6912
1474560
1474560
47185920
188743680
188743680
188743680
754974720
310378492
243269615
973078460
973078460
981461619
981461619
981461619
981461619
981461619
981461619
981461619
981461619
981461619
360707821
360707821
360707821
377041275
86388564
86388564
345554256
345554...

result:

ok 399 lines

Test #26:

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

input:

500
295 175
175 279
279 276
276 488
295 166
175 327
295 234
175 412
412 453
175 400
327 289
166 129
234 224
224 424
279 381
327 127
327 388
424 392
279 448
448 416
327 382
488 64
488 408
381 237
448 215
289 100
488 326
388 322
412 323
382 471
382 386
175 2
327 226
295 201
408 128
488 354
215 138
392...

output:

1
1
1
12
12
12
12
64
64
5120
61440
61440
61440
245760
983040
983040
983040
983040
983040
983040
3932160
47185920
47185920
47185920
47185920
47185920
47185920
566231040
805306362
536870368
150992766
150992766
50330922
50330922
50330922
50330922
33496348
133985392
535941568
147277566
769086439
7690864...

result:

ok 499 lines

Test #27:

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

input:

600
24 589
24 533
589 202
24 54
533 364
54 132
24 478
202 43
364 321
533 479
533 376
533 97
321 465
54 568
202 161
161 434
54 493
132 159
97 433
159 30
132 340
161 184
321 36
321 320
434 570
434 363
568 367
589 249
570 555
568 92
92 394
132 146
465 152
161 406
340 328
132 456
568 51
51 140
589 295
4...

output:

12
12
48
48
576
576
6912
27648
110592
110592
442368
442368
663552
663552
663552
663552
2654208
2654208
2654208
10616832
127401984
127401984
509607936
509607936
41943038
167772152
444595571
444595571
780137931
780137931
780137931
125818665
503274660
503274660
503274660
503274660
503274660
503274660
5...

result:

ok 599 lines

Test #28:

score: 0
Accepted
time: 9ms
memory: 3664kb

input:

700
44 86
44 559
559 663
663 155
155 130
130 488
559 401
559 698
488 32
32 681
44 525
86 527
698 185
681 653
559 495
86 175
495 508
488 507
86 138
86 537
401 301
527 238
559 219
681 415
495 662
415 135
495 376
401 182
182 448
376 509
155 601
495 120
537 293
376 139
653 179
681 183
681 535
662 685
68...

output:

12
12
12
12
48
192
192
192
192
2304
27648
110592
442368
442368
5308416
5308416
169869312
444596219
444596219
780140523
125829033
125829033
125829033
503316132
50327466
603929592
603929592
419229662
39534179
39534179
39534179
39534179
39534179
266849375
266849375
69153147
345765735
345765735
71458251...

result:

ok 699 lines

Test #29:

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

input:

800
510 86
510 179
510 522
179 362
522 192
86 687
192 496
192 691
179 455
455 627
496 673
455 456
192 763
627 311
763 151
311 388
687 775
673 199
673 396
311 60
396 320
687 720
396 406
627 429
496 482
362 553
720 465
311 147
388 69
429 197
763 662
496 253
60 619
86 142
192 511
147 368
455 623
406 44...

output:

1
1
1
1
1
1
12
12
12
384
12288
2359296
9437184
301989888
301989888
301989888
113246208
113246208
113246208
452984832
452984832
452984832
452984832
452984832
444596219
444596219
343932863
377487099
100654932
226224765
904899060
838459324
79068358
79068358
533698750
533698750
138306294
138306294
66143...

result:

ok 799 lines

Test #30:

score: 0
Accepted
time: 14ms
memory: 3672kb

input:

900
78 24
78 895
895 522
895 806
895 863
522 105
24 819
78 333
333 525
863 541
78 331
78 371
331 609
525 822
609 25
333 589
541 100
78 566
806 798
541 318
822 559
24 716
895 701
701 667
806 800
371 729
701 577
100 736
333 81
589 603
822 866
667 846
603 228
566 387
318 477
387 9
477 523
105 823
78 26...

output:

4
48
48
48
48
192
192
768
768
768
768
24576
294912
294912
3538944
3538944
14155776
14155776
56623104
226492416
905969664
905969664
889192438
562036693
754974198
25163733
16609934
531517888
38418415
38418415
153673660
153673660
845839567
114268613
457074452
457074452
457074452
846146626
389853445
561...

result:

ok 899 lines

Test #31:

score: 0
Accepted
time: 18ms
memory: 3740kb

input:

1000
552 529
552 917
529 759
917 833
833 683
759 337
683 841
683 986
841 634
986 944
944 17
552 76
986 955
76 970
841 40
552 813
986 742
552 891
970 310
833 540
759 991
310 659
742 699
944 191
759 706
991 609
609 162
529 968
699 696
813 262
552 889
337 291
706 89
609 603
968 371
759 221
603 312
659 ...

output:

1
1
1
32
1024
1024
1024
1024
1024
12288
12288
49152
49152
49152
49152
49152
49152
589824
589824
589824
2359296
2359296
2359296
2359296
2359296
2359296
9437184
9437184
9437184
37748736
37748736
150994944
150994944
150994944
603979776
603979776
603979776
260046841
41943011
167772044
167772044
16777204...

result:

ok 999 lines

Test #32:

score: 0
Accepted
time: 22ms
memory: 3684kb

input:

1100
38 215
215 642
38 383
38 576
576 531
38 1091
1091 456
576 259
1091 424
38 337
215 350
215 61
424 209
531 184
215 777
259 1022
209 1020
1091 309
1091 1042
383 854
61 945
350 575
337 994
854 386
424 125
994 1007
386 290
1022 82
642 208
208 497
945 1096
82 502
125 357
497 843
576 417
383 877
843 6...

output:

1
4
128
128
10240
10240
10240
122880
122880
122880
1474560
17694720
70778880
70778880
283115520
75497463
75497463
75497463
75497463
75497463
75497463
520091954
520091954
671032880
729526927
729526927
729526927
729526927
652901576
652901576
652901576
652901576
652901576
652901576
323419724
295434543
...

result:

ok 1099 lines

Test #33:

score: 0
Accepted
time: 26ms
memory: 3748kb

input:

1200
19 977
977 725
977 636
636 207
725 416
19 190
190 1086
416 850
1086 51
207 336
207 507
725 1152
1152 847
977 567
850 668
977 405
405 344
416 793
405 119
405 35
567 66
567 1030
636 545
668 824
545 490
66 720
977 192
405 670
1086 359
35 1067
405 371
1086 1007
371 890
1067 384
19 832
359 554
507 1...

output:

4
16
16
16
64
64
768
3072
98304
98304
393216
4718592
4718592
4718592
4718592
18874368
18874368
75497472
75497472
729808881
771751748
276821799
276821799
276821799
276821799
276821799
276821799
276821799
109042843
100613460
100613460
100613460
100613460
100613460
100613460
224897661
702283226
7022832...

result:

ok 1199 lines

Test #34:

score: 0
Accepted
time: 32ms
memory: 3744kb

input:

1300
233 227
227 995
995 50
995 675
233 101
50 894
101 1236
50 858
858 978
675 1198
858 249
995 398
249 963
227 31
50 1043
978 1132
249 376
50 614
858 889
978 1005
963 760
1043 1090
1005 928
928 926
1043 441
760 1048
995 993
978 576
858 1069
614 69
1090 328
858 387
1043 1172
889 1022
1236 393
1069 5...

output:

1
4
16
512
512
512
6144
6144
6144
6144
24576
294912
1179648
1179648
37748736
37748736
150994944
813694975
813694975
813694975
813694975
813694975
780140523
780140523
377487099
377487099
377487099
377487099
377487099
545255687
545255687
695947781
365418548
463429839
154476613
154476613
617906452
4751...

result:

ok 1299 lines

Test #35:

score: 0
Accepted
time: 32ms
memory: 3708kb

input:

1400
604 762
762 947
604 102
102 1287
762 411
947 852
852 142
947 900
762 629
102 805
852 784
947 1163
784 578
762 121
1287 709
102 903
805 83
1287 694
903 850
411 209
784 1135
850 33
121 325
325 824
824 476
411 488
411 1369
900 744
604 586
325 1152
102 579
33 455
1287 1178
852 447
850 463
784 290
1...

output:

1
4
4
4
48
3840
3840
3840
3840
46080
1474560
1474560
5898240
5898240
5898240
5898240
5898240
5898240
471859200
754974630
25165461
805294752
805294752
805294752
805294752
226445949
905783796
905783796
886962022
661100734
661100734
661100734
661100734
945498337
945498337
787260289
787260289
91428881
9...

result:

ok 1399 lines

Test #36:

score: 0
Accepted
time: 37ms
memory: 3764kb

input:

1500
310 987
987 1336
310 432
1336 1161
1161 936
1336 327
310 1352
1336 298
298 947
987 887
987 48
310 1127
327 1003
48 1365
327 1441
947 101
1161 548
298 59
1003 1193
1003 342
1336 964
1127 1085
432 21
298 1096
1441 1148
101 577
887 281
548 536
1148 530
1365 1299
281 1478
1148 67
281 111
342 363
14...

output:

1
4
4
4
4
4
128
512
6144
6144
24576
24576
24576
24576
294912
3538944
14155776
169869312
679477248
721420286
125829033
125829033
503316132
503316132
503316132
50327466
704584524
585329002
585329002
344827302
53785781
53785781
53785781
53785781
53785781
645429372
645429372
645429372
645429372
14013965...

result:

ok 1499 lines

Test #37:

score: 0
Accepted
time: 47ms
memory: 3772kb

input:

1600
1339 24
1339 218
1339 92
218 1127
1339 1368
218 1025
1368 698
1339 1275
218 1095
1339 1554
1127 384
1339 611
1368 286
218 1210
1554 692
218 1111
1339 1444
1339 1431
1554 1121
218 1106
611 1141
1368 119
92 1012
1368 1499
698 783
1106 644
1275 795
783 449
1368 1105
795 726
92 731
1105 84
84 308
1...

output:

12
12
12
144
144
144
144
144
144
144
4608
4608
4608
4608
18432
18432
221184
221184
221184
2654208
212336640
293601185
293601185
293601185
293601185
411038743
411038743
645910619
587153770
352126374
259165692
115255245
384818587
541029995
541029995
541029995
541029995
502893822
120692656
120692656
48...

result:

ok 1599 lines

Test #38:

score: 0
Accepted
time: 53ms
memory: 3780kb

input:

1700
459 472
472 912
912 179
459 849
912 480
459 1590
459 121
480 271
472 1586
849 913
1586 1143
1590 1315
912 97
480 896
480 627
179 103
912 709
1590 1376
1586 1429
97 546
1376 1174
709 769
627 1084
546 536
1174 1681
1590 316
97 457
1429 465
627 149
480 898
1586 1639
898 304
1590 1686
1586 1442
103...

output:

32
128
512
40960
1310720
15728640
62914560
62914560
251658240
251658240
251658240
251658240
251658240
251658240
251658240
251658240
25165821
25165821
25165821
25165821
25165821
939524080
293599925
410998423
410998423
939003664
939003664
100786658
211195543
211195543
211195543
211195543
844782172
844...

result:

ok 1699 lines

Test #39:

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

input:

1800
1620 734
734 1659
1620 249
249 1358
249 227
1358 184
227 655
184 1674
1620 388
1659 1747
1358 122
734 1111
388 1482
249 1254
227 1043
1659 45
1620 1076
1076 552
122 1141
388 1785
552 1239
227 907
1482 1664
1659 1120
1239 1200
1239 709
1043 1649
1141 1160
227 1264
552 1211
1674 444
249 1207
1043...

output:

192
768
344064
1376256
44040192
44040192
44040192
528482301
528482301
352321494
352321494
411041623
411041623
939522064
939522064
293576885
293576885
293576885
293576885
176063187
176063187
176063187
704252748
820522286
820522286
287356085
287356085
28866681
346400172
387356335
387356335
551180987
5...

result:

ok 1799 lines

Test #40:

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

input:

1900
170 665
170 1068
170 1766
1068 1598
665 1239
170 1628
170 753
665 1709
170 31
1068 73
753 966
1766 1807
1807 897
1068 745
1628 1247
73 317
1598 286
897 140
1239 461
1247 834
1766 624
897 945
834 339
897 889
889 1396
31 1392
745 65
1598 1896
834 786
834 166
834 1900
889 1811
624 1131
65 1035
113...

output:

4
4
320
320
320
320
320
10240
10240
10240
40960
7864320
31457280
31457280
377487360
377487360
100663284
100663284
100663284
176155347
176155347
56291569
225166276
900665104
607927357
607927357
307417813
307417813
307417813
231426899
231426899
780634082
780634082
24181799
96727196
100537213
100537213...

result:

ok 1899 lines

Test #41:

score: 0
Accepted
time: 74ms
memory: 3692kb

input:

2000
1038 818
1038 431
1038 1165
431 831
431 1829
1829 998
1829 90
818 393
998 357
1165 744
818 461
744 453
461 1546
90 1760
1038 792
1546 1795
1760 454
1546 248
818 1991
1829 1468
431 1507
744 1651
998 128
998 1025
744 1871
818 1628
128 850
1468 469
1546 1409
357 531
1546 1604
1507 1176
357 1838
16...

output:

1
32
32
32
32
128
128
1536
1536
1536
1536
1536
1536
1536
576
576
18432
221184
884736
884736
3538944
14155776
14155776
56623104
226492416
226492416
905969664
889192438
889192438
687865726
687865726
268433888
268433888
75491199
75491199
75491199
301964796
301964796
678674295
718208474
718208474
138306...

result:

ok 1999 lines

Test #42:

score: 0
Accepted
time: 73ms
memory: 3780kb

input:

1992
1148 1681
1148 1885
1885 128
1885 1851
1148 435
1681 1604
1851 203
1148 275
1148 736
1851 64
1851 1230
435 505
1148 1451
203 459
1604 182
435 652
1451 1270
275 694
203 368
652 1354
1885 392
1681 1111
435 253
1604 1979
1979 936
1148 273
1148 1822
1230 1288
694 970
1885 207
64 653
275 1561
1681 1...

output:

1
12
12
12
48
48
576
2304
73728
73728
884736
884736
3538944
14155776
56623104
56623104
536870908
536870908
25165461
25165461
25165461
16748174
16748174
200978088
200978088
200978088
803912352
662749047
220916349
220916349
220916349
220916349
220916349
654507482
654507482
654507482
654507482
65450748...

result:

ok 1991 lines

Test #43:

score: 0
Accepted
time: 73ms
memory: 3856kb

input:

1993
777 1425
777 1077
777 813
813 657
1077 1827
1425 392
777 1505
657 1207
392 1376
1425 528
813 1752
1376 1271
392 1141
1425 1778
528 1787
1827 64
1505 1728
657 716
813 251
1207 1882
392 759
528 1133
251 122
1425 1531
657 207
716 1871
207 74
1778 1735
1882 214
1425 546
1752 1079
1752 350
1752 271
...

output:

4
320
327680
3932160
3932160
15728640
62914560
62914560
62914560
62914560
16777214
16777214
536870848
452984058
301927932
301927932
301927932
301927932
628402125
517119794
517119794
71990470
71990470
287961880
77330281
927963372
927963372
927963372
927963372
717120429
717120429
986477962
986477962
8...

result:

ok 1992 lines

Test #44:

score: 0
Accepted
time: 73ms
memory: 3868kb

input:

2000
374 1460
1460 1983
374 1149
1983 1599
374 1554
1983 14
1554 155
374 646
155 478
478 455
374 834
1983 988
374 1234
374 1331
834 1299
834 286
1599 1516
1599 736
1554 241
1331 1694
478 637
286 163
646 1033
646 86
736 1037
1516 980
155 1645
14 1459
980 567
1037 339
14 747
163 1803
834 1921
736 1681...

output:

32
128
512
512
512
6144
24576
98304
98304
393216
4718592
4718592
377487360
536870908
452984778
452984778
444595571
444595571
444595571
444595571
629093325
629093325
629093325
519884594
249149010
249149010
996596040
991651101
991651101
991651101
971871345
971871345
892752321
470784193
470784193
47078...

result:

ok 1999 lines

Test #45:

score: 0
Accepted
time: 74ms
memory: 3740kb

input:

2000
519 346
346 1135
519 1887
519 248
519 1990
1990 933
1135 1475
1135 1659
346 1614
346 804
1990 275
1887 610
248 1269
1990 1516
1269 571
571 1851
1269 1912
248 1102
1614 363
1614 1714
610 675
1990 1359
933 1771
1135 297
248 597
275 892
1359 417
1851 1552
1771 735
346 1586
1552 801
610 898
1516 11...

output:

12
12
12
12
12
12
12
12
384
384
30720
30720
368640
1474560
1474560
117964800
471859200
471859200
889192447
889192447
687865834
687865834
687865834
268435184
268435184
75496383
301985532
301985532
301985532
209697775
838791100
360431341
443481011
443481011
443481011
443481011
775679691
863885640
4608...

result:

ok 1999 lines

Test #46:

score: 0
Accepted
time: 74ms
memory: 3812kb

input:

1993
590 635
635 368
635 1497
590 551
635 347
551 955
347 348
635 1581
347 1671
347 1119
955 1349
1349 1956
1349 745
1956 1003
590 636
1497 382
551 490
636 1026
1671 121
347 1685
590 515
1026 1337
1026 1176
745 1718
1026 686
121 179
382 860
590 1340
1337 1298
955 1595
382 1374
635 1892
1595 609
1581...

output:

1
12
48
48
48
3840
46080
1474560
1474560
17694720
70778880
70778880
70778880
671088635
671088635
687865834
754974630
25165461
25165461
301985532
209697775
209697775
209697775
332198680
332198680
330550367
971871345
892752321
576276225
576276225
576276225
576276225
925848582
730584322
730584322
78105...

result:

ok 1992 lines

Test #47:

score: 0
Accepted
time: 74ms
memory: 3820kb

input:

1995
1929 1865
1865 1711
1865 1456
1865 538
538 631
1929 1286
1456 139
139 1910
1286 767
767 466
1711 718
767 1119
466 1063
631 700
538 813
466 776
1119 88
1929 555
718 1006
466 1508
1006 1825
1063 107
1508 352
555 238
1006 970
970 296
1286 562
813 488
1865 683
718 344
352 1860
238 1635
1456 1888
48...

output:

32
128
512
512
40960
163840
5242880
20971520
671088640
671088640
687865854
687865854
687865854
50331562
50331562
50331562
201326248
452973818
444464051
444464051
444464051
444464051
342346847
342346847
342346847
342346847
115184752
115184752
460739008
844711679
844711679
844711679
947066795
94706679...

result:

ok 1994 lines

Test #48:

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

input:

1994
545 87
545 658
545 1699
658 910
87 194
658 1936
1936 1191
1699 57
1936 323
87 320
1936 118
57 1523
658 1361
1361 1028
545 42
545 1023
194 1226
910 1199
320 1724
118 188
323 1399
320 1312
1023 1183
323 1874
1699 1643
910 1310
1361 392
910 255
323 794
57 97
255 1457
194 1628
323 1147
1023 505
139...

output:

4
16
16
512
6144
6144
196608
196608
2359296
2359296
28311552
113246208
452984832
520093682
520093682
520093682
520093682
520093682
520093682
671088176
687863998
754967286
754967286
754967286
754967286
754967286
25136085
25136085
301633020
301633020
301633020
208287727
61469464
61469464
61469464
6146...

result:

ok 1993 lines

Test #49:

score: 0
Accepted
time: 73ms
memory: 3764kb

input:

1994
386 1504
386 140
386 1382
140 303
1504 285
1504 155
1504 152
1382 1129
285 1212
303 1697
140 1084
1084 1314
152 1112
1129 541
140 1740
1740 597
1740 1407
155 1233
1697 175
1740 806
285 716
1382 710
597 1219
1382 1375
1129 440
710 1283
152 1696
175 1468
1283 1305
1084 1029
1233 411
175 820
1696 ...

output:

1
4
4
4
16
16
16
16
16
16
16
16
16
64
64
64
64
64
256
256
256
256
3072
12288
12288
12288
12288
393216
1572864
1572864
1572864
1572864
1572864
6291456
6291456
6291456
6291456
25165824
100663296
226492413
226492413
226492413
721420250
671088176
671088176
671088176
671088176
511690219
511690219
4021773...

result:

ok 1993 lines

Test #50:

score: 0
Accepted
time: 97ms
memory: 3732kb

input:

1999
1245 1507
1507 630
1245 1797
1797 664
1245 287
1507 1160
1797 75
75 691
664 663
691 1901
1507 908
630 1010
1010 477
1901 660
908 845
1901 1581
630 61
660 1932
1010 836
287 1363
1507 384
1797 795
630 751
1581 1566
1797 1666
630 238
287 1478
630 593
1245 805
287 171
805 447
238 1769
751 410
384 8...

output:

1
32
32
128
4096
131072
524288
2097152
8388608
100663296
402653184
612368383
360710125
335544088
335544088
335544088
335544088
335544088
335544088
343931999
134206576
612234559
624863181
502964018
46102098
15367366
15367366
15367366
15367366
15367366
491755712
491755712
762517489
762517489
762517489...

result:

ok 1998 lines

Test #51:

score: 0
Accepted
time: 73ms
memory: 3792kb

input:

1992
1257 1618
1257 426
1257 1217
1257 1386
426 867
426 840
1257 1919
1618 1146
1618 68
867 19
867 390
840 852
1146 194
390 395
426 1196
194 1099
1618 1316
1257 1862
1386 149
395 724
1862 1580
1618 1261
1257 1211
1618 458
867 358
149 320
1099 120
1146 1043
1196 1055
852 256
1043 1532
1043 1453
1146 ...

output:

4
48
48
576
2304
27648
27648
27648
331776
331776
1327104
5308416
5308416
21233664
21233664
84934656
339738624
360710143
360710143
360710143
335544304
889191142
562031509
562031509
251637330
166099340
994947727
994947727
365292161
708661269
708661269
708661269
715784842
715784842
866650662
471869589
...

result:

ok 1991 lines

Test #52:

score: 0
Accepted
time: 564ms
memory: 3976kb

input:

4992
2254 3807
2254 3102
3807 2775
3807 1796
2254 3137
3102 2864
2864 2930
2254 4196
2254 3618
3137 3799
3102 2788
3102 260
3799 948
2930 1372
260 767
1796 4666
1372 3005
2864 1292
767 3506
4196 122
1796 4175
1292 4455
3506 445
3005 4744
4744 210
4196 608
608 3338
4196 1272
3799 3449
3102 4626
2864 ...

output:

12
960
3840
3840
15360
15360
15360
15360
61440
61440
61440
61440
737280
737280
8847360
8847360
35389440
424673280
612368371
360709981
360709981
444595571
444595571
444595571
444595571
444595571
444595571
444595571
444595571
444595571
444595571
444595571
780137931
780137931
780137931
377455995
996596...

result:

ok 4991 lines

Test #53:

score: 0
Accepted
time: 562ms
memory: 4044kb

input:

4993
4002 987
987 3538
987 3045
3045 2555
987 4770
3538 2256
2555 3272
2555 1709
4770 3739
4002 348
4002 4406
4770 3923
1709 4255
987 736
4406 884
348 3682
3272 1407
4255 3822
4770 3548
2555 1287
3548 3442
1287 723
3682 692
884 780
987 3420
348 3925
3272 4294
1709 288
3822 4049
3682 1795
288 3203
98...

output:

1
1
1
4
48
48
192
15360
61440
61440
245760
245760
245760
2949120
11796480
943718400
943718400
943718400
343932917
343932917
377487315
511704907
511704907
511704907
511704907
603979704
603979704
260045977
838791100
886962022
985057849
576276225
925848582
925848582
925848582
925848582
708661269
708661...

result:

ok 4992 lines

Test #54:

score: 0
Accepted
time: 568ms
memory: 3992kb

input:

5000
2922 4380
4380 405
2922 2064
4380 2607
2607 217
4380 975
4380 3596
4380 4728
2064 4809
975 563
975 1797
1797 3758
4728 2118
217 2313
1797 3700
2922 125
3700 4942
975 2120
2922 3762
3758 1432
2118 2505
2120 91
217 1296
1432 707
2120 4457
1797 1718
4809 621
4809 1793
3596 4070
217 2495
2495 2782
...

output:

1
4
4
48
48
48
576
576
576
576
576
576
576
2304
2304
73728
73728
73728
73728
294912
294912
9437184
37748736
37748736
37748736
452984832
293601077
176159955
176159955
117430754
117430754
117430754
117430754
763051069
763051069
763051069
151179987
844782172
844782172
844782172
80431973
965183676
86600...

result:

ok 4999 lines

Test #55:

score: 0
Accepted
time: 557ms
memory: 3996kb

input:

5000
3583 3210
3210 398
3583 2693
398 2212
3583 4318
2693 3767
4318 585
2212 3100
3767 3800
398 3045
3045 3225
2693 1410
4318 2997
3583 4230
4318 2756
2693 3279
3800 277
2693 4998
1410 2707
3279 3395
3800 4316
3100 849
277 1392
3225 424
398 3869
3583 4770
3225 4893
398 3534
4230 998
2756 4510
4998 3...

output:

12
48
48
192
192
768
768
9216
294912
294912
294912
3538944
3538944
3538944
3538944
3538944
3538944
3538944
3538944
113246208
113246208
452984832
452984832
452984832
813694975
260046841
260046841
704639820
469723016
57471217
57471217
57471217
57471217
229884868
919539472
683424829
683424829
683424829...

result:

ok 4999 lines

Test #56:

score: 0
Accepted
time: 564ms
memory: 3968kb

input:

4993
3421 335
3421 3384
3384 2639
3384 3957
335 1950
2639 4750
1950 4723
1950 125
3957 4650
335 3240
125 14
125 3427
4750 1215
1950 1946
3384 1228
1215 4554
3427 3067
4650 493
1946 2439
4750 856
4650 4864
3957 413
3240 2326
4750 3124
3067 3352
493 2492
4723 3998
3067 3843
3124 3890
125 3650
2492 539...

output:

4
16
192
2304
2304
9216
9216
9216
9216
36864
147456
147456
147456
1769472
7077888
7077888
7077888
7077888
84934656
20971519
671088608
671088608
671088608
687865726
687865726
754974198
754974198
754974198
75491199
75491199
75491199
75491199
518889266
583122807
730584322
925848582
708661269
715784842
...

result:

ok 4992 lines

Test #57:

score: 0
Accepted
time: 560ms
memory: 3976kb

input:

4995
211 3650
211 1426
3650 1408
3650 2277
1408 846
3650 4853
2277 1044
846 3976
1044 1101
211 711
4853 1314
1044 3717
3650 2129
1101 1323
711 3705
1314 492
211 684
1314 3004
1426 2483
3705 4163
3976 2720
3705 615
2483 2125
2129 606
1314 383
1323 4396
3004 3359
4163 1680
383 4456
2720 3299
383 1171
...

output:

1
4
16
16
16
512
512
2048
2048
2048
2048
8192
8192
32768
32768
32768
32768
32768
131072
131072
4194304
4194304
4194304
16777216
67108864
67108864
805306368
679477239
721420250
671088176
780103371
125680425
502721700
502721700
502721700
43194282
43194282
43194282
172777128
76836830
76836830
76836830
...

result:

ok 4994 lines

Test #58:

score: 0
Accepted
time: 560ms
memory: 3976kb

input:

4994
4843 841
4843 1759
841 3972
4843 1967
841 3643
3972 4250
1967 1688
1688 4498
4498 3127
841 3981
3643 1258
3972 1038
841 4529
4843 2943
1038 2
2943 2422
1759 897
3981 4409
2943 3288
4409 2642
1967 1792
4409 4892
1759 2582
4843 850
3127 3837
3127 2132
2 4477
1967 4894
2 988
850 1182
1792 3805
440...

output:

1
1
1
1
1
4
4
4
16
16
16
192
192
192
2304
2304
73728
294912
1179648
1179648
1179648
1179648
1179648
1179648
1179648
37748736
150994944
813694975
813694975
813694975
260046841
260046841
260046841
41943011
41943011
41943011
167772044
671088176
687863998
268413152
268413152
226224765
904899060
51833138...

result:

ok 4993 lines

Test #59:

score: 0
Accepted
time: 566ms
memory: 3972kb

input:

4994
3082 1951
1951 3601
1951 3738
1951 4344
4344 4857
1951 1035
1951 115
4857 2442
3601 862
4344 507
3738 4082
3082 1334
4344 1429
3738 121
862 2959
115 2667
1951 1293
4857 3777
1951 3772
3772 2153
1429 3834
2959 2159
2959 2558
1951 901
2959 2187
1334 2126
2558 716
2159 1041
3772 4656
901 2623
2126...

output:

4
16
16
16
192
768
768
768
3072
3072
3072
12288
12288
12288
12288
12288
12288
49152
49152
49152
589824
113246208
113246208
113246208
113246208
629145597
562036693
562036693
562036693
754974198
687865726
301964796
301964796
628844493
628844493
158136716
899396239
602851897
602851897
602851897
9494636...

result:

ok 4993 lines

Test #60:

score: 0
Accepted
time: 568ms
memory: 3992kb

input:

4999
2563 2013
2563 481
2563 3209
481 2729
2563 3214
2729 333
3214 2819
2563 2324
333 4929
4929 1541
3209 655
2013 1273
4929 1829
3214 3642
3642 64
1541 1571
3214 1527
2013 3196
1829 1228
1527 2321
1829 4041
3209 2369
3196 3773
64 4464
2729 1822
3214 1679
3773 1419
2321 2470
1829 459
459 551
1228 47...

output:

4
16
64
64
64
256
256
3072
12288
12288
49152
49152
49152
49152
49152
196608
786432
62914560
62914560
754974720
754974720
25165821
100663284
209715055
209715055
209715055
838860220
838860220
67107896
67107896
805294752
805294752
805294752
805294752
679337847
166099340
166099340
664397360
664397360
66...

result:

ok 4998 lines

Test #61:

score: 0
Accepted
time: 563ms
memory: 3916kb

input:

4992
1623 4927
1623 284
284 1870
1870 3799
1870 2808
1870 3748
3748 435
3748 1025
1870 434
1623 590
1025 3022
4927 4144
4927 3389
1025 1312
4144 673
2808 541
3799 3183
673 2245
1870 1730
590 1649
541 3733
284 1405
590 3209
284 407
1405 4177
1025 3875
1405 1917
4927 654
3209 3271
2808 3741
3733 3238
...

output:

12
48
48
48
1536
1536
1536
1536
1536
122880
491520
5898240
23592960
94371840
562036729
562036729
100661844
545237255
553380942
347723828
347723828
347723828
347723828
179708524
718834096
602993342
602993342
602993342
415484662
911751217
911751217
652271809
652271809
612598530
453905414
453905414
453...

result:

ok 4991 lines

Test #62:

score: 0
Accepted
time: 73ms
memory: 3736kb

input:

2000
1572 1701
1701 656
1701 123
123 1735
1572 1184
1572 1367
1184 173
123 1954
1954 1793
173 17
1184 695
17 1172
1954 723
1701 248
1572 1053
1954 1634
123 1142
173 1869
695 1800
1793 490
1735 819
1172 1898
248 576
695 1598
123 1606
173 1371
123 859
123 1354
1184 658
17 229
1898 1580
1354 1405
1954 ...

output:

1
32
32
32
32
32
32
32
128
4096
16384
16384
16384
1310720
1310720
41943040
167772160
167772160
671088640
671088640
67108856
268435424
75497343
301989372
209713135
838852540
838852540
838852540
360677101
360677101
444464051
779611851
779611851
779611851
779611851
779611851
123714345
494857380
4948573...

result:

ok 1999 lines

Test #63:

score: 0
Accepted
time: 89ms
memory: 3812kb

input:

2200
1755 660
1755 1425
1755 1138
1755 305
305 1901
1901 1584
1138 441
660 2066
305 243
1138 830
1901 1639
1425 503
503 236
441 1189
243 2088
1639 2188
660 1401
503 1816
2188 578
503 1238
830 714
1901 695
1755 1367
578 83
243 1702
1425 852
714 1133
578 1928
2188 1455
236 1350
1639 1733
1350 393
2088...

output:

12
12
48
3840
15360
61440
61440
245760
245760
983040
11796480
141557760
566231040
805306362
805306362
411038743
939487504
939487504
939487504
939487504
939487504
939487504
939487504
939487504
939487504
763216957
704584524
704584524
469059464
747852775
988278476
958380845
958380845
519882257
51988225...

result:

ok 2199 lines

Test #64:

score: 0
Accepted
time: 107ms
memory: 3760kb

input:

2400
1638 1669
1669 1329
1329 1192
1669 242
1638 1225
1192 1381
1329 1834
242 2275
1192 1932
1192 490
1932 86
1381 1517
242 1587
242 2183
1517 1146
2275 2288
242 2341
1225 1632
1632 22
2341 1019
490 1060
2341 598
1587 1889
2183 297
1517 1905
1146 113
1517 882
1932 1458
1905 1767
2341 368
1905 471
11...

output:

4
4
4
48
48
192
768
768
768
9216
9216
9216
737280
737280
23592960
94371840
94371840
94371840
134217727
134217727
536870908
150994926
150994926
603979704
603979704
603979704
167758220
16609934
16609934
16609934
16609934
66439736
129582846
518331384
518331384
518331384
76836830
922041960
693434781
571...

result:

ok 2399 lines

Test #65:

score: 0
Accepted
time: 125ms
memory: 3828kb

input:

2600
409 1358
1358 2122
1358 2042
1358 571
2042 2065
2042 1524
1358 2206
571 1951
2122 886
1951 303
409 581
2206 1221
409 648
409 958
1221 15
1221 1964
571 993
648 2152
571 1968
1968 262
2206 2191
409 862
409 1146
993 617
15 1878
1968 474
15 926
1878 53
1221 915
2042 1736
303 2175
1524 1129
262 2136...

output:

4
4
16
16
16
512
40960
1310720
5242880
20971520
20971520
20971520
20971520
671088640
67108856
150994686
150994686
813691879
813691879
260034457
41893475
502721700
502721700
502721700
287961880
287961880
460809501
538492247
261597903
144441777
144441777
577767108
520149102
672861616
672861616
6728616...

result:

ok 2599 lines

Test #66:

score: 0
Accepted
time: 146ms
memory: 3836kb

input:

2800
1837 2615
1837 2400
2615 557
557 2476
2476 229
2400 1685
2476 1496
557 1938
2400 746
1496 346
2400 2060
1496 769
346 810
810 1715
346 2652
346 602
2476 868
1837 1746
2476 1217
2400 1570
810 809
746 25
602 1889
1685 1123
1715 1094
1217 1681
1746 2165
1889 1592
1496 830
809 2048
1123 853
602 2088...

output:

192
192
768
768
9216
110592
8847360
813694759
260045977
260045977
260045977
260045977
260045977
41939555
820522286
820522286
820522286
287356085
841682704
841682704
841682704
452244669
810734323
987389511
954824985
824566881
824566881
824566881
303534465
303534465
215893507
594233378
594233378
62118...

result:

ok 2799 lines

Test #67:

score: 0
Accepted
time: 169ms
memory: 3800kb

input:

3000
2263 2753
2263 1899
1899 1760
2263 526
526 1748
526 647
2263 2924
1899 1159
647 667
1760 961
526 2993
2924 2387
961 2307
2753 396
2263 1221
2753 1999
526 1168
2753 1682
1168 2401
2401 406
1159 1843
961 2029
1682 150
150 329
1168 1844
2993 68
1760 201
2401 56
2263 1911
2263 1133
647 1770
526 147...

output:

4
4
16
16
16
64
2048
2048
393216
393216
12582912
12582912
50331648
201326592
201326592
201326592
805306368
805306368
805306368
679477239
679477239
687863998
268413152
268413152
75408255
301633020
301633020
301633020
301633020
368605305
368605305
368605305
368605305
476176867
160863946
160863946
1608...

result:

ok 2999 lines

Test #68:

score: 0
Accepted
time: 194ms
memory: 3844kb

input:

3200
2327 576
576 293
576 1354
576 2219
1354 87
1354 2476
2219 2534
87 2580
2219 3179
2327 2266
2219 1154
1154 247
2476 1969
2219 1001
1001 402
1001 1699
402 2547
2327 46
1001 1229
2266 2796
1229 1371
1001 255
1229 1522
1354 3200
2476 1745
2219 28
87 959
28 1084
1354 2048
1699 530
1745 97
1522 636
8...

output:

1
12
48
48
576
576
2304
184320
5898240
70778880
283115520
134217727
134217727
134217727
301989852
209715055
520091954
671032880
671032880
687642814
687642814
265758944
64791423
64791423
64791423
64791423
64791423
76836830
76836830
76836830
307347320
307347320
307347320
307347320
850915063
850915063
...

result:

ok 3199 lines

Test #69:

score: 0
Accepted
time: 217ms
memory: 3824kb

input:

3400
1175 1154
1175 2688
2688 612
2688 42
42 2110
42 3251
1175 2956
2956 349
349 1534
2688 323
323 922
323 2669
323 1038
2688 2808
2669 726
1534 999
726 1948
323 2449
2808 905
2110 1685
2669 2904
2449 2988
2449 719
1948 1541
1154 1522
1175 2230
612 2950
2669 260
905 2264
1534 927
2950 1459
2950 2694...

output:

4
4
320
3840
3840
3840
3840
3840
307200
1228800
1228800
98304000
98304000
393216000
393216000
393216000
393216000
511705057
511705057
150994566
150994566
41870435
167481740
167481740
167481740
167481740
167481740
669926960
669926960
53168696
212674784
555608702
555608702
677838306
714864518
71486451...

result:

ok 3399 lines

Test #70:

score: 0
Accepted
time: 253ms
memory: 3836kb

input:

3600
3195 3487
3487 3019
3195 960
3487 301
960 2519
3019 3551
3195 2705
3487 1233
3551 2234
2705 801
301 3500
3500 782
2705 1487
801 2529
2529 3151
2234 2032
782 2748
3500 2411
3195 132
3551 1013
3551 2854
2748 532
301 123
3487 2902
132 3296
2705 1363
3019 3456
532 1829
801 1077
2705 2486
3487 1294
...

output:

1
4
4
4
4
4
4
4
16
64
64
256
256
1024
12288
393216
176160768
704643072
469762040
880803807
880803807
880803807
528482169
528482169
528482169
939519760
939519760
939519760
939519760
292664501
292664501
292664501
292664501
172413651
689654604
762129710
762129710
53785781
215143124
215143124
860572496
...

result:

ok 3599 lines

Test #71:

score: 0
Accepted
time: 286ms
memory: 3820kb

input:

3800
1070 168
1070 2129
2129 1236
2129 2851
2851 85
1070 3424
2851 1465
168 271
1465 351
85 2801
1236 2170
2129 3163
168 1862
1236 596
1070 3565
596 634
1236 2051
2170 151
85 2850
2051 2415
351 3097
1070 1833
2129 2578
2851 1587
634 29
2129 3768
1236 655
2170 1073
1862 1782
2129 2112
3097 2980
2578 ...

output:

1
4
16
16
16
16
16
16
64
64
256
1024
32768
2621440
2621440
2621440
83886080
335544320
335544320
335544320
343932927
377487355
377487355
536870848
536870848
452984058
301927932
209467375
209467375
837869500
356744941
428735411
428735411
153603167
153603167
614412668
614412668
614412668
614412668
4611...

result:

ok 3799 lines

Test #72:

score: 0
Accepted
time: 324ms
memory: 3912kb

input:

4000
2427 2844
2844 3535
2427 412
412 371
412 1950
371 1558
1558 2143
1950 1134
412 3032
3535 1535
1950 686
371 1715
3535 1138
1138 3269
412 2797
412 2542
1950 3481
412 2711
1138 3335
2143 1657
1950 1831
3032 2476
3269 191
1134 2473
1657 2759
1950 1492
2476 1382
1558 1307
2797 3622
2759 1411
2473 31...

output:

32
32
32
32
384
1536
6144
24576
294912
1179648
14155776
14155776
14155776
14155776
56623104
56623104
226492416
905969664
905969664
41943011
503316132
16775822
201309864
452449530
811553767
418091067
413936624
657502143
657502143
902315245
614527921
614527921
461622978
848247559
191324357
765297428
7...

result:

ok 3999 lines

Test #73:

score: 0
Accepted
time: 367ms
memory: 3984kb

input:

4200
433 1162
1162 3801
1162 400
3801 2369
2369 3735
433 233
233 3483
433 4182
233 3307
4182 2257
4182 2944
233 3958
400 2209
400 1722
2944 2787
3958 3962
1722 1139
3307 2882
2944 3792
4182 4007
3958 1996
2369 3990
2944 2254
3735 4122
233 2622
4182 2732
2944 1278
3483 725
1278 2213
3792 3573
233 260...

output:

4
16
64
28672
28672
28672
28672
28672
917504
917504
3670016
704643072
704643072
469762040
880803807
880803807
587202154
587202154
587202154
58715377
58715377
704252748
820522286
820522286
287356085
151179987
604719948
604719948
604719948
309885068
241295919
241295919
241295919
241295919
241295919
96...

result:

ok 4199 lines

Test #74:

score: 0
Accepted
time: 413ms
memory: 3936kb

input:

4400
2760 1564
2760 1328
2760 2897
1564 2163
1328 320
2760 3766
320 577
577 1883
2760 153
577 3570
153 4022
1328 3427
3766 1135
2897 2669
2669 3401
1328 2924
3427 207
2760 3649
3401 917
1135 4130
2760 1636
3649 3797
1135 1453
2924 524
320 2331
1135 3714
3797 2209
2331 3740
1883 3532
524 3189
524 122...

output:

80
960
76800
76800
76800
307200
1228800
235929600
943718400
943718400
943718400
780140541
780140541
377487315
511704907
8374087
8374087
8374087
402647376
402647376
402647376
402647376
612345151
612345151
612345151
612345151
612345151
612345151
612345151
444586931
628402125
517119794
215971410
595168...

result:

ok 4399 lines

Test #75:

score: 0
Accepted
time: 462ms
memory: 3884kb

input:

4600
4012 595
595 1545
1545 600
600 2370
4012 4129
4012 2220
2220 1261
600 1739
2370 1805
595 2549
600 3391
1739 1354
4012 3485
1261 4055
1261 3250
3485 2352
3485 209
1739 934
3485 2910
3250 2837
4129 757
1261 245
4055 1366
1261 4490
2910 1008
2837 3490
1354 2533
595 3224
3250 3763
209 2526
3391 459...

output:

1
1
12
12
12
48
192
192
192
192
192
2304
2304
27648
2211840
8847360
8847360
35389440
35389440
141557760
700448767
419430380
444595571
780137931
125818665
503274660
503274660
503274660
503274660
503274660
503274660
16609934
66439736
265758944
265758944
265758944
268928905
232413801
929655204
72388775...

result:

ok 4599 lines

Test #76:

score: 0
Accepted
time: 553ms
memory: 4016kb

input:

4800
2035 1755
2035 3165
3165 4518
3165 2966
2035 3914
3165 737
3165 721
3914 3718
1755 2672
2672 501
3718 2561
721 1425
721 3779
721 3999
721 2361
737 117
3165 1328
721 4610
501 1431
3779 309
501 3387
737 172
117 1054
3718 1060
3165 3146
2035 2120
501 4453
309 4126
721 4229
4229 2538
2672 3090
3718...

output:

1
32
128
512
512
2048
65536
2097152
402653184
402653184
612368383
452984826
444596147
444596147
780140235
125827881
503311524
335147800
28796188
28796188
921478016
691179005
390880985
565279587
264629642
264629642
482193720
482193720
402006312
609780895
609780895
329660269
418468342
418468342
418468...

result:

ok 4799 lines

Test #77:

score: 0
Accepted
time: 567ms
memory: 3972kb

input:

5000
2488 2789
2488 181
181 3058
2488 3097
3058 3854
3854 974
3058 3156
974 1266
3058 3049
2789 3214
2488 1676
181 444
1676 1541
181 2529
181 1774
444 44
1266 172
3214 1176
3854 4978
1266 3830
181 2723
3830 1038
1266 1110
1038 979
172 2693
1176 2255
2488 2966
2723 1938
2255 215
2966 2083
2966 333
30...

output:

1
80
80
80
80
80
6400
6400
204800
16384000
16384000
524288000
524288000
524288000
524288000
524288000
524288000
524288000
524288000
524288000
524288000
100663294
100663294
402653176
838860700
838860700
360709741
360709741
444594611
780134091
125803305
32728348
130913392
523653568
523653568
785004528...

result:

ok 4999 lines

Extra Test:

score: 0
Extra Test Passed