QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#571830#4888. Decoding The MessageMade_in_CodeAC ✓203ms3912kbC++142.5kb2024-09-18 09:15:332024-09-18 09:15:37

Judging History

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

  • [2024-09-18 09:15:37]
  • 评测
  • 测评结果:AC
  • 用时:203ms
  • 内存:3912kb
  • [2024-09-18 09:15:33]
  • 提交

answer

#include <bitset>
#include <iostream>
#define LL long long

using namespace std;

int t, a[256];
LL n;

LL Pow(LL x, int y, int mod) {
  LL ans = 1;
  for (int i = 1; i <= y; i <<= 1) {
    if (i & y) {
      ans = ans * x % mod;
    }
    x = x * x % mod;
  }
  return ans;
}

LL Calc1() {
  LL ans = 0;
  for (int i = 0; i < 256; i++) {
    ans = (ans + 1LL * i * a[i]) % 255;
  }
  if (n >= 8) {
    ans = Pow(ans, 128, 255);
  } else {
    for (int i = 2; i <= n; i++) {
      ans = Pow(ans, i, 255);
    }
  }
  return ans;
}

LL Calc20() {
  int d[11] = {};
  for (int i = 0, t = 0; i < 256; i++) {
    for (int j = 1; j <= a[i]; j++) {
      d[t++] = i;
    }
  }
  int t = 1;
  for (int s = 0; s < 1 << n; s++) {
    if (__builtin_popcount(s) == n >> 1) {
      int w = 0;
      for (int i = 0; i < n; i++) {
        if (s >> i & 1) {
          w = (w - d[i] + 257) % 257;
        } else {
          w = (w + d[i]) % 257;
        }
      }
      t = t * w % 257;
    }
  }
  for (int i = 2; i <= n >> 1; i++) {
    t = Pow(t, i * i, 257);
  }
  return n & 1 ? Pow(t, n + 1 >> 1, 257) : t;
}

LL Calc21() {
  int mx = 0, s = 0;
  LL m = n >> 1;
  bitset<257> f[512], g[512];
  for (int i = 1; i < 256; i++) {
    s = (s + 1LL * a[i] * i) % 257;
    if (a[i] > a[mx]) {
      mx = i;
    }
  }
  s = s * 129 % 257, f[0][0] = g[0][0] = 1;
  for (int i = 0; i < 256; i++) {
    if (i != mx) {
      for (int j = 0; j <= a[i]; j++) {
        for (int k = 0; j + k <= n - a[mx]; k++) {
          int w = i * j % 257;
          g[j + k] |= f[k] << w | f[k] >> 257 - w;
        }
      }
      for (int j = 0; j <= n - a[mx]; j++) {
        f[j] = g[j];
      }
    }
  }
  for (int i = max(m - n + a[mx], 0LL); i <= a[mx] && i <= m; i++) {
    if (f[m - i][(s - 1LL * i * mx % 257 + 257) % 257]) {
      return 0;
    }
  }
  return 1;
}

LL Calc2() {
  int mx = 0;
  for (int i = 0; i < 256; i++) {
    mx = max(mx, a[i]);
  }
  if (n >= 512 && n - mx >= 256) {
    return 0;
  } else if (n <= 11) {
    return Calc20();
  } else {
    return Calc21();
  }
}

int main() {
  cin.tie(0), cout.tie(0);
  ios::sync_with_stdio(0);
  cin >> t;
  while (t--) {
    n = 0;
    for (int i = 0; i < 256; i++) {
      a[i] = 0;
    }
    int m;
    cin >> m;
    for (int i = 1, x; i <= m; i++) {
      cin >> x >> a[x], n += a[x];
    }
    cout << (Calc1() * 32896 + Calc2() * 32640) % 65535 << '\n';  // CRT
  }
  return 0;
}

詳細信息

Test #1:

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

input:

5
1
42 1
2
0 1
1 1
1
239 2
2
1 1
2 1
3
1 1
2 2
3 2

output:

42
256
514
1284
61726

result:

ok 5 number(s): "42 256 514 1284 61726"

Test #2:

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

input:

100
1
213 79
1
54 69
1
218 55
1
248 80
1
101 8
1
153 79
1
240 45
1
112 70
1
217 5
1
208 64
1
48 30
1
0 19
1
53 40
1
63 17
1
179 65
1
221 22
1
135 84
1
138 20
1
54 29
1
114 19
1
253 94
1
240 36
1
40 94
1
244 93
1
239 24
1
133 8
1
105 91
1
45 43
1
241 74
1
206 17
1
100 73
1
133 44
1
57 70
1
56 72
1
47...

output:

21846
21846
26215
59110
32896
6426
48060
59110
43570
32896
15420
0
59110
6426
26215
17476
15420
15420
21846
21846
32896
15420
59110
21846
54741
32896
48060
48060
32896
50116
26215
32896
15420
54741
6426
17476
15420
21846
54741
39321
54741
54741
6426
54741
1
59110
59110
26215
54741
15420
15420
22101
...

result:

ok 100 numbers

Test #3:

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

input:

100
1
208 74003161
1
108 37880052
1
102 289342450
1
190 16254190
1
20 507132853
1
1 842472902
1
212 226854721
1
33 797732105
1
213 114087750
1
128 914592259
1
27 779924279
1
203 425018504
1
217 458915584
1
139 710603120
1
226 84538604
1
50 602470204
1
150 228443262
1
48 593328022
1
24 35949157
1
148...

output:

1
54741
0
59110
26215
32896
1
48060
15420
1
21846
32896
32896
59110
32896
59110
15420
54741
21846
1
54741
26215
54741
32896
32896
54741
0
54741
21846
48060
32896
21846
32896
50116
50116
21846
15420
48060
59110
26215
15420
21846
1
54741
21846
48060
15420
54741
17476
48060
54741
6426
54741
59110
54741...

result:

ok 100 numbers

Test #4:

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

input:

100
2
14 231169007
169 438746441
1
106 224694504
1
11 18668998
1
94 173751742
1
248 424067991
1
132 301760918
1
192 82611030
1
165 348431335
2
25 205571031
27 312669004
1
244 137616146
2
199 365022194
197 490765328
2
151 270019586
159 158690083
1
169 403261990
1
246 138193758
2
38 426785000
53 20660...

output:

54741
54741
32896
32896
21846
54741
15420
48060
54741
32896
54741
32896
59110
54741
32896
26215
32896
59110
17476
32896
32896
32896
59110
32640
15420
43690
32896
21846
32896
32896
32896
59110
32896
15420
32896
54741
32896
32896
21846
26215
39321
54741
17476
1
32896
21846
48060
32896
32896
32896
1542...

result:

ok 100 numbers

Test #5:

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

input:

100
19
159 4447181
119 4122592
208 20865102
19 18177591
218 15143881
145 22831007
151 35147071
91 49145857
165 13456608
253 18740477
123 40212709
175 10592471
244 41909532
62 34807087
41 14303940
153 1925365
84 46161946
120 19515674
140 39567667
18
36 6939854
219 19270307
107 26811080
135 44704863
1...

output:

32896
15420
32896
59110
32896
54741
59110
1
32896
32896
32896
1
32896
15420
32896
32896
0
32896
15420
32896
15420
32896
32896
32896
32896
21846
32896
32896
54741
54741
59110
32896
32896
32896
32896
32896
32896
32896
54741
54741
32896
43690
32896
32896
32896
32896
17476
32896
59110
15420
32896
59110
...

result:

ok 100 numbers

Test #6:

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

input:

100
162
143 1143808
192 3810724
189 1037339
105 270668
167 1068188
216 4408992
225 1618501
221 430240
120 3189057
223 2722065
217 1793649
29 3122166
129 249284
245 4125250
89 317643
254 3504072
170 4904459
104 2478836
240 1440277
180 3705854
255 3406356
149 1736411
33 4267429
227 2649591
78 4076525
...

output:

32896
32896
32896
54741
54741
32896
32896
59110
32896
32896
59110
54741
17476
32896
32896
59110
32896
32896
54741
32896
32896
54741
32896
54741
32896
17476
15420
32896
54741
54741
54741
54741
39321
32896
59110
59110
54741
59110
32896
32896
54741
32896
32896
32896
32896
32896
54741
0
32896
54741
1542...

result:

ok 100 numbers

Test #7:

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

input:

100
2
225 103463954
133 98673573
1
115 229035681
2
72 99532710
56 262010873
1
29 163503969
3
209 190760315
244 3444017
50 194052768
1
64 90518604
3
133 254936162
112 248946806
219 174695931
1
237 93137417
3
151 238090677
19 2534188
145 26960475
3
224 159486758
106 47651522
179 262824676
1
250 540564...

output:

54741
48060
32896
21846
54741
54741
32896
21846
32896
32896
48060
32896
39321
32896
32896
32896
54741
54741
32896
48060
59110
17476
32896
15420
32896
26215
15420
0
32896
32896
15420
32896
32896
32896
54741
54741
48060
15420
15420
59110
32896
32896
32896
32896
32896
54741
21846
32896
54741
1
32896
59...

result:

ok 100 numbers

Test #8:

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

input:

100
5
9 31874638
121 25059072
79 135500659
252 5862068
235 95284441
5
93 4009689
251 85715731
161 161993061
85 174911893
33 146760588
5
47 131530698
22 19994334
98 99702159
196 78068211
176 86704392
5
116 34106857
39 148267518
79 165442900
16 114763590
0 161252155
5
174 193371329
124 109104737
185 1...

output:

32896
54741
54741
54741
54741
32896
54741
32896
32896
17476
54741
59110
32896
54741
1
54741
54741
15420
43690
1
32896
32896
39321
32896
21846
32896
32896
54741
32896
54741
32896
32896
15420
32896
43690
15420
32896
54741
32896
32896
59110
54741
39321
54741
54741
32896
54741
32896
54741
32896
32896
59...

result:

ok 100 numbers

Test #9:

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

input:

100
33
44 18869789
117 8369510
145 3544065
144 3664765
168 1365372
85 12860320
150 13537400
53 8130861
91 4951044
63 8583660
110 17817008
94 4597127
255 7812378
14 17438008
129 16276681
186 5448132
2 11721273
74 6179751
181 10738486
49 19672464
98 19560557
190 14484751
225 5605695
135 9185676
156 92...

output:

32896
32896
54741
17476
59110
32896
32896
32896
59110
59110
32896
54741
32896
32896
32896
32896
32896
32896
54741
32896
32896
59110
54741
54741
32896
21846
54741
54741
32896
54741
43690
32896
32896
32896
32896
32896
17476
32896
32896
54741
32896
54741
32896
59110
59110
32896
32896
32896
32896
32896
...

result:

ok 100 numbers

Test #10:

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

input:

100
9
113 24641456
211 94030371
136 79996041
181 26478413
180 4010900
84 17453960
5 68850072
112 80595759
207 98062006
5
12 37702784
80 70203355
154 27068043
195 8627370
224 36311167
4
86 89385424
124 55291852
174 21271530
52 37177714
5
153 62356676
6 31133088
249 54379427
158 58660757
17 71472808
2...

output:

54741
32896
59110
54741
54741
32896
54741
32896
6426
32896
32896
54741
32896
32896
32896
54741
39321
54741
54741
32896
54741
32896
59110
54741
17476
54741
54741
59110
43690
32896
32896
32896
54741
32896
32896
32896
54741
39321
32896
39321
54741
54741
32896
32896
54741
32896
21846
32896
17476
32896
3...

result:

ok 100 numbers

Test #11:

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

input:

100
49
144 4682405
99 6524578
55 7445296
28 7539543
113 6780302
169 3932842
214 4675084
245 3630237
87 5943524
15 6686127
29 5394734
211 6289135
146 4999318
152 7976657
115 6464846
217 3716932
104 2332998
75 669827
89 1437466
160 9175851
8 3009996
17 4165901
98 7340466
158 9527493
106 6171697
90 754...

output:

54741
54741
54741
54741
32896
32896
54741
32896
32896
54741
17476
32896
32896
54741
32896
32896
59110
32896
59110
32896
59110
32896
59110
54741
32896
32896
59110
32896
59110
54741
54741
32896
32896
32896
32896
32896
54741
32896
59110
32896
32896
32896
32896
32896
32896
32896
59110
54741
32896
32896
...

result:

ok 100 numbers

Test #12:

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

input:

100
1
223 1
1
21 1
1
192 1
1
239 1
1
167 1
1
137 1
1
99 1
1
164 1
1
84 1
1
189 1
1
184 1
1
166 1
1
242 1
1
112 1
1
112 1
1
244 1
1
49 1
1
127 1
1
22 1
1
58 1
1
152 1
1
49 1
1
221 1
1
61 1
1
228 1
1
29 1
1
217 1
1
136 1
1
87 1
1
72 1
1
167 1
1
123 1
1
42 1
1
178 1
1
116 1
1
193 1
1
85 1
1
178 1
1
61 ...

output:

223
21
192
239
167
137
99
164
84
189
184
166
242
112
112
244
49
127
22
58
152
49
221
61
228
29
217
136
87
72
167
123
42
178
116
193
85
178
61
163
245
147
153
99
168
5
173
17
156
106
182
109
238
122
229
93
156
121
88
5
50
233
104
127
229
122
123
55
198
185
127
29
27
101
106
142
82
113
159
198
185
64
...

result:

ok 100 numbers

Test #13:

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

input:

100
2
212 2
156 1
2
97 1
251 2
1
8 1
1
98 2
2
198 2
29 1
2
94 1
50 2
2
252 2
9 1
1
48 2
2
17 1
42 2
2
86 2
71 1
2
180 2
141 2
1
83 2
1
13 2
2
201 1
112 2
2
182 1
174 1
1
104 2
2
141 1
109 1
1
56 2
2
103 2
253 2
1
65 1
1
59 1
2
4 2
14 1
1
187 1
1
148 1
2
245 2
240 1
1
211 1
2
145 2
243 1
1
37 1
2
29 ...

output:

2665
11236
8
21331
30940
47881
26994
4626
28561
49149
54741
2056
21331
49555
41056
54484
35470
39064
32896
65
59
60454
187
148
18565
211
54799
37
20935
47089
39835
3000
21331
17611
22374
9601
51366
32896
148
4369
216
39064
28270
40411
1260
21331
52495
128
56461
186
15420
12601
76
28270
55501
43165
6...

result:

ok 100 numbers

Test #14:

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

input:

100
2
5 2
24 2
2
51 3
171 3
1
154 3
3
7 3
98 1
232 1
3
87 1
95 1
185 1
1
190 1
3
11 3
77 1
253 1
3
242 2
1 2
247 2
3
152 2
252 2
209 1
3
86 1
223 1
230 3
2
193 2
153 3
2
243 2
196 2
1
39 2
1
98 2
1
193 1
3
175 1
128 3
149 2
3
80 2
236 2
186 3
3
155 3
179 1
6 2
2
110 2
141 2
2
118 2
124 2
3
61 2
120 ...

output:

2056
39441
50199
6561
11824
190
35631
59110
35631
59076
59635
2056
60909
21331
193
15556
44200
48196
32896
32896
26470
39321
125
33916
21846
26215
58566
39064
65289
5
39000
6546
32896
34
160
59076
147
11454
28270
50406
39441
2056
53551
15930
39771
71
58821
25770
61201
15556
39064
28
9154
50661
12850...

result:

ok 100 numbers

Test #15:

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

input:

100
4
36 2
119 1
46 1
213 2
4
127 1
176 1
17 3
156 2
3
103 3
7 3
125 2
3
197 2
207 3
65 1
2
178 3
220 1
3
88 2
39 3
195 2
3
145 2
185 4
222 3
1
54 3
2
131 1
81 4
4
156 1
121 3
222 1
8 1
2
225 1
200 2
3
97 3
119 3
43 4
2
225 1
44 2
1
95 4
4
132 3
115 2
125 1
128 2
3
63 1
220 3
174 2
3
251 3
58 3
139 ...

output:

39576
50661
26470
23580
1036
256
34936
20064
2245
41056
8125
26470
61294
28270
1
8721
22101
41056
15420
32896
54741
256
49216
2056
39321
16576
8026
30856
12850
59110
54741
48060
2056
32896
26470
54741
26470
28
60711
23901
21846
32896
63496
8224
59620
256
48196
52701
59110
48060
52701
32571
1
10140
1...

result:

ok 100 numbers

Test #16:

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

input:

100
2
230 2
33 1
3
101 5
218 5
216 4
4
138 2
50 5
148 5
211 1
1
12 5
3
138 5
101 3
124 2
2
51 2
91 1
5
93 4
167 1
157 4
59 1
138 5
3
229 4
227 1
11 2
5
244 5
165 5
142 5
3 1
200 2
5
67 5
15 2
176 3
122 5
50 2
5
69 4
255 2
24 3
228 4
219 5
4
188 3
209 4
121 3
71 1
1
95 1
5
190 5
162 2
158 2
205 3
180...

output:

20179
1
1
46020
50371
39754
1
58600
32896
1
48060
256
95
48060
42790
21846
1
21846
58275
22101
1
1
21846
256
26215
24090
26215
54741
33406
1
54741
59110
56674
1
21846
1
54741
16576
54741
55266
52701
47
18186
21846
1
218
256
54741
87
8736
1
256
32896
34936
54741
21846
36736
32640
50116
16576
256
3235...

result:

ok 100 numbers

Test #17:

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

input:

100
6
12 2
227 5
7 4
83 4
124 3
230 6
6
138 2
58 6
130 6
165 2
30 4
140 3
2
28 5
224 1
3
192 5
207 5
124 4
6
98 6
68 4
66 2
51 3
149 1
81 2
2
238 3
77 3
4
196 2
222 3
146 3
63 2
3
156 4
188 3
74 6
3
44 5
136 6
24 2
4
149 3
165 5
208 2
30 2
6
216 2
24 4
154 5
230 4
242 3
207 1
2
96 2
40 3
2
30 5
172 ...

output:

32896
54741
24736
32896
32896
23070
256
6426
1
1
32896
29511
21846
1
59110
22101
30720
59110
21846
1
1
1
32896
54741
59110
32896
50625
21846
15420
67
15420
63834
37231
32896
34536
32896
1
26215
1
18496
32896
1
26215
1
15420
26215
22101
25164
14415
26331
17460
110
32896
51
3855
24175
54741
48060
3238...

result:

ok 100 numbers

Test #18:

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

input:

100
2
101 2
6 6
2
221 2
2 2
6
90 2
9 3
1 5
34 6
250 4
119 3
5
162 4
154 7
10 4
146 2
254 5
4
209 6
249 1
77 2
25 2
2
129 1
148 3
2
93 6
191 3
5
252 5
56 2
157 7
173 6
202 2
1
228 5
2
169 7
202 1
5
240 6
227 3
38 5
166 3
74 5
2
0 1
127 7
7
254 7
84 1
10 1
5 7
3 3
243 3
0 6
4
35 3
143 1
215 5
169 6
7
...

output:

17476
32896
54741
32896
21846
58581
21846
1
16440
26470
17476
256
26215
21846
54741
21846
32896
15846
1
32896
54996
22101
1
21846
32896
54741
21846
50116
17476
47166
32896
59110
15420
32896
8481
54741
28270
14400
1
32896
32896
32896
39321
1
32896
26215
1
48060
114
32896
54741
26215
1
21846
48060
328...

result:

ok 100 numbers

Test #19:

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

input:

100
4
46 6
4 1
186 6
37 2
7
166 7
50 3
115 4
7 7
147 1
174 2
116 6
5
186 1
26 3
228 4
158 2
130 3
8
140 6
112 1
153 3
60 7
122 5
63 7
157 6
237 8
1
181 8
1
134 6
3
133 2
22 6
246 2
3
183 6
236 7
91 6
5
155 7
118 6
175 5
195 1
48 5
6
174 5
218 2
96 8
82 1
113 3
93 6
8
73 5
217 4
213 6
65 1
237 7
132 ...

output:

48060
54741
32896
59110
32896
54741
59110
1
1
32896
54741
15420
58821
32896
17476
1
50116
54741
1
32896
48060
1
32896
1
32896
39201
32896
59110
48060
32896
32896
1
32896
32896
54741
1
1
1
32896
21846
54741
59110
59110
21846
54741
17476
11185
54741
32896
59110
32896
59110
54741
1
256
21846
32896
4806...

result:

ok 100 numbers

Test #20:

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

input:

100
4
35 1
60 5
139 2
150 5
4
173 1
110 6
64 3
208 4
9
152 8
96 7
46 2
51 9
81 6
108 7
199 9
99 6
208 8
6
80 5
18 3
221 6
124 3
31 2
252 8
3
203 2
205 3
114 7
6
176 8
86 4
205 8
239 6
41 2
118 3
9
203 8
215 2
85 2
14 4
148 7
171 5
213 8
155 7
76 9
5
173 7
159 7
185 2
209 5
230 6
6
168 3
130 8
135 2
...

output:

32896
21846
59110
15420
50116
54741
54741
32896
32896
54741
59110
32896
1
32896
32896
15420
54741
54741
21846
50116
32896
32896
32896
32896
32896
32896
54741
32896
1
1
59110
15420
21846
32896
54741
26215
59110
1
32896
32896
50116
41056
45610
15420
54741
54741
32896
32896
1
1
54741
32896
21846
32896
...

result:

ok 100 numbers

Test #21:

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

input:

100
3
207 8
211 7
117 8
5
156 7
215 8
170 4
164 9
161 1
2
54 3
32 3
1
85 1
5
119 5
221 8
124 1
194 10
197 9
3
106 4
95 7
166 9
3
7 2
159 5
31 5
5
126 4
194 3
135 8
255 10
113 6
3
161 5
1 2
5 5
1
52 2
5
87 3
231 4
76 10
210 8
67 8
2
225 1
49 4
4
209 4
18 6
27 7
31 5
3
135 8
29 3
204 7
2
24 10
131 8
5...

output:

1
32896
6546
85
59110
54741
1
54741
1
13621
54741
33151
1
48060
32896
15420
15420
54741
54741
1
21846
26215
1
21846
1
32896
54741
1
1
1
54741
112
1
1
54741
32896
1
18834
54741
1
31876
1
59110
21846
56781
32896
26215
62901
5526
54741
1
21846
154
32896
54741
23901
48060
1
22101
36040
26215
25186
1
218...

result:

ok 100 numbers

Test #22:

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

input:

100
2
241 1
199 1
3
54 13
55 1
5 4
4
224 18
188 7
199 7
104 10
4
201 6
9 4
245 4
10 11
5
65 3
151 11
195 12
143 14
39 1
2
254 9
191 15
4
23 14
77 15
97 5
89 13
1
1 6
1
131 19
2
237 7
136 20
4
220 1
210 13
64 15
116 12
4
183 4
20 7
160 13
64 5
5
96 18
12 1
123 2
105 20
221 1
4
192 11
98 6
227 14
186 ...

output:

2605
21846
32896
1
54741
6426
32896
54741
1
1
32896
1
1
1
1
1
1
1
15420
54741
26215
32896
14230
32896
21846
32896
1
54741
54741
54741
1
32896
48060
1
32896
32896
21846
17476
32896
1
33151
21846
32640
26215
59110
54741
32896
32640
21846
32896
48060
59110
32896
59110
32896
1
1
54741
32896
60
1
32896
1...

result:

ok 100 numbers

Test #23:

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

input:

100
1
251 80
3
82 93
244 48
154 90
4
75 51
168 24
146 86
1 34
2
134 57
200 63
3
2 79
23 51
182 82
1
250 1
5
123 89
15 28
189 12
237 19
140 21
3
112 51
124 64
8 74
2
128 60
204 49
2
148 99
37 62
1
153 91
5
77 50
145 2
55 81
106 53
52 85
4
236 13
165 29
79 20
202 77
2
203 23
96 88
2
148 58
186 70
3
14...

output:

59110
54741
32896
21846
59110
250
54741
59110
21846
1
6426
54741
54741
1
32896
32896
32896
32896
54741
32896
1
32896
32896
32896
21846
26215
21846
32896
15420
32896
54741
32896
32896
32896
32896
32896
15420
32896
32896
59110
1
32896
1
32896
54741
32896
32896
59110
32896
32896
54741
54741
54741
32896...

result:

ok 100 numbers

Test #24:

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

input:

100
4
180 10
38 3
246 7
223 3
8
224 8
214 5
4 2
132 10
118 8
187 2
141 5
210 8
6
50 7
214 5
150 9
124 4
11 9
87 5
7
30 1
230 6
255 3
68 8
89 3
221 7
4 9
3
190 2
248 4
164 2
2
200 2
188 7
7
132 7
18 2
254 6
16 6
152 10
116 10
164 1
9
239 9
18 4
156 5
223 10
139 3
134 8
145 1
51 2
45 6
4
140 5
87 2
41...

output:

48060
54741
59110
54741
43690
21846
54741
54741
21846
59110
32896
32896
43690
32896
21846
21846
256
32896
32896
54741
54741
32896
54741
1
32896
30856
15420
1
32896
21846
32896
54741
32896
59110
32896
32896
59110
54741
54741
26470
21846
15420
54741
32896
21846
32896
54741
54741
32896
54741
17476
1
0
...

result:

ok 100 numbers

Test #25:

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

input:

100
9
71 1
219 1
235 1
137 1
211 1
40 1
179 1
107 1
135 1
10
180 1
212 1
165 1
77 1
249 1
19 1
149 1
174 1
218 1
117 1
5
0 1
105 1
242 1
153 1
253 1
10
201 1
31 1
169 1
208 1
149 1
250 1
209 1
133 1
212 1
173 1
8
236 1
204 1
234 1
135 1
197 1
1 1
104 1
170 1
6
146 1
34 1
235 1
237 1
210 1
161 1
6
72...

output:

30856
48315
54756
26215
21846
50406
63751
50371
63751
111
33916
19729
32896
54741
2041
12595
61981
31176
8601
155
17511
441
6561
32641
9895
256
176
63615
58921
40546
50511
22101
8190
22101
24411
256
21846
32896
19396
50406
47481
54741
41056
24736
29290
24190
55266
99
48060
32895
21846
6681
114
1
130...

result:

ok 100 numbers

Test #26:

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

input:

100
9
42 1
35 2
16 1
230 2
106 1
148 2
105 1
81 2
238 2
6
164 2
83 2
45 1
190 1
248 2
209 2
8
85 2
194 2
199 1
90 1
205 1
68 1
201 1
115 1
4
196 1
125 2
177 2
218 1
1
49 2
6
25 1
182 1
242 2
254 2
80 2
114 1
1
148 2
10
140 1
109 2
168 2
201 1
77 2
233 2
219 1
82 1
11 2
228 1
5
87 2
18 1
235 2
54 2
1...

output:

1
1
1
256
54484
22101
52171
32896
21846
2056
50
33406
256
32896
43369
21846
1
256
34795
61150
52701
54741
4096
37231
1
9766
32896
33151
256
31611
54741
17476
172
56356
21846
30856
32896
256
15556
21846
9210
30856
1
10795
58666
256
33924
36976
32896
30856
59110
32896
21846
26535
17341
32896
204
52701...

result:

ok 100 numbers

Test #27:

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

input:

100
5
217 1
34 1
28 1
130 3
220 1
3
147 3
40 2
241 2
7
137 3
19 3
185 1
88 1
151 2
202 2
48 2
10
128 3
168 2
233 3
167 3
221 2
249 2
138 3
190 3
53 2
58 3
3
14 3
113 2
57 2
2
236 3
217 3
7
167 1
38 1
173 3
114 1
124 3
14 3
122 1
1
164 1
9
64 3
122 2
29 3
34 2
52 2
227 3
185 1
127 1
198 3
7
126 1
233...

output:

16576
19516
32896
32896
256
46071
54741
164
32896
1
32896
256
256
32896
54741
32896
54741
22101
6426
59
32896
26215
32896
32896
32896
32896
19806
32896
32896
56686
50371
15420
54741
33406
54741
30856
1
22101
54741
59110
54741
48316
21846
1801
32896
33916
36721
15420
32896
2056
54741
256
32640
53721
...

result:

ok 100 numbers

Test #28:

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

input:

100
19
0 1
56 1
211 1
104 1
196 1
63 1
246 1
7 1
102 1
85 1
45 1
64 1
84 1
195 1
197 1
217 1
65 1
159 1
50 1
13
112 1
220 1
228 1
38 1
66 1
103 1
69 1
90 1
76 1
157 1
12 1
113 1
106 1
5
91 1
30 1
251 1
206 1
200 1
16
181 1
74 1
225 1
36 1
58 1
68 1
95 1
101 1
152 1
141 1
13 1
78 1
179 1
110 1
70 1
8...

output:

32896
59110
256
32896
59110
59110
33916
13174
54741
26215
52411
32896
52701
32896
54741
59110
50116
54741
2311
17476
1
26215
32896
1
59110
60654
15420
45
32896
75
22101
24736
32896
32896
36976
158
57375
54741
32911
59110
32896
54996
15420
32896
32896
59110
109
32896
54741
32896
32896
61981
32896
433...

result:

ok 100 numbers

Test #29:

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

input:

100
20
20 2
43 9
128 7
171 7
153 8
169 3
209 7
92 10
5 9
74 5
191 5
131 10
79 5
140 1
194 3
68 1
185 1
184 1
14 4
242 4
7
154 9
15 1
7 9
126 7
32 7
225 4
22 5
6
24 7
175 2
228 4
25 9
139 3
84 9
16
162 2
237 10
161 5
15 4
67 4
81 9
134 5
158 5
97 9
191 5
202 9
7 2
163 1
41 2
59 1
151 5
5
250 8
249 5
...

output:

54741
59110
32896
59110
32896
32896
54741
54741
26215
32896
43690
59110
32896
32896
59110
32896
54741
15420
32896
15420
32896
59110
32896
1
32896
32896
32896
54741
15420
54741
59110
48060
54741
59110
54741
32896
54741
21846
54741
32896
54741
54741
21846
32896
42790
32896
54741
1
1
21846
1
32896
5474...

result:

ok 100 numbers

Test #30:

score: 0
Accepted
time: 30ms
memory: 3600kb

input:

100
3
70 4
145 5
64 5
28
5 6
0 8
113 7
228 1
242 1
121 9
214 6
238 7
243 5
159 6
4 5
253 1
161 5
104 6
75 8
92 6
144 1
132 9
17 2
10 10
179 9
41 8
206 10
222 7
6 6
77 10
197 6
162 5
17
240 3
216 8
200 2
2 10
55 9
96 1
23 5
107 4
93 1
11 4
90 4
52 10
223 6
125 7
190 9
50 5
83 5
1
81 5
14
20 8
166 8
1...

output:

26215
59110
32896
50625
54741
54741
54741
48315
32896
1
32896
32896
54741
32896
59110
54741
54741
32896
32896
32896
32896
32896
59110
59110
32896
32896
54741
32896
21846
17476
1
54741
54741
32896
54741
32896
17476
32896
15420
54741
59110
21846
32896
48060
32896
54741
32896
1
32896
54741
32896
0
5911...

result:

ok 100 numbers

Test #31:

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

input:

100
9
215 61
138 100
40 83
175 61
173 96
207 42
145 62
182 52
166 58
3
144 48
236 67
117 89
22
127 59
91 7
104 77
224 75
115 37
134 14
247 18
135 97
83 40
56 51
112 72
236 84
211 12
36 54
239 68
109 15
105 1
130 92
81 53
165 77
5 90
123 5
3
120 73
64 42
11 89
25
58 16
233 68
144 5
76 46
13 44
180 72...

output:

32896
32896
59110
17476
15420
32896
32896
32896
59110
54741
32896
32896
32896
54741
54741
15420
32896
32896
59110
32896
54741
32896
32896
32896
59110
59110
59110
59110
32896
32896
26215
59110
54741
32896
15420
54741
54741
43690
54741
39321
17476
59110
54741
32896
32896
32896
59110
54741
32896
32896
...

result:

ok 100 numbers

Test #32:

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

input:

100
10
3 1
41 1
226 1
128 1
64 1
131 1
155 1
245 1
9 1
53 1
23
3 1
53 1
210 1
194 1
74 1
43 1
223 1
246 1
2 1
252 1
150 1
134 1
232 1
195 1
227 1
167 1
95 1
209 1
6 1
23 1
66 1
50 1
42 1
6
123 1
181 1
133 1
78 1
205 1
236 1
14
129 1
237 1
122 1
108 1
12 1
57 1
0 1
9 1
17 1
56 1
239 1
76 1
167 1
243 ...

output:

26470
32896
25246
32896
54231
252
32896
54741
32896
32896
32896
1
54741
32896
32896
59110
32896
54741
39321
17476
32896
43690
59110
26470
5881
59110
32896
32896
32896
54741
24141
82
54741
1
22101
54741
32896
32896
32896
32896
54741
3076
54741
32896
32896
54741
30856
54741
32896
54741
32896
54741
393...

result:

ok 100 numbers

Test #33:

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

input:

100
46
237 36
79 25
107 43
184 47
193 8
215 22
202 1
180 4
228 1
147 2
137 20
88 46
12 27
26 35
22 22
245 2
27 5
63 30
80 8
123 27
236 5
102 48
96 8
126 7
129 41
9 14
7 16
142 28
90 21
196 36
98 21
13 42
185 25
8 33
161 16
58 20
158 5
53 23
108 12
150 12
39 34
167 40
99 30
48 6
189 43
235 27
26
229 ...

output:

32896
54741
32896
15420
32896
32896
15420
32896
54741
39321
59110
59110
32896
32896
54741
54741
21846
54741
54741
17476
32896
32896
32896
54741
15420
32896
54741
54741
32896
32896
32896
59110
15420
32896
32896
32896
32896
32896
39321
54741
15420
32896
32896
32896
32896
54741
32896
32896
32896
54741
...

result:

ok 100 numbers

Test #34:

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

input:

100
97
227 1
51 1
136 1
75 1
118 1
48 1
217 1
58 1
164 1
222 1
63 1
10 1
174 1
244 1
169 1
137 1
43 1
245 1
189 1
53 1
38 1
128 1
42 1
3 1
31 1
150 1
144 1
127 1
197 1
61 1
166 1
165 1
103 1
85 1
97 1
213 1
176 1
228 1
101 1
192 1
90 1
121 1
252 1
147 1
107 1
87 1
130 1
49 1
185 1
92 1
251 1
21 1
11...

output:

32896
16
17476
32896
59110
54741
54741
54741
54741
59110
54741
32896
32896
32896
43690
32896
59110
59110
27760
59110
15420
15420
32896
32896
170
54741
32896
10915
32896
54741
32896
54741
61201
32896
32896
39321
32896
54741
43690
32896
54741
32896
32896
54741
32896
54741
32896
59110
15420
54741
54741...

result:

ok 100 numbers

Test #35:

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

input:

100
213
29 1
135 1
226 1
31 1
160 1
51 1
176 1
216 1
58 1
213 1
153 1
251 1
16 1
95 1
99 1
197 1
48 1
85 1
42 1
103 1
56 1
232 1
41 1
24 1
12 1
84 1
168 1
59 1
23 1
236 1
52 1
11 1
183 1
94 1
107 1
77 1
255 1
125 1
57 1
171 1
177 1
248 1
40 1
90 1
221 1
30 1
93 1
128 1
117 1
6 1
137 1
154 1
69 1
249...

output:

54741
32896
54741
32896
59110
54741
32896
32896
32896
59110
32896
32896
32896
59110
54741
32896
15420
32896
32896
54741
32896
42661
32896
32896
54741
54741
54741
54741
17476
32896
54741
59110
32896
59110
32896
32896
59110
32896
54741
32896
15420
59110
32896
32896
32896
32896
32896
32896
32896
32896
...

result:

ok 100 numbers

Test #36:

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

input:

100
170
250 1
51 1
254 1
160 1
104 1
141 1
7 1
49 1
50 1
234 1
20 1
170 1
235 1
33 1
1 1
111 1
117 1
102 1
166 1
142 1
115 1
152 1
81 1
56 1
227 1
84 1
71 1
62 1
129 1
43 1
53 1
91 1
192 1
167 1
120 1
99 1
172 1
176 1
143 1
245 1
101 1
132 1
232 1
134 1
107 1
133 1
27 1
195 1
86 1
215 1
80 1
9 1
94 ...

output:

39321
32896
32896
54741
32896
32896
54741
54741
54741
54741
54741
54741
32896
32896
17476
59110
54741
32896
15420
32896
6750
32896
32896
17476
59110
54741
32896
32896
32896
54741
15420
32896
32896
54741
54741
54741
32896
32896
32896
32896
32896
32896
32896
32896
54741
15420
32896
15420
54741
54741
3...

result:

ok 100 numbers

Test #37:

score: 0
Accepted
time: 131ms
memory: 3864kb

input:

100
168
44 1
9 1
22 1
155 1
48 1
242 2
150 2
227 1
241 2
173 1
110 2
65 1
78 2
57 2
52 2
102 2
84 2
54 2
35 1
202 2
231 2
204 2
210 1
134 2
45 1
130 1
32 2
185 2
191 2
126 2
79 1
252 1
223 2
159 2
165 2
180 2
106 2
53 1
100 2
63 1
243 2
236 2
253 1
41 2
222 2
143 1
255 2
177 1
141 1
51 1
220 2
188 2...

output:

59110
59110
32896
0
32896
59110
15420
10216
32896
59110
59110
32896
32896
32896
54741
32896
0
54741
54741
32896
15420
54741
32896
32896
32896
54741
32896
32896
32896
32896
32896
59110
59110
32896
15420
32896
32896
32896
32896
236
32896
54741
59110
32896
54741
59110
39321
32896
32896
59110
32896
3289...

result:

ok 100 numbers

Test #38:

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

input:

100
165
65 2
9 2
52 3
228 3
134 2
135 3
196 3
254 3
252 1
147 1
63 2
234 3
248 3
153 1
183 2
77 1
115 3
191 1
48 1
253 1
100 2
237 1
95 2
210 3
14 2
136 2
187 3
75 1
19 1
98 1
167 1
49 3
10 3
25 2
82 2
34 3
206 3
106 1
180 2
244 2
216 2
29 2
128 3
17 1
211 1
139 2
175 2
198 2
88 2
55 1
76 1
160 3
22...

output:

32896
32896
32641
32896
32896
32896
54741
15420
32896
54741
32896
15420
54741
32896
59110
32896
32896
54741
59110
54741
54741
32896
54741
59110
17476
32896
32896
32896
32896
17476
54741
32896
54741
54741
32896
15420
32896
54741
59110
32896
32896
32896
15420
15420
32896
32896
54741
54741
59110
32896
...

result:

ok 100 numbers

Test #39:

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

input:

100
2
217 28
206 33
1
169 251
2
132 171
100 94
1
122 10
2
80 162
244 40
2
11 176
211 215
1
146 130
1
163 126
2
154 75
37 66
2
88 232
102 68
2
65 150
217 167
1
255 127
1
180 124
1
158 211
1
29 170
1
51 154
1
244 104
1
55 142
1
202 59
1
133 53
1
204 76
2
76 86
248 157
2
15 110
157 248
2
214 168
152 18...

output:

32896
1
32896
59110
59110
54741
59110
54741
21846
32896
32896
32640
15420
1
43690
39321
32896
59110
1
1
39321
1
32896
54741
26215
1
26215
21846
21846
21846
1
21846
54741
1
15420
54741
6426
6426
33471
1
15420
15420
48060
21846
1
1
1
54741
59110
21846
1
26215
1
21846
59110
54741
1
21846
15420
21846
39...

result:

ok 100 numbers

Test #40:

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

input:

100
1
168 20
1
146 3
7
16 24
192 33
0 32
35 56
205 55
238 62
217 14
4
251 54
148 29
22 26
68 9
1
131 36
4
141 35
219 15
196 59
6 25
5
237 16
0 18
114 27
116 34
246 52
7
30 37
21 64
125 26
222 5
232 30
156 28
212 47
1
2 56
2
101 61
8 27
3
102 31
96 32
68 38
1
11 5
2
175 13
71 23
8
255 56
103 33
66 39...

output:

15420
15129
54741
59110
54741
32896
32896
32896
32896
1
32896
59620
1
32896
32896
50661
54741
54741
43690
32896
21846
1
59110
59110
59110
32896
32896
32896
32896
1
32896
54741
21846
32896
32896
54741
54741
32896
15420
54741
54741
15420
32896
32896
32896
54741
1
514
59110
54741
32896
15420
54741
5911...

result:

ok 100 numbers

Test #41:

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

input:

100
2
133 254
164 255
2
64 255
228 255
2
236 255
21 254
2
167 255
7 254
2
124 255
83 254
2
186 255
140 255
2
34 255
1 254
2
178 254
167 254
2
242 255
143 255
2
180 254
35 254
2
167 255
171 254
2
62 254
145 254
2
31 254
211 255
2
79 255
231 254
2
45 254
176 255
2
204 254
112 255
2
188 255
87 254
2
22...

output:

32896
32640
54741
32896
32896
32640
32896
15420
32640
59110
54741
54741
32896
54741
15420
39321
54741
32896
32896
54741
54741
32896
59110
54741
32896
54741
32896
32896
32640
32896
32640
32640
32640
54741
32896
32896
17476
32896
32896
54741
39321
59110
32896
32640
32896
32896
32640
32640
54741
32640
...

result:

ok 100 numbers

Test #42:

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

input:

100
2
33 255
105 255
2
11 254
49 255
2
236 255
132 254
3
105 255
28 142
16 113
2
22 254
119 255
3
139 255
177 133
192 122
2
139 254
196 255
2
134 254
235 255
2
74 254
158 254
2
246 254
39 255
2
147 254
200 255
2
199 254
70 255
3
5 255
27 122
188 132
3
63 255
171 133
169 121
3
204 255
42 118
126 137
...

output:

32640
32896
54741
54741
32896
15420
32896
32896
32896
54741
54741
32896
15420
32896
54741
59110
32896
21846
54741
32896
54741
32896
32896
32896
59110
43690
15420
32896
59110
59110
32896
15420
32896
32896
32640
32896
32896
54741
32896
32896
32640
54741
32896
32896
54741
32896
15420
15420
59110
17476
...

result:

ok 100 numbers

Test #43:

score: 0
Accepted
time: 139ms
memory: 3896kb

input:

100
5
20 255
13 73
60 62
196 61
11 58
3
116 254
156 134
174 120
4
218 255
30 81
209 90
165 84
3
78 254
208 124
128 130
6
104 255
205 40
211 51
127 53
6 57
32 54
5
243 255
251 51
255 81
97 65
86 58
4
22 255
182 95
113 66
31 93
3
166 254
39 116
97 139
4
57 254
84 82
225 97
6 76
3
158 254
146 127
119 1...

output:

32896
32896
15420
54741
54741
32896
32896
54741
54741
32896
32896
59110
32896
54741
59110
32896
32896
17476
54741
32896
32896
32896
59110
32896
59110
54741
32896
32896
32896
32640
54741
54741
32896
32896
15420
32896
54741
32896
32896
32896
54741
54741
17476
54741
32640
32896
54741
32896
32896
32896
...

result:

ok 100 numbers

Test #44:

score: 0
Accepted
time: 151ms
memory: 3908kb

input:

100
9
206 255
74 44
79 29
102 29
252 32
2 29
190 31
196 30
163 31
6
149 255
163 58
241 32
74 53
85 49
247 63
2
189 254
203 254
8
196 254
137 36
152 34
228 39
36 31
0 37
205 43
78 34
10
25 255
182 20
236 47
210 36
104 29
169 20
207 26
44 22
100 32
14 22
4
126 255
253 86
112 81
55 88
3
254 255
235 133...

output:

15420
32896
32896
32896
32896
15420
54741
54741
15420
15420
54741
32896
32896
54741
17476
54741
59110
54741
32896
32896
32896
32896
32896
59110
15420
32896
32896
32896
54741
15420
15420
59110
15420
54741
59110
32896
32896
32896
32896
32896
32896
39321
15420
32896
59110
32896
54741
32896
32896
59110
...

result:

ok 100 numbers

Test #45:

score: 0
Accepted
time: 161ms
memory: 3604kb

input:

100
14
43 254
79 13
183 20
62 20
174 12
60 24
118 21
241 21
254 14
46 24
160 16
69 24
173 28
107 18
31
156 255
9 5
123 8
47 11
231 9
71 18
229 3
57 11
172 8
127 10
1 10
196 8
10 9
187 10
255 6
72 5
102 7
23 12
131 8
107 4
41 4
121 10
44 10
118 10
190 7
195 6
169 8
139 14
198 8
21 6
103 9
30
191 255
...

output:

32896
17476
54741
54741
54741
54741
59110
59110
32896
59110
54741
54741
59110
32896
32896
54741
32896
54741
32896
32896
32896
59110
32896
54741
59110
32896
32896
54741
32896
32896
54741
32896
32896
32896
15420
59110
54741
54741
32896
32896
32896
54741
32896
32896
32896
17476
59110
32896
54741
59110
...

result:

ok 100 numbers

Test #46:

score: 0
Accepted
time: 166ms
memory: 3600kb

input:

100
13
221 254
202 22
119 22
1 17
17 23
166 25
149 15
186 19
83 31
39 21
206 16
44 19
134 24
77
220 255
29 3
47 4
121 5
217 4
242 6
248 2
95 2
153 3
254 6
26 3
119 5
12 1
216 2
229 2
1 3
3 8
250 3
123 5
160 5
105 1
114 3
61 3
83 2
130 2
48 2
52 2
84 4
150 3
70 2
226 5
113 3
161 1
151 2
55 3
41 4
79 ...

output:

32896
54741
32896
32896
32896
32896
15420
59110
32896
32896
32896
32896
0
54741
15420
32896
32896
32896
32896
32896
17476
32896
32896
32896
54741
32896
32896
54741
54741
32896
32896
32896
59110
15420
32896
32896
32896
32896
32896
54741
54741
32896
32896
32896
32640
54741
54741
54741
59110
32896
1747...

result:

ok 100 numbers

Test #47:

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

input:

100
78
21 255
6 4
53 5
126 3
43 4
220 2
122 1
13 3
56 4
63 2
140 3
65 3
199 3
4 1
205 4
94 6
138 1
137 5
163 4
215 2
108 3
89 4
162 6
158 4
115 2
228 3
192 2
32 2
83 3
250 2
184 5
153 2
187 3
54 4
198 1
110 5
23 5
185 5
61 3
69 5
46 3
183 3
201 3
208 4
176 2
40 4
45 3
111 2
161 2
174 2
171 1
170 4
1...

output:

32896
32896
32896
54741
54741
32896
32896
32896
32896
59110
32896
54741
32896
54741
32896
32896
32896
32896
32896
32896
15420
54741
32896
32896
32896
32896
54741
32896
32896
43690
32896
59110
59110
54741
54741
32896
59110
32896
32896
54741
59110
32896
59110
54741
32896
59110
32896
59110
32896
32896
...

result:

ok 100 numbers

Test #48:

score: 0
Accepted
time: 168ms
memory: 3832kb

input:

100
100
216 254
115 1
83 2
44 1
196 2
154 3
30 1
169 1
207 4
69 3
87 3
227 1
195 2
72 3
114 4
179 3
186 2
65 1
102 3
105 3
158 1
76 2
189 2
74 1
191 3
180 2
234 1
39 1
67 2
117 4
176 2
113 2
104 3
27 5
116 3
209 4
182 1
157 3
77 2
190 3
251 2
222 2
174 4
145 2
132 1
45 5
56 2
129 4
70 3
122 2
32 3
2...

output:

59110
32896
32896
32896
32896
32896
32896
59110
43690
32896
32896
59110
32896
32896
59110
54741
15420
32896
32896
15420
32896
59110
54741
39321
32896
54741
32896
32896
54741
15420
32896
54741
15420
32896
32896
32896
32896
54741
32896
32896
54741
17476
54741
59110
32896
54741
32896
59110
54741
54741
...

result:

ok 100 numbers

Test #49:

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

input:

100
2
133 116561872
164 255
2
64 456894640
228 255
2
236 872953738
21 254
2
167 329053158
7 254
2
124 649542258
83 254
2
186 595600739
140 255
2
34 331908494
1 254
2
178 799151697
167 254
2
242 202619716
143 255
2
180 861775563
35 254
2
167 607112804
171 254
2
62 854763019
145 254
2
31 241798361
211...

output:

32896
59110
17476
32896
32896
21846
59110
17476
32896
59110
32896
32896
50116
15420
15420
6426
54741
59110
54741
54741
32896
59110
32896
32896
32896
21846
32896
32896
21846
59110
32896
15420
32640
54741
54741
32896
32896
32896
32896
15420
39321
32896
32896
32896
32896
54741
21846
32640
54741
54741
5...

result:

ok 100 numbers

Test #50:

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

input:

100
2
33 842230506
105 255
2
11 460120086
49 255
2
236 241644686
132 254
3
105 143165866
28 142
16 113
2
22 518371782
119 255
3
139 303196990
177 133
192 122
2
139 226288856
196 255
2
134 832792741
235 255
2
74 17830907
158 254
2
246 937048889
39 255
2
147 450848641
200 255
2
199 667453550
70 255
3
...

output:

54741
54741
32896
54741
54741
59110
32896
1
43690
21846
21846
59110
15420
32896
54741
54741
54741
1
39321
6426
21846
32896
1
32896
15420
17476
48060
54741
32896
59110
32896
59110
32896
32896
32640
54741
17476
43690
54741
59110
21846
54741
1
32896
17476
32896
59110
59110
26215
39321
59110
54741
32896...

result:

ok 100 numbers

Test #51:

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

input:

100
5
20 570560642
13 73
60 62
196 61
11 58
3
116 201421101
156 134
174 120
4
218 599289555
30 81
209 90
165 84
3
78 442447431
208 124
128 130
6
104 110262429
205 40
211 51
127 53
6 57
32 54
5
243 40850260
251 51
255 81
97 65
86 58
4
22 122962192
182 95
113 66
31 93
3
166 566329799
39 116
97 139
4
5...

output:

32896
15420
15420
15420
54741
32896
59110
54741
54741
32896
32896
59110
32896
32896
59110
54741
32896
32896
54741
32896
32896
32896
32896
32896
32896
59110
32896
32896
32896
1
54741
39321
26215
32896
43690
32896
15420
32896
54741
32896
54741
39321
43690
54741
59110
32896
32896
32896
59110
54741
5474...

result:

ok 100 numbers

Test #52:

score: 0
Accepted
time: 156ms
memory: 3896kb

input:

100
17
180 566927908
209 5
55 14
0 16
49 18
18 12
172 11
42 21
45 32
39 23
1 15
102 21
54 9
17 18
171 13
222 15
88 11
16
44 873443997
23 23
98 13
83 17
221 12
192 14
251 14
201 17
147 23
36 19
228 22
21 16
130 24
134 20
188 12
103 8
5
43 825154808
182 65
70 57
34 66
110 67
22
179 930890317
85 11
11 ...

output:

32896
59110
32896
32896
32896
54741
54741
54741
32896
32896
54741
54741
32896
17476
32896
54741
32896
32896
32896
54741
32896
54741
59110
32896
54741
54741
15420
54741
59110
32896
32896
32896
17476
32896
32896
15420
39321
32896
54741
32896
32896
32896
32896
32896
54741
32896
59110
15420
32896
54741
...

result:

ok 100 numbers

Test #53:

score: 0
Accepted
time: 168ms
memory: 3600kb

input:

100
100
216 707625498
115 1
83 2
44 1
196 2
154 3
30 1
169 1
207 4
69 3
87 3
227 1
195 2
72 3
114 4
179 3
186 2
65 1
102 3
105 3
158 1
76 2
189 2
74 1
191 3
180 2
234 1
39 1
67 2
117 4
176 2
113 2
104 3
27 5
116 3
209 4
182 1
157 3
77 2
190 3
251 2
222 2
174 4
145 2
132 1
45 5
56 2
129 4
70 3
122 2
...

output:

32896
32896
59110
15420
32896
32896
54741
54741
15420
32896
32896
32896
32896
59110
32896
39321
54741
59110
32896
32896
32896
32896
32896
32896
17476
54741
32896
32896
32896
32896
54741
32896
54741
54741
32896
32896
59110
15420
32896
32896
54741
32896
39321
32896
32896
54741
32896
32896
54741
54741
...

result:

ok 100 numbers

Test #54:

score: 0
Accepted
time: 106ms
memory: 3864kb

input:

100
2
133 576088209
164 255
2
230 769456771
93 255
2
172 936201921
36 255
2
37 609208089
52 255
2
7 770481399
103 255
2
194 686161383
236 255
2
159 764780143
156 255
2
180 235301207
52 255
2
149 418253097
117 255
2
221 748225673
82 255
2
187 940266235
208 255
2
82 993718155
170 255
2
200 325911575
1...

output:

21846
10795
21846
21846
21846
21846
21846
48060
21846
50116
10795
48060
26215
21846
26215
21846
21846
21846
48060
21846
21846
21846
26215
1
48060
1
21846
21846
48060
26215
21846
21846
1
26215
26215
21846
21846
21846
50116
10795
48060
1
21846
48060
1
21846
48060
21846
1
1
26215
48060
48060
32640
5011...

result:

ok 100 numbers

Test #55:

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

input:

100
6
136 11
153 4
53 14
34 1
105 10
241 17
9
85 1
230 9
179 4
132 3
239 6
122 15
106 9
141 17
71 2
7
129 8
197 9
198 16
73 6
144 9
98 12
212 15
2
93 9
100 3
5
246 15
234 4
58 4
30 19
138 7
9
85 18
183 18
63 4
212 10
101 12
110 5
202 4
31 8
78 12
1
16 10
4
141 3
237 6
40 7
146 10
7
192 6
164 5
53 16...

output:

54741
32896
54741
21846
32896
15420
59110
48060
54741
32896
48060
32896
21846
59110
32896
1
1
32896
32896
21846
54741
32896
54741
54741
15420
32896
32896
54741
256
21846
21846
32896
48060
1
59110
54741
43690
32896
32896
32896
32896
32896
54741
54741
32896
54741
39321
54741
21846
32896
32896
48060
54...

result:

ok 100 numbers

Test #56:

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

input:

100
4
203 52
205 11
254 206
100 77
3
91 88
98 124
44 63
1
52 48
3
242 170
203 33
46 197
1
23 68
4
160 82
193 61
149 25
236 200
1
129 240
2
11 248
106 168
4
136 59
123 140
192 25
0 49
3
85 217
228 238
16 236
4
150 138
154 50
10 202
6 184
3
102 142
69 127
111 10
4
101 51
13 62
126 212
109 90
4
86 62
1...

output:

59110
54741
54741
54741
17476
32896
15420
17476
32896
15420
54741
54741
32896
59110
1
48060
32896
39321
39321
1
32896
54741
1
32896
54741
21846
43690
54741
32896
54741
32896
0
6426
21846
1
17476
21846
32896
48060
32896
54741
26215
32896
32896
32896
54741
48060
1
21846
39321
1
54741
15420
1
32896
480...

result:

ok 100 numbers

Test #57:

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

input:

100
3
226 288
63 171
121 4
3
235 78
138 56
55 72
3
139 135
24 141
56 197
3
232 77
7 242
140 62
3
78 70
91 55
36 249
3
186 90
129 110
36 258
3
71 274
25 71
27 109
3
33 56
208 57
243 222
3
224 286
82 233
223 109
3
27 86
51 161
80 96
3
245 122
236 86
158 103
3
148 52
46 147
47 202
3
107 235
113 95
249 ...

output:

59110
54741
32896
32896
32896
54741
32896
15420
32896
54741
59110
54741
54741
32896
54741
32896
54741
32896
15420
32896
54741
59110
43690
54741
32896
32896
15420
59110
59110
32896
32896
32896
32896
54741
32896
32896
32896
32896
54741
15420
54741
54741
59110
32896
32896
59110
32896
15420
32896
32896
...

result:

ok 100 numbers

Test #58:

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

input:

100
3
106 65
26 273
159 214
3
140 190
206 78
181 133
3
40 139
110 156
41 88
3
150 173
185 47
181 22
3
199 47
240 185
247 215
3
28 22
74 6
55 266
3
14 190
2 63
57 39
3
179 93
11 216
252 14
3
137 8
231 27
135 146
3
129 160
1 196
157 131
3
157 127
160 255
127 218
3
218 258
138 81
30 270
3
205 145
157 6...

output:

32896
54741
54741
32896
32896
15420
32896
54741
1
54741
15420
54741
32896
54741
32896
32896
32896
1
32896
54741
32896
32896
32896
32896
32896
32896
54741
32896
32896
59110
54741
32896
32896
32896
15420
26215
32896
15420
15420
15420
32896
54741
32896
59110
32896
32896
15420
59110
32896
21846
32896
32...

result:

ok 100 numbers

Test #59:

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

input:

100
3
248 11
156 6
120 26
3
248 15
172 18
114 10
3
211 18
52 17
127 8
3
1 9
10 15
131 20
3
211 1
120 3
242 42
3
20 2
74 36
140 7
3
210 11
58 3
72 30
3
123 1
130 7
139 36
3
17 27
182 3
0 13
3
11 16
129 11
183 21
3
139 1
124 37
48 9
3
211 9
233 14
232 23
3
166 10
233 30
156 8
3
158 23
190 13
164 8
3
1...

output:

1
6426
1
32896
26215
21846
21846
1
15420
32896
1
21846
32896
21846
48060
1
0
1
1
26215
32896
48060
1
1
21846
21846
48060
54741
6426
54741
1
26215
26215
1
21846
1
26215
21846
10795
59110
54741
1
21846
1
32896
1
48060
26215
21846
26215
26215
21846
1
59110
17476
32896
1
1
21846
21846
21846
1
1
43690
54...

result:

ok 100 numbers

Test #60:

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

input:

100
3
224 15
131 61
13 19
3
245 37
182 55
78 4
3
63 40
82 23
10 29
3
81 6
24 46
236 42
3
28 59
6 20
122 14
3
188 72
169 16
5 8
3
184 4
33 74
237 19
3
216 27
187 13
104 54
3
191 4
163 55
175 34
3
44 21
212 62
62 15
3
234 75
71 11
20 6
3
184 42
56 1
91 51
3
7 13
245 55
91 25
3
108 23
243 31
67 41
3
14...

output:

54741
32896
32896
54741
48060
59110
1
1
1
32896
1
26215
32896
1
32896
32896
1
1
32896
54741
1
54741
21846
32896
54741
48060
54741
32896
1
26215
32896
32896
54741
59110
1
59110
59110
32896
1
54741
32896
32896
1
48060
1
59110
32896
59110
32896
21846
54741
21846
1
54741
32896
48060
32896
54741
54741
26...

result:

ok 100 numbers

Test #61:

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

input:

100
3
4 70
138 69
87 7
3
52 2
27 95
205 51
3
81 46
145 72
226 28
3
131 80
191 17
222 49
3
116 28
48 113
226 6
3
141 105
199 34
238 9
3
64 18
247 2
175 124
3
157 59
215 82
251 7
3
53 39
213 65
190 38
3
209 120
78 20
86 5
3
134 12
66 95
205 37
3
139 78
164 43
60 24
3
133 10
238 100
253 37
3
154 48
225...

output:

32896
50116
32896
59110
1
32896
54741
15420
32896
26215
1
32896
54741
32896
54741
26215
32896
32896
59110
32896
48060
1
32896
32896
21846
59110
54741
54741
6426
59110
15420
32896
1
32896
1
54741
54741
54741
32896
15420
26215
17476
15420
54741
32896
21846
32896
32896
32896
1
48060
26215
6426
26215
32...

result:

ok 100 numbers

Test #62:

score: 0
Accepted
time: 24ms
memory: 3552kb

input:

100
3
53 88
134 29
107 81
3
120 7
128 111
137 75
3
74 15
11 13
147 167
3
153 26
106 25
135 147
3
114 133
30 38
171 24
3
218 37
239 53
73 103
3
47 77
146 25
162 92
3
109 47
239 106
45 39
3
159 40
145 115
85 40
3
15 61
98 128
203 7
3
3 23
8 116
124 56
3
163 18
120 91
27 84
3
20 46
197 60
244 87
3
255 ...

output:

21846
54741
32896
32896
54741
32896
54741
32896
43690
15420
54741
54741
32896
32896
32896
32896
32896
32896
15420
1
54741
32896
32896
54741
54741
1
32896
54741
39321
32896
15420
54741
32896
59110
32896
15420
32896
32896
32896
32896
54741
32896
59110
54741
21846
59110
54741
54741
32896
59110
54741
54...

result:

ok 100 numbers

Test #63:

score: 0
Accepted
time: 31ms
memory: 3864kb

input:

100
3
195 78
88 1
124 164
3
144 131
128 60
207 55
3
29 7
139 117
232 120
3
189 6
104 2
43 240
3
35 2
46 174
136 66
3
231 64
99 37
146 143
3
216 20
159 135
70 87
3
35 3
214 151
201 90
3
63 77
233 51
35 114
3
51 62
119 163
75 23
3
106 72
163 130
82 46
3
217 27
58 52
247 169
3
159 11
149 40
66 194
3
55...

output:

54741
54741
1
17476
59110
59110
0
32896
54741
32896
32896
32896
32896
54741
15420
1
1
32896
54741
15420
54741
32896
1
54741
32896
54741
32896
32896
32896
32896
54741
15420
54741
54741
32896
32896
54741
32896
54741
54741
54741
32896
15420
17476
15420
59110
59110
32896
17476
54741
32896
54741
54741
32...

result:

ok 100 numbers

Test #64:

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

input:

100
3
241 14
47 246
231 35
3
117 168
6 100
65 29
3
201 49
144 60
254 187
3
183 226
93 44
223 24
3
169 74
232 46
113 174
3
187 144
230 16
10 135
3
114 80
105 101
32 115
3
92 131
198 72
244 95
3
108 37
1 219
81 39
3
25 17
180 174
142 101
3
104 81
115 160
71 54
3
102 32
5 30
68 233
3
175 156
97 85
181 ...

output:

32896
32896
32896
54741
0
32896
59110
54741
54741
17476
32896
32896
32896
32896
32896
54741
54741
32896
54741
54741
54741
32896
32896
32896
54741
54741
32896
32896
54741
32896
32896
15420
59110
32896
17476
32896
32896
59110
54741
32896
1
32896
17476
32896
32896
54741
54741
32896
59110
32896
54741
39...

result:

ok 100 numbers

Test #65:

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

input:

100
3
28 48
116 266
44 33
3
165 156
216 154
49 34
3
228 72
156 108
75 168
3
186 281
1 15
124 51
3
62 85
175 23
224 234
3
55 212
148 109
37 22
3
113 47
21 218
100 82
3
144 59
220 93
222 192
3
2 115
84 151
96 81
3
23 185
73 74
164 88
3
215 89
203 185
222 74
3
26 20
66 111
63 212
3
114 116
127 75
170 1...

output:

32896
59110
54741
15420
32896
32896
32896
15420
59110
17476
32896
32896
54741
32896
54741
32896
32896
54741
32896
32896
39321
54741
32896
43690
32896
54741
32896
43690
59110
32896
32896
32896
32896
32896
54741
17476
59110
39321
54741
32896
32896
32896
54741
59110
54741
32896
32896
59110
32896
54741
...

result:

ok 100 numbers

Test #66:

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

input:

100
3
190 197
5 105
99 93
3
45 7
216 120
108 268
3
248 118
124 49
64 230
3
147 63
81 10
75 320
3
72 41
234 288
127 67
3
190 2
225 163
151 233
3
158 94
184 59
55 245
3
61 66
197 76
15 251
3
38 64
238 4
109 329
3
174 102
14 195
224 98
3
39 205
86 24
233 163
3
0 14
66 185
43 194
3
80 233
29 128
169 33
...

output:

32896
54741
59110
54741
32896
1
54741
17476
59110
59110
32896
32896
32896
32896
54741
21846
59110
17476
32896
54741
54741
15420
59110
54741
32896
1
32896
54741
54741
21846
54741
32896
54741
32896
26215
32896
54741
54741
15420
32896
32896
32896
54741
32896
32896
59110
54741
54741
59110
32896
59110
59...

result:

ok 100 numbers

Test #67:

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

input:

100
3
129 34
202 167
237 243
3
196 75
58 335
93 35
3
215 27
206 163
98 255
3
85 10
153 231
168 202
3
198 432
81 4
104 9
3
79 113
16 225
143 108
3
94 414
218 9
118 25
3
142 12
144 30
56 403
3
156 207
5 50
13 190
3
8 33
96 312
139 102
3
215 70
235 178
133 196
3
134 102
199 105
120 235
3
176 78
63 341
...

output:

32896
59110
32896
32896
21846
32896
32896
32896
32896
54741
32896
54741
54741
15420
15420
32896
54741
17476
54741
32896
15420
54741
59110
32896
59110
17476
32896
32896
43690
32896
32896
15420
32896
32896
32896
59110
32896
32896
32896
54741
54741
54741
54741
32896
54741
32896
54741
17476
15420
32896
...

result:

ok 100 numbers

Test #68:

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

input:

100
3
14 197
139 90
78 205
3
160 2
150 181
197 310
3
117 162
88 303
129 32
3
45 235
49 7
130 255
3
108 17
32 179
167 300
3
11 64
126 195
212 234
3
7 137
105 219
190 140
3
38 37
193 398
104 62
3
46 232
129 107
116 158
3
113 8
191 78
60 408
3
185 226
226 198
93 71
3
144 225
208 26
190 245
3
171 92
224...

output:

32896
59110
54741
32896
17476
32896
32896
32896
32896
32896
32896
32896
54741
54741
32896
32896
32896
59110
32896
32896
54741
32896
32896
59110
15420
15420
54741
32896
32896
32896
39321
32896
32896
59110
54741
59110
32896
54741
15420
54741
32896
32896
54741
32896
54741
32896
32896
32896
54741
32896
...

result:

ok 100 numbers

Test #69:

score: 0
Accepted
time: 90ms
memory: 3596kb

input:

100
3
142 71
150 76
46 359
3
4 328
172 15
136 117
3
162 232
57 185
123 61
3
220 167
36 281
235 32
3
88 351
210 21
40 112
3
241 48
42 60
119 348
3
245 214
226 147
65 139
3
15 52
71 414
124 1
3
20 308
109 137
29 44
3
203 78
237 24
43 359
3
158 132
48 159
97 159
3
128 39
169 206
28 215
3
187 244
54 244...

output:

32896
32896
54741
32896
32896
15420
32896
1
32896
32896
39321
32896
32896
32896
1
54741
54741
32896
32896
54741
54741
32896
32896
54741
54741
21846
54741
21846
32896
54741
54741
39321
32896
59110
32896
59110
32896
32896
54741
32896
32896
32896
54741
32896
32896
54741
59110
59110
54741
32896
32896
15...

result:

ok 100 numbers

Test #70:

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

input:

100
163
175 4
56 3
243 4
237 4
171 1
253 3
214 1
126 3
79 2
122 2
254 4
202 4
196 1
98 3
158 1
44 3
85 2
47 1
218 3
217 2
91 4
41 2
134 2
50 1
61 4
152 1
159 2
170 4
181 4
114 4
149 2
151 4
19 2
226 2
150 1
81 3
82 2
31 1
45 4
225 3
180 3
140 1
5 2
52 3
63 3
197 4
234 3
155 2
99 2
7 4
6 1
96 2
69 4
...

output:

54741
54741
15420
32896
54741
32896
43690
15420
32896
17476
54741
54741
32896
54741
59110
32896
32896
39321
59110
32896
32896
32896
32896
54741
32896
32896
54741
32896
54741
54741
32896
32896
59110
32896
15420
32896
54741
54741
32896
32896
21846
59110
32896
32896
15420
59110
32896
32896
59110
32896
...

result:

ok 100 numbers

Test #71:

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

input:

100
161
44 5
39 4
208 1
134 2
53 2
14 1
88 2
38 3
214 2
213 2
140 4
118 2
16 4
17 1
120 2
204 1
177 5
144 4
24 3
86 4
165 1
9 5
55 3
46 4
203 5
32 2
197 4
167 5
93 1
45 1
158 5
185 1
194 4
60 4
245 5
4 4
34 2
130 3
244 3
74 2
64 3
110 1
70 2
162 5
224 4
243 2
65 5
26 4
252 4
112 2
135 2
57 2
143 3
4...

output:

32896
32896
32896
32896
54741
32896
54741
32896
54741
32896
32896
17476
17476
32896
32896
54741
15420
32896
15420
54741
32896
32896
32896
32896
59110
15420
32896
17476
32896
59110
54741
32896
32896
54741
59110
17476
32896
59110
32896
54741
54741
54741
59110
15420
32896
54741
54741
17476
15420
54741
...

result:

ok 100 numbers

Test #72:

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

input:

100
57
99 3
5 2
121 1
192 3
124 3
31 3
120 1
143 2
189 1
125 2
207 2
16 3
223 3
72 3
114 2
101 1
55 3
86 3
129 2
90 3
217 2
118 1
180 1
74 1
147 2
97 3
187 2
178 3
163 3
139 1
93 1
140 3
232 2
196 2
64 1
115 3
10 3
218 3
12 3
224 3
193 2
184 1
8 1
98 1
132 3
220 3
253 2
65 3
110 1
123 3
11 1
102 3
1...

output:

32896
54741
54741
39321
32896
59110
32896
32896
15420
32896
32896
39321
54741
32896
15420
59110
32896
36736
32896
32896
15420
59110
54741
32896
32896
32896
32896
32896
32896
32896
32896
54741
32896
32896
32896
54741
32896
54741
15420
54741
59110
0
22101
15420
0
59110
54741
59110
32896
15420
54741
32...

result:

ok 100 numbers

Test #73:

score: 0
Accepted
time: 131ms
memory: 3604kb

input:

100
168
44 1
9 1
22 1
155 1
48 1
242 2
150 2
227 1
241 2
173 1
110 2
65 1
78 2
57 2
52 2
102 2
84 2
54 2
35 1
202 2
231 2
204 2
210 1
134 2
45 1
130 1
32 2
185 2
191 2
126 2
79 1
252 1
223 2
159 2
165 2
180 2
106 2
53 1
100 2
63 1
243 2
236 2
253 1
41 2
222 2
143 1
255 2
177 1
141 1
51 1
220 2
188 2...

output:

59110
59110
32896
0
32896
59110
15420
10216
32896
59110
59110
32896
32896
32896
54741
32896
0
54741
54741
32896
15420
54741
32896
32896
32896
54741
32896
32896
32896
32896
32896
59110
59110
32896
15420
32896
32896
32896
32896
236
32896
54741
59110
32896
54741
59110
39321
32896
32896
59110
32896
3289...

result:

ok 100 numbers

Test #74:

score: 0
Accepted
time: 195ms
memory: 3604kb

input:

100
71
177 3
38 3
23 3
4 3
37 3
103 2
57 3
203 2
217 2
21 2
15 3
88 3
205 3
18 3
142 2
124 3
218 3
149 2
66 3
90 3
138 3
196 3
237 2
51 3
89 3
109 2
27 2
53 2
74 2
94 2
179 3
28 3
253 3
110 3
250 3
148 3
184 3
251 3
128 2
172 3
77 3
190 3
220 2
243 3
125 2
55 3
238 3
158 2
135 2
134 2
11 3
201 3
33 ...

output:

32896
32896
32896
32896
54741
32896
32896
32896
32896
32896
32896
15420
43690
59110
1
54741
54741
54741
54741
17476
59110
54741
15420
32896
17476
54741
39321
15420
59110
59110
32896
54741
39321
32896
54741
32896
59110
32896
32896
32896
32896
54741
59110
32896
15420
32896
54741
25186
32896
32896
1542...

result:

ok 100 numbers

Test #75:

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

input:

100
2
129 6
189 5
5
99 5
207 6
130 6
91 6
115 6
2
160 6
193 6
4
233 6
153 5
67 6
95 6
1
26 6
8
45 6
121 5
19 6
154 5
247 6
215 5
249 6
81 5
8
78 6
244 5
46 6
73 6
189 6
9 5
130 6
124 6
10
245 6
133 6
60 5
221 6
177 5
235 6
26 6
208 5
201 5
198 5
1
226 5
3
148 5
218 6
15 5
5
163 6
155 5
124 5
187 6
2...

output:

22101
54741
54741
15420
54741
59110
59110
59110
63190
1
54741
26215
32896
54741
54741
59125
30720
32896
32896
59125
59110
32896
32896
54741
54741
1
21846
1
32896
32896
10795
1
1
54741
54741
54741
1
2245
39321
32896
63190
32896
54741
32896
15420
54741
1
32896
54741
15420
21846
54741
35920
39321
21846...

result:

ok 100 numbers

Test #76:

score: 0
Accepted
time: 12ms
memory: 3640kb

input:

100
16
1 8
2 8
3 5
4 4
5 3
6 2
7 2
8 2
9 2
10 1
11 1
12 1
13 1
14 1
15 1
0 999999958
16
1 8
2 8
3 5
4 4
5 3
6 2
7 2
8 2
9 2
10 1
11 1
12 1
13 1
14 1
15 1
0 999999943
16
1 8
2 8
3 5
4 4
5 3
6 2
7 2
8 2
9 2
10 1
11 1
12 1
13 1
14 1
15 1
0 999999928
16
1 8
2 8
3 5
4 4
5 3
6 2
7 2
8 2
9 2
10 1
11 1
12 1...

output:

26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
26215
...

result:

ok 100 numbers