QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#168659#5045. Kingpooty#AC ✓752ms56772kbC++201.1kb2023-09-08 18:34:242023-09-08 18:34:24

Judging History

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

  • [2023-09-08 18:34:24]
  • 评测
  • 测评结果:AC
  • 用时:752ms
  • 内存:56772kb
  • [2023-09-08 18:34:24]
  • 提交

answer

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

long long A[200000], iA[200000], M;
map<long long, long long> m, s;

long long pw(long long i, long long p) {
    if (!p) return 1;
    if (p == 1) return i;
    return pw(i * i % M, p / 2) * (p % 2 ? i : 1) % M;
}

int main() {
    //freopen("in.txt", "r", stdin);
    long long T;
    scanf("%lld", &T);
    while (T--) {
        long long N, w = 0, i, j;
        scanf("%lld %lld", &N, &M);
        for (i = 0; i < N; ++i) scanf("%lld", &A[i]), iA[i] = pw(A[i], M - 2);
        for (i = 1; i <= 4; ++i) for (j = 0; j + i < N; ++j) ++m[A[j + i] * iA[j] % M];
        for (auto it = m.begin(); it != m.end(); ++it) if (it->second >= N / 4) {
            long long z = it->first, zi = pw(z, M - 2);
            for (i = 0; i < N; ++i) {
                auto rt = s.find(A[i] * zi % M);
                long long t = (rt != s.end() ? rt->second : 0);
                s[A[i]] = max(s[A[i]], t + 1);
                w = max(w, t + 1);
            }
            s.clear();
        }
        m.clear();
        printf("%lld\n", w >= (N + 1) / 2 ? w : -1);
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3904kb

input:

4
6 1000000007
1 1 2 4 8 16
6 1000000007
597337906 816043578 617563954 668607211 89163513 464203601
5 1000000007
2 4 5 6 8
5 1000000007
2 4 5 6 7

output:

5
-1
3
-1

result:

ok 4 number(s): "5 -1 3 -1"

Test #2:

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

input:

1000
200 495189361
193302375 262009153 248101278 250233641 303504256 426913173 23261177 206011896 214770731 286184509 492688635 207979481 282629026 450810670 41818047 359796006 445343921 241742611 249404909 41291916 392252331 125287519 92825425 162555413 371172157 420486666 270651384 309213995 11709...

output:

-1
133
-1
187
163
114
114
132
100
108
116
137
115
-1
165
115
142
165
-1
-1
108
129
-1
144
122
-1
111
146
190
159
134
-1
117
180
196
-1
-1
192
123
110
-1
106
153
103
-1
-1
103
169
-1
174
152
-1
181
113
135
-1
153
199
182
-1
177
152
177
162
-1
115
-1
-1
-1
113
128
-1
-1
-1
-1
168
167
-1
140
-1
-1
-1
1...

result:

ok 1000 numbers

Test #3:

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

input:

1000
200 949663931
479217281 320985989 765005251 6434894 250659962 96381980 929176627 859155083 837781618 895381960 276913403 206799800 594561194 451400141 287326771 230131436 499694353 149062037 769076212 249680039 876506380 680573243 672238085 235553233 593493391 524937617 832401231 490042272 4494...

output:

198
-1
-1
-1
120
-1
162
-1
101
-1
103
157
188
-1
-1
177
-1
126
114
-1
177
-1
-1
150
-1
148
140
165
-1
102
-1
192
-1
-1
-1
181
149
196
-1
-1
173
147
-1
149
-1
-1
200
-1
-1
-1
-1
-1
156
-1
114
119
199
127
123
138
169
188
146
-1
137
-1
-1
-1
121
-1
-1
121
-1
-1
-1
108
117
127
-1
127
194
-1
121
-1
-1
12...

result:

ok 1000 numbers

Test #4:

score: 0
Accepted
time: 212ms
memory: 4012kb

input:

1000
200 752331551
23573436 686888652 118880475 606109605 504896777 156156511 407092389 168008046 588489051 384747939 312334251 10179640 389706827 496937297 625716990 602916042 580060754 535624296 196865310 693079720 672788885 104900220 416739470 142969723 655913476 432092835 454858443 698545241 763...

output:

-1
179
-1
-1
126
-1
189
-1
115
-1
-1
-1
175
-1
109
-1
166
190
129
-1
-1
108
-1
135
-1
174
109
-1
183
-1
-1
-1
142
-1
105
159
163
144
-1
-1
-1
124
175
135
183
132
-1
-1
115
-1
-1
130
159
-1
-1
160
138
145
196
-1
123
163
-1
-1
181
-1
137
126
111
-1
-1
110
111
148
-1
-1
131
-1
-1
-1
101
-1
-1
-1
-1
-1
...

result:

ok 1000 numbers

Test #5:

score: 0
Accepted
time: 215ms
memory: 3964kb

input:

1000
200 952479163
404962930 635613728 875512822 126836765 893278336 93755885 802367656 41132902 703323879 109154481 793288802 49973196 534490899 462994291 829278242 789093683 134072789 384627711 513380294 28212590 922131395 333371011 352605762 351655730 28129292 473972568 10559174 951685030 7877219...

output:

-1
-1
-1
171
-1
190
-1
-1
-1
107
-1
-1
176
-1
-1
118
-1
-1
119
-1
-1
160
-1
100
-1
-1
129
190
165
-1
-1
108
-1
-1
-1
188
167
121
189
190
113
153
-1
-1
-1
-1
142
192
186
102
108
-1
-1
-1
-1
-1
137
160
143
146
163
156
163
176
135
-1
-1
-1
-1
-1
-1
-1
-1
117
-1
-1
-1
147
166
-1
200
195
189
177
-1
143
-...

result:

ok 1000 numbers

Test #6:

score: 0
Accepted
time: 256ms
memory: 4372kb

input:

100
2000 146158349
19643059 687117 30976705 141997757 126939439 27291348 99640815 77869374 140943896 108863607 47555226 24332054 20814180 9774186 95917237 54599801 123926643 144812251 18602850 105663323 135089587 86540799 102680207 83257587 98590031 102391932 51059987 8865754 980981 32147720 8025236...

output:

-1
-1
1976
-1
1443
-1
1206
1958
-1
1973
-1
-1
1294
-1
-1
-1
1223
-1
1457
1496
1860
1473
-1
-1
-1
-1
1654
-1
-1
-1
1505
1306
-1
-1
1696
-1
-1
-1
1475
1133
1189
1609
-1
-1
1397
1540
-1
1625
1191
-1
1923
-1
1835
-1
1296
-1
-1
-1
-1
1893
1705
1378
1343
-1
-1
1444
-1
-1
-1
1788
-1
1255
-1
-1
-1
-1
-1
-1
...

result:

ok 100 numbers

Test #7:

score: 0
Accepted
time: 265ms
memory: 6580kb

input:

100
2000 275587717
83150209 104356116 34298444 197772460 101494007 261547554 223901747 141042340 131644199 60357915 86344257 81799664 202980147 152575387 115211945 7568397 260000358 100079566 95526927 11929407 165620994 44220242 62535336 42656523 39073826 149365602 253784018 119905129 214185578 2576...

output:

-1
1379
-1
-1
-1
1294
1717
-1
1569
1573
1375
-1
-1
1151
1859
1927
-1
1953
-1
1655
-1
-1
1986
-1
1019
-1
-1
1791
-1
1641
1783
1092
1488
1364
-1
1640
1875
1080
-1
1860
-1
1509
1578
-1
-1
1303
-1
1783
-1
-1
1744
1727
1525
-1
-1
1462
-1
-1
-1
-1
1316
1389
1144
-1
-1
1361
-1
1866
1334
-1
1313
1792
1286
-...

result:

ok 100 numbers

Test #8:

score: 0
Accepted
time: 251ms
memory: 4372kb

input:

100
2000 728295619
196905643 523233418 352318827 369770119 347085435 127560509 546671396 362387446 649410690 156802530 298823172 508289744 452232923 497191988 294603059 371099463 359230006 112535834 365805832 66877149 503870773 709803811 404046859 570062640 574727791 550224131 433734296 17881765 652...

output:

1982
-1
1859
1702
-1
1998
1377
-1
1731
1754
1498
1079
-1
1329
1879
-1
1334
-1
-1
1105
-1
-1
-1
1756
1165
-1
-1
-1
1328
-1
-1
1307
1815
-1
1666
1159
1263
-1
-1
-1
-1
-1
1443
-1
-1
1796
-1
1122
1310
1183
-1
-1
-1
-1
-1
1687
1122
1906
1200
-1
-1
1899
1543
-1
1487
-1
-1
-1
1885
1263
1325
-1
-1
1164
1548...

result:

ok 100 numbers

Test #9:

score: 0
Accepted
time: 265ms
memory: 6420kb

input:

100
2000 933493147
311022270 68427073 410339431 66474535 75931530 216168461 596520713 772600691 587660302 307741208 399247506 406645429 62857626 3532644 485034914 95405783 290695394 802486951 113550555 678338176 331200438 608959909 689318946 20753772 157370341 699828644 477646090 360131489 626962275...

output:

-1
1314
-1
-1
-1
1309
-1
1693
-1
1491
1438
-1
1012
1591
-1
-1
-1
1008
1917
1829
-1
1580
-1
1904
-1
1903
1155
1509
1378
1328
1050
-1
1576
-1
1752
1469
1858
-1
1261
-1
-1
1951
-1
1563
-1
1317
-1
1502
1867
-1
-1
1623
-1
-1
-1
1956
-1
-1
1215
1619
-1
-1
1852
1957
1561
-1
1493
-1
-1
1649
1110
1484
1429
1...

result:

ok 100 numbers

Test #10:

score: 0
Accepted
time: 347ms
memory: 11648kb

input:

10
20000 394172071
215340230 130633568 345392055 252111757 290095347 168672848 194628253 178431552 4977718 99966452 268841997 280806854 303621488 25038073 104682112 315461954 307022385 171592359 96110115 293022137 333987173 216781089 336833348 28521180 90994503 276664376 261103859 334641831 14856855...

output:

19880
-1
-1
13636
14129
-1
13865
-1
-1
-1

result:

ok 10 numbers

Test #11:

score: 0
Accepted
time: 365ms
memory: 9768kb

input:

10
20000 831500497
756984954 294988881 429721584 295799143 257217177 50456012 13420397 2969434 721431867 225933624 119351587 523441 211421177 294967820 42091607 225669354 190586927 101257586 45651368 244907097 778123162 44054039 684914480 764858903 102131788 351954286 780877035 439837711 428415753 7...

output:

-1
-1
-1
15494
14393
14874
-1
-1
-1
-1

result:

ok 10 numbers

Test #12:

score: 0
Accepted
time: 346ms
memory: 9828kb

input:

10
20000 905983279
751785219 756502769 317100935 46106015 81697243 113450190 218531390 732183548 337309810 77491620 16286634 236726435 305167458 104295335 503145608 404379366 171869896 258486011 272629763 713887214 873622033 534736735 24120356 224608505 36553224 379385885 317448347 393152738 8866108...

output:

-1
-1
-1
-1
-1
12977
13633
-1
14693
10329

result:

ok 10 numbers

Test #13:

score: 0
Accepted
time: 371ms
memory: 9480kb

input:

10
20000 144511651
123896984 53764446 105306768 103158669 35196311 130674500 83966631 5993612 80522785 141568416 27425680 35528114 133382 99203681 76234496 93249763 140627841 75825332 58193203 100605893 10297744 81443846 38431311 134426404 32085087 33126697 128392840 35165175 81204390 69243064 93196...

output:

16666
17656
-1
-1
-1
-1
14609
17394
18594
13681

result:

ok 10 numbers

Test #14:

score: 0
Accepted
time: 752ms
memory: 51980kb

input:

1
200000 503181461
107429481 294405700 206565826 495988566 37179765 6546199 110332231 437691313 274385052 421520839 85026366 327233500 143699080 63667028 327938631 27533615 355276066 487285084 407716484 302709200 376088216 363588280 378116327 196388430 357959260 412581280 391371092 422167063 3623876...

output:

118278

result:

ok 1 number(s): "118278"

Test #15:

score: 0
Accepted
time: 670ms
memory: 43996kb

input:

1
200000 675454867
380042934 556489164 434552374 495189650 369846868 6899165 654717118 562979032 544560057 236120079 673341859 340171590 626783457 137792322 605431841 197948736 156566705 177828951 135991396 96059783 457411474 584395061 6813347 75601485 218667838 124496749 494264789 71692566 28824401...

output:

142643

result:

ok 1 number(s): "142643"

Test #16:

score: 0
Accepted
time: 611ms
memory: 31508kb

input:

1
200000 60324409
51939046 34252820 22461608 29712161 36420311 1147508 32901308 15512233 23334023 35546542 24026620 12210103 53562137 57393256 53634724 3364064 32749246 18441242 1105447 30360481 26761245 41588892 26340436 29909011 51311120 28810668 60004026 10533810 18870790 48746108 44671535 159779...

output:

174335

result:

ok 1 number(s): "174335"

Test #17:

score: 0
Accepted
time: 598ms
memory: 56772kb

input:

1
200000 392960111
181739746 47157565 269347140 65403397 304536088 298245479 330308437 76917091 342532299 273626156 373104074 344820389 241641115 93082829 252043316 189605772 302523233 335962472 31078204 294740895 152851882 207902532 392581791 336280905 7206845 136439293 97424930 348175420 4408133 2...

output:

-1

result:

ok 1 number(s): "-1"

Test #18:

score: 0
Accepted
time: 336ms
memory: 13212kb

input:

1
200000 50665379
1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 4 1 ...

output:

100000

result:

ok 1 number(s): "100000"

Test #19:

score: 0
Accepted
time: 353ms
memory: 13180kb

input:

1
200000 50665379
22623774 11311887 30988633 40827006 20413503 35539441 43102410 21551205 36108292 18054146 9027073 29846226 14923113 32794246 16397123 33531251 42098315 46381847 48523613 49594496 24797248 12398624 6199312 3099656 1549828 774914 387457 25526418 12763209 31714294 15857147 33261263 41...

output:

100000

result:

ok 1 number(s): "100000"

Test #20:

score: 0
Accepted
time: 464ms
memory: 19392kb

input:

1
200000 281130937
1 4 1 8 1 16 1 32 1 64 1 128 1 256 1 512 1 1024 1 2048 1 4096 1 8192 1 16384 1 32768 1 65536 1 131072 1 262144 1 524288 1 1048576 1 2097152 1 4194304 1 8388608 1 16777216 1 33554432 1 67108864 1 134217728 1 268435456 1 255739975 1 230349013 1 179567089 1 78003241 1 156006482 1 308...

output:

100000

result:

ok 1 number(s): "100000"

Test #21:

score: 0
Accepted
time: 465ms
memory: 19516kb

input:

1
200000 738636427
296556719 517596573 628116500 314058250 157029125 447832776 223916388 111958194 55979097 397307762 198653881 468645154 234322577 486479502 243239751 490938089 614787258 307393629 523015028 261507514 130753757 434695092 217347546 108673773 423655100 211827550 105913775 422275101 58...

output:

100000

result:

ok 1 number(s): "100000"

Test #22:

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

input:

1000
2 276978727
260010368 88304478
2 158375449
14007988 42989300
2 265300493
246056707 103672550
2 655511903
430899266 598480001
2 142319921
17136621 100435246
2 457902673
399617359 355188497
2 616379809
417835125 438666049
2 216350689
179035115 102785289
2 886654259
488302044 105632997
2 156729619...

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

ok 1000 numbers

Test #23:

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

input:

1000
4 172781461
150015400 65108653 50648570 10693060
3 604213499
437376898 222624492 558168969
3 405284227
193074404 91587221 353249967
3 566230397
157548757 62762058 466670214
5 363988607
28650347 173788117 104668203 351804479 116840170
5 559821553
155614238 227458796 4497874 59881986 116064362
4 ...

output:

4
2
2
2
-1
-1
3
2
3
2
3
2
-1
2
2
2
2
4
2
5
4
4
4
2
2
2
-1
3
2
2
2
3
2
2
3
2
2
4
2
2
3
2
2
4
2
2
2
2
3
2
5
3
2
2
2
2
2
3
3
2
-1
2
4
5
3
-1
2
-1
-1
-1
2
2
2
-1
2
-1
4
2
3
2
2
2
3
2
3
2
2
2
2
2
2
2
3
2
-1
2
-1
3
3
3
2
-1
2
3
2
2
2
2
3
3
4
4
2
3
5
3
3
-1
2
2
3
-1
5
2
4
2
2
2
3
5
2
-1
3
2
2
3
5
2
2
4
2
3...

result:

ok 1000 numbers

Test #24:

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

input:

1000
2 536585177
99038749 97516014
6 931710817
116137533 795339380 931363320 895475086 868081293 902189276
4 352662481
320313427 171128238 240243123 321888266
3 343322653
337769782 325422317 155123432
8 551127179
435583987 154184412 26763291 157730106 467081434 214177989 376752621 102242465
2 750439...

output:

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

result:

ok 1000 numbers

Test #25:

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

input:

1000
6 983520137
4073771 936439870 628012444 725494051 694294122 726397428
3 600298301
516252993 206871719 106594570
5 843185383
409739584 58706225 264392272 789765489 358945083
2 317735753
40369446 118618621
9 994603937
321579439 666019853 584042329 233744403 596554056 932175802 574951405 567652445...

output:

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

result:

ok 1000 numbers

Test #26:

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

input:

1000
9 181137793
88402334 34127064 40778231 99344870 47917552 49156864 98689397 91212144 47966026
4 219140423
187576650 124413903 143344512 94192217
9 962848531
835278773 745898201 466947470 122665217 896010473 358415763 193653316 645088866 328278834
5 180987523
72892700 145606387 103940405 12258307...

output:

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

result:

ok 1000 numbers

Test #27:

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

input:

1000
200 495189361
262009153 381082199 248101278 250233641 303504256 127600914 23261177 206011896 214770731 286184509 492688635 282629026 450810670 41818047 359796006 453390124 215783700 445343921 491365610 241742611 183253376 100840541 249404909 41291916 392252331 125287519 92825425 162555413 37117...

output:

-1
-1
32
-1
28
24
52
127
-1
-1
-1
-1
105
-1
-1
-1
-1
-1
-1
-1
-1
60
59
111
-1
116
64
24
-1
-1
-1
-1
-1
-1
31
-1
96
-1
126
-1
47
115
5
46
37
103
9
-1
-1
89
68
6
-1
-1
31
-1
182
3
84
-1
64
-1
-1
49
93
-1
55
19
36
-1
50
7
139
24
-1
-1
100
-1
-1
165
-1
-1
70
54
62
-1
108
90
-1
-1
73
-1
-1
32
19
-1
-1
-1...

result:

ok 1000 numbers

Test #28:

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

input:

1000
99 949663931
521264178 680441294 454557236 243767555 776434975 659445800 124852627 204483779 436949150 504730041 228811819 413353981 772761786 755906028 709743605 896903983 838918325 538701921 259760208 29333020 427498642 638931124 222224751 365718195 225857587 743460582 605364405 274635674 107...

output:

90
-1
83
-1
36
116
-1
-1
165
47
-1
149
74
143
-1
-1
-1
38
-1
-1
-1
-1
-1
125
83
50
-1
-1
68
66
-1
85
-1
-1
-1
-1
-1
105
-1
108
165
12
80
-1
175
24
12
-1
65
78
133
-1
28
9
-1
86
-1
-1
54
-1
148
-1
150
90
144
-1
50
93
-1
61
178
-1
-1
21
-1
170
-1
23
-1
-1
94
-1
85
79
8
-1
-1
82
88
109
-1
115
15
-1
-1
...

result:

ok 1000 numbers

Test #29:

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

input:

1000
159 752331551
599149973 603480317 422034841 543646956 363308768 330537984 532849782 698038299 577356026 544143259 150023984 259467628 169965380 117518871 183815137 743745824 365355548 526480746 167665585 221272857 68414747 269927983 566675726 31901053 154154169 631990455 609008629 47502900 4724...

output:

-1
-1
69
49
-1
61
-1
85
-1
-1
-1
70
-1
81
-1
88
-1
6
-1
97
-1
-1
105
-1
55
115
7
31
-1
-1
-1
2
73
151
153
-1
-1
-1
27
-1
-1
104
15
-1
70
31
124
-1
33
-1
66
38
-1
89
100
-1
27
143
-1
-1
-1
49
87
-1
178
-1
-1
77
63
-1
107
-1
-1
-1
137
-1
-1
-1
143
-1
94
99
54
-1
10
65
117
2
-1
86
-1
64
-1
83
-1
109
39...

result:

ok 1000 numbers

Test #30:

score: 0
Accepted
time: 190ms
memory: 14156kb

input:

10
22122 960341387
796052337 363661467 709218486 286067355 683249528 760097513 629568314 284149282 495359042 483125266 133891157 8752663 183679247 807169802 723305290 462506230 329040642 208579593 762868304 620532824 531403616 271098034 310378782 781420160 121479346 461141686 864003227 704595659 325...

output:

11271
-1
-1
-1
15641
1669
14721
6506
1157
2616

result:

ok 10 numbers

Test #31:

score: 0
Accepted
time: 322ms
memory: 15064kb

input:

10
19612 115333193
21863287 113776509 93882752 42747360 17228308 113515445 71057012 48036179 74274742 17453211 35946222 52592949 51378986 88257688 71342397 47031078 18428701 80553217 4854765 74689719 25080491 54573749 20277062 106989220 98396557 48704766 57176079 34381346 53176787 58776617 100639124...

output:

13074
-1
11845
7979
31095
21044
-1
-1
11335
-1

result:

ok 10 numbers

Test #32:

score: 0
Accepted
time: 243ms
memory: 11476kb

input:

10
17468 469083089
437241360 6015002 366282494 383705372 33644946 392701672 146136590 310059099 142258167 405501263 317138813 79329254 30479580 11281076 366991055 212876116 372960196 200275660 311562630 103260610 279542526 67442133 194632377 114987783 412863320 168561593 231240034 412982880 44853624...

output:

9180
9461
8265
-1
-1
-1
-1
-1
-1
14438

result:

ok 10 numbers

Test #33:

score: 0
Accepted
time: 207ms
memory: 5956kb

input:

1000
196 360619613
21385017 105751645 195889351 357488582 327376694 248240466 244466999 113364503 132969675 221145571 141210131 306813840 42364862 174939532 113610945 266567577 111013387 293800812 87057166 122703981 354169328 66925752 76633728 145491 259996538 33877644 12325842 308355902 177302129 3...

output:

138
200
139
199
100
171
118
128
186
100
193
140
121
196
122
121
121
155
198
120
196
98
140
181
199
184
198
198
123
119
147
151
140
123
196
197
123
137
108
197
130
-1
140
-1
111
199
187
199
193
128
184
155
171
198
199
145
-1
188
129
157
199
133
200
107
200
121
147
115
107
107
138
106
176
163
98
155
2...

result:

ok 1000 numbers

Test #34:

score: 0
Accepted
time: 209ms
memory: 3980kb

input:

1000
196 834759407
339059335 703009693 250686913 512342776 400358053 558298750 300511640 591475405 498915730 235387233 86621997 172241914 716935460 465420627 755149320 94257564 95875683 286817254 640227033 430444035 243211506 812010201 179691154 501672926 787696146 164635534 39087129 449026889 82046...

output:

99
101
199
-1
-1
100
-1
98
198
98
-1
-1
99
196
-1
99
99
99
100
100
100
98
198
100
100
100
98
99
199
-1
99
98
100
99
100
198
98
98
99
198
98
99
198
196
197
200
199
98
198
197
99
99
197
200
99
196
100
198
99
99
198
200
197
99
100
197
199
99
99
100
100
100
199
99
196
99
99
-1
100
99
-1
199
-1
196
197
1...

result:

ok 1000 numbers

Test #35:

score: 0
Accepted
time: 207ms
memory: 5872kb

input:

1000
198 840941389
666987045 158998987 86607340 154594842 107054000 702995002 477767539 251744963 187819270 285877205 383894648 26846700 596109094 249883625 653796322 230498498 415773299 308094920 596854169 368416223 545927153 699322665 196768750 307564000 602814230 756713853 461189691 497795093 363...

output:

162
199
184
174
129
116
119
138
198
105
135
151
101
-1
118
113
108
98
126
126
140
171
185
100
200
100
99
196
175
123
141
120
197
99
191
100
198
174
146
128
198
157
196
150
200
167
143
200
197
200
166
146
150
110
137
197
196
115
148
114
128
198
138
200
-1
99
185
137
163
100
125
200
197
111
123
184
10...

result:

ok 1000 numbers

Test #36:

score: 0
Accepted
time: 204ms
memory: 5888kb

input:

1000
198 713367539
592704477 639115848 502376082 677985002 284215291 520708827 562619041 14265777 159630252 172883320 434298155 649625198 448926297 674224776 441142013 356277044 223705928 582677914 494061499 218352641 644929730 33836967 87464948 539821853 694710650 156071616 49094817 236646056 18696...

output:

99
98
99
196
100
-1
199
100
197
196
100
100
101
197
-1
-1
-1
197
196
101
98
101
99
98
196
98
197
98
100
196
-1
99
199
198
200
101
99
100
99
100
199
100
-1
-1
196
99
100
101
99
99
197
197
197
199
199
98
200
99
199
100
199
99
99
198
-1
200
100
198
-1
-1
199
-1
198
-1
98
99
-1
200
196
198
100
101
-1
-1...

result:

ok 1000 numbers

Test #37:

score: 0
Accepted
time: 252ms
memory: 6092kb

input:

100
2000 143966509
51810367 56103163 83824520 50740595 133913126 64221364 140282355 118556056 53501321 41777674 58690986 119822392 133469557 107052578 48178731 88505491 29916195 116166077 89221954 58457829 96608966 100640922 2823224 55003778 2364170 28838834 27798253 44459211 61401033 133488758 5847...

output:

2000
1996
1999
1999
1980
1997
1848
1528
1886
2000
1537
1167
1172
1996
1190
1996
1999
1017
-1
-1
-1
1814
1166
1717
1548
2000
2000
1818
1517
1349
1441
1124
1078
1629
1997
1999
1703
1601
-1
1998
1137
1608
2000
1996
1424
1631
1348
1115
1532
1703
1037
1703
2000
1563
1564
2000
2000
1998
1155
1012
2000
199...

result:

ok 100 numbers

Test #38:

score: 0
Accepted
time: 243ms
memory: 6032kb

input:

100
1997 335443553
142926112 286578888 115603744 103480096 178679160 127615234 191164339 158554895 67264227 163451091 179955632 47245978 310552367 38432484 104031766 71776574 80952576 270039281 54949007 57157922 4014469 127335579 309243801 97848326 167606626 54351463 137392357 76256262 330845261 273...

output:

999
999
1999
1999
1998
998
1998
2000
2000
1996
1000
-1
1996
1996
1997
1999
999
1000
998
1996
1999
1000
2000
1998
-1
-1
1996
999
2000
1000
999
999
-1
1997
1000
1000
1000
1997
1001
1001
1000
1996
999
999
1997
1997
-1
999
1998
1001
1999
-1
-1
-1
1996
1000
1000
1996
1998
2000
1996
2000
1996
998
1996
100...

result:

ok 100 numbers

Test #39:

score: 0
Accepted
time: 248ms
memory: 5992kb

input:

100
1997 414914893
104915962 7911657 16387980 345886123 363129795 120789531 233103979 289656161 315863028 164527592 168231400 49591699 115126446 352860518 349248063 149552652 102154790 167852886 216825108 91623467 321472615 270803746 59480303 27851107 177051576 73069827 59984295 53963626 212208726 2...

output:

1662
-1
1142
1997
1062
1761
1079
1839
1997
1537
1621
1996
1438
1238
1147
2000
1994
1239
1957
1416
1613
1744
1557
1996
1996
1604
1880
1448
1110
1997
2000
2000
1844
-1
1730
1451
1732
1998
1998
1447
1450
1998
1952
1306
1875
1998
1998
1997
1346
1207
1085
-1
1997
1998
1876
1998
1012
1292
1998
1609
1495
1...

result:

ok 100 numbers

Test #40:

score: 0
Accepted
time: 261ms
memory: 6032kb

input:

100
1999 916063903
330656197 276047683 132830683 357337694 543962931 701584290 423475308 144311294 102348844 402736205 339938623 107901115 419062774 136359732 707004353 288708326 478997435 612387750 76059143 555838159 731446732 660799353 101249812 293536468 708103811 481584006 638026919 315432125 59...

output:

1000
-1
-1
1996
998
999
1997
998
2000
2000
1998
998
999
1998
998
-1
1999
998
999
999
1000
-1
999
1997
999
1999
999
1000
1000
2000
998
-1
2000
998
2000
998
2000
999
999
1997
1000
998
1000
1999
998
999
2000
1996
-1
1000
-1
2000
1000
-1
-1
1999
998
999
999
1998
1996
1998
1997
1996
1997
2000
1997
999
99...

result:

ok 100 numbers

Test #41:

score: 0
Accepted
time: 338ms
memory: 7364kb

input:

10
19996 418868123
135326249 289438437 282359507 287896519 240948643 23969930 386869088 37197609 141210149 149630177 345474574 297316606 84150772 64355093 100714721 218729989 78719895 285906077 411404840 281766008 318430553 218363447 116215283 131809780 139730694 287075007 158736991 236081585 364277...

output:

19444
10478
11949
-1
19997
14088
19999
18967
19997
11661

result:

ok 10 numbers

Test #42:

score: 0
Accepted
time: 335ms
memory: 7352kb

input:

10
19998 714660211
702359609 180232485 43205423 383215675 169616617 65116664 188357116 28912213 92213607 441795222 367979289 76844305 464344164 508498949 477562999 159044070 565816804 369519714 104454531 149112470 526104704 201834458 417882801 506105906 160826239 620154699 710640340 149437395 590187...

output:

9999
10000
-1
20000
19996
10000
19996
10000
19997
9999

result:

ok 10 numbers

Test #43:

score: 0
Accepted
time: 336ms
memory: 5460kb

input:

10
19998 59579599
57015919 39700639 33285758 23775317 51759963 55055927 33761485 26019548 28652004 4053271 38094552 28133082 1446215 11844321 58805776 3286374 20797623 44644868 51884648 59386018 36822440 57378952 3467058 46639570 36563527 19624678 8626839 52352409 33535615 52881068 24934749 57905722...

output:

19998
10859
20000
20000
13852
19996
11075
20000
20000
-1

result:

ok 10 numbers

Test #44:

score: 0
Accepted
time: 333ms
memory: 7304kb

input:

10
20000 430954669
57827695 379423244 209125773 151234719 322240633 325110808 335736680 86081507 26240132 5991127 75118890 151677871 100413954 28436553 416924630 60956713 208450814 308249532 161187626 262753556 179961905 261388350 98891313 403725614 375101303 313444780 191382357 197802146 270956084 ...

output:

20000
10000
-1
9999
19996
10000
9999
10000
10000
19996

result:

ok 10 numbers

Test #45:

score: 0
Accepted
time: 505ms
memory: 19520kb

input:

1
199997 997941391
203578315 139016317 632457102 212790425 24872825 396093321 854538583 703909370 412503104 142612770 331882030 801499289 803884413 59300331 135863591 786800729 154026273 348409990 242984771 114259043 351912726 804429808 531492381 68605988 173431399 633922032 277436240 175972621 5005...

output:

116727

result:

ok 1 number(s): "116727"

Test #46:

score: 0
Accepted
time: 510ms
memory: 19520kb

input:

1
199998 989854301
649790290 854346023 78926658 568788737 708007788 862722652 553174913 727783183 982902896 859522783 358141638 155941107 204985202 906153415 1842894 627003915 746355922 768096209 37350550 402668791 642561837 633841457 284747754 143849798 838219533 44457127 175284459 865618191 972085...

output:

184191

result:

ok 1 number(s): "184191"

Test #47:

score: 0
Accepted
time: 524ms
memory: 19520kb

input:

1
199999 842007421
534708255 351204081 144731563 458887402 444503408 66441602 296559112 177333851 594304055 507636630 1219613 88642914 291528583 676984661 85784100 116407527 375029650 709810325 484529666 549365277 457829235 706256628 605272553 601962561 490005834 453219891 620902536 269604647 783498...

output:

127024

result:

ok 1 number(s): "127024"

Test #48:

score: 0
Accepted
time: 506ms
memory: 19528kb

input:

1
200000 860229527
475045006 251613046 142614324 350866299 106419745 369005303 193462478 758471717 452938546 459487750 289251419 60198560 669445175 136861344 195617643 371761871 336865997 234500955 322975850 174871155 11551602 373951037 248943521 182738782 292233284 772334071 792957808 591412871 731...

output:

-1

result:

ok 1 number(s): "-1"

Test #49:

score: 0
Accepted
time: 516ms
memory: 19512kb

input:

1
199997 73135723
35799728 21781792 41004017 32896565 21968007 43669879 6731652 2090087 70035963 14826660 7866725 20416697 69345195 65394208 55024075 25648996 25526578 52211801 7066524 29016311 13846864 2906137 38447468 48860831 21234612 34908478 52727708 15354415 62059048 49360817 35837380 30082322...

output:

199997

result:

ok 1 number(s): "199997"

Test #50:

score: 0
Accepted
time: 503ms
memory: 19384kb

input:

1
199999 908856521
549073532 54634422 118640614 739510877 258314281 695876477 231919255 713893292 813175821 522910339 69981699 457238405 622908962 363875877 710218124 792652559 157216003 693080617 576961689 284633091 893444654 329582136 816620194 597925485 476026824 549496248 337415484 196598190 349...

output:

114023

result:

ok 1 number(s): "114023"

Test #51:

score: 0
Accepted
time: 522ms
memory: 19520kb

input:

1
199999 371793431
71457184 173790154 7138660 335330248 46051811 200357629 131298404 74067585 40154863 128693853 217309669 325443793 160976655 331788852 133862053 102367224 50901124 337806327 268019186 321330775 188144814 63125657 49996849 239893317 140897583 61151293 7179524 129660946 297373932 106...

output:

193122

result:

ok 1 number(s): "193122"

Test #52:

score: 0
Accepted
time: 496ms
memory: 19432kb

input:

1
199996 251402621
51089997 100937781 164176609 182313250 50699190 115203695 160092103 70856954 54361804 77033970 30461261 132167342 100321991 56370805 113818417 186119012 108687975 110156257 147747555 8203580 72040546 249076164 92553794 267836 168100664 248562811 135579259 187494217 188311701 21800...

output:

199996

result:

ok 1 number(s): "199996"

Test #53:

score: 0
Accepted
time: 515ms
memory: 19520kb

input:

1
199997 567823679
57536777 161376268 249183974 294624013 561062936 428479646 349957235 337594083 303142755 33135054 458330599 148626251 478791886 385634543 183115 47261293 524975156 144295415 300695258 326785620 476770136 162585930 71529562 335902553 72124743 72173957 329249554 356287233 86914852 2...

output:

199997

result:

ok 1 number(s): "199997"

Test #54:

score: 0
Accepted
time: 505ms
memory: 19524kb

input:

1
199999 968591321
55629487 39268858 610835715 89275183 570704119 89818967 377224455 134334041 208805950 132961150 250058691 81501913 495823 623503214 937707555 86184321 480608948 337606801 549218763 534170290 167333764 558407639 637708879 396574298 475695025 862460731 966607189 728516163 665551408 ...

output:

-1

result:

ok 1 number(s): "-1"

Test #55:

score: 0
Accepted
time: 508ms
memory: 19468kb

input:

1
199999 462881959
182735821 5334254 16726103 119981187 244720459 38979901 147478088 281266556 238180911 378819685 98295561 42427966 99475142 40098985 175778993 267484876 429189598 360096814 340706909 120389797 74290387 117629263 449682703 5936719 314642574 284813706 87813501 206726737 441879941 128...

output:

199999

result:

ok 1 number(s): "199999"

Test #56:

score: 0
Accepted
time: 497ms
memory: 19444kb

input:

1
200000 45884129
16473010 5338000 21598129 38924417 11326661 37141511 27741746 8308463 41675782 37094413 18672612 19536234 45812537 19219183 36304017 13483773 16376430 24653678 20174752 15160417 26266441 41272005 29665233 6090054 9340117 20684576 9093151 36919517 7485847 12857680 42020867 29369840 ...

output:

100000

result:

ok 1 number(s): "100000"

Test #57:

score: 0
Accepted
time: 507ms
memory: 19520kb

input:

1
199996 757516699
137514181 524419874 301517509 482191071 228913313 755289108 143052043 612364126 192824787 76034925 19835700 298308807 483928869 403730920 385840601 285546766 10891666 677600527 495835760 539053752 713897668 676030930 64710597 504274215 582873771 202588430 505049106 282817914 38549...

output:

99998

result:

ok 1 number(s): "99998"

Test #58:

score: 0
Accepted
time: 515ms
memory: 19568kb

input:

1
199997 607096507
345403388 42216580 379947769 15126984 218635517 98221419 93868619 435499601 299621799 120980510 452558642 227213754 403657692 320506518 505039492 591905267 510179144 522325061 359473855 184601157 529299409 5823982 125665795 529528422 582636192 14190716 532713595 51232586 509013715...

output:

-1

result:

ok 1 number(s): "-1"

Test #59:

score: 0
Accepted
time: 511ms
memory: 19432kb

input:

1
199999 770612231
218593656 570467758 217838898 382691424 103157185 401119271 345318718 317982940 90805671 614356847 128598510 577878829 711523451 326775944 67456870 437054851 94230080 269070381 278902799 424701664 63141333 584539218 240055486 441803656 516394530 665730320 316663280 452129694 26818...

output:

-1

result:

ok 1 number(s): "-1"

Test #60:

score: 0
Accepted
time: 517ms
memory: 19564kb

input:

1
200000 710495239
151356311 457907749 152914392 238053332 37829387 685439027 259700724 113035588 478232966 419564273 555628810 613777030 368858819 40726172 370102184 670494691 373258439 416611603 304341849 195281190 709127934 559291423 587024204 472184980 426612457 72018358 415514116 182294177 6301...

output:

100000

result:

ok 1 number(s): "100000"

Test #61:

score: 0
Accepted
time: 507ms
memory: 19572kb

input:

1
199996 548262919
366739879 212248236 265874760 469683003 17164963 130161105 495398774 377840578 527386243 46550746 377988515 341464670 433778988 391400118 76648442 545298165 464385428 213163326 254699537 368754528 345884504 275348796 509665156 459450539 410371574 4235430 220151977 107364674 162184...

output:

99998

result:

ok 1 number(s): "99998"

Test #62:

score: 0
Accepted
time: 512ms
memory: 19520kb

input:

1
199998 245254193
81315158 171366003 194567856 113149426 184932391 218619800 13354631 34338100 169632419 96171643 111313081 98958750 20197952 51961851 196384059 210581904 164935537 170581643 95174201 110762376 230282100 125749561 9495227 16392543 110534702 39059446 72732699 189254385 95378439 23707...

output:

99999

result:

ok 1 number(s): "99999"

Test #63:

score: 0
Accepted
time: 512ms
memory: 19468kb

input:

1
199999 318818033
250378928 55329969 280685459 10661018 178990038 308985501 155214388 28735530 150019728 298601328 210011674 236144833 174377555 273767221 157661027 76329921 270725217 257596737 214273652 176305389 20944554 64337141 205304886 305391258 190571727 134625778 116819504 81297575 31222753...

output:

100000

result:

ok 1 number(s): "100000"

Test #64:

score: 0
Accepted
time: 512ms
memory: 19476kb

input:

1
200000 68342629
32210212 29417033 27224953 4188561 53594596 47685759 11508887 14493236 31471916 58561015 50443345 25741133 68191520 43391539 22649649 5013655 13593299 25308595 8245110 9981537 28100560 11151232 11496636 5373274 13070320 60103151 46041236 47083831 189456 17371000 13862543 55310994 5...

output:

200000

result:

ok 1 number(s): "200000"

Test #65:

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

input:

1000
198 495189361
491070272 325213197 309012458 232285889 30882442 195631983 24872248 306608336 138927267 307583510 156293171 25753070 400467167 213541716 451043180 485601120 286833532 221236450 41697889 467434450 456465331 250844332 233151817 406527212 59046894 153378286 162636189 200558095 451357...

output:

131
127
107
-1
107
198
-1
100
-1
113
127
196
-1
117
131
-1
109
109
100
198
99
197
196
-1
-1
-1
149
-1
198
196
198
196
111
100
197
169
-1
197
198
-1
199
198
198
98
198
122
-1
-1
136
200
98
98
-1
198
-1
-1
199
105
165
-1
200
130
-1
196
131
-1
165
128
129
116
198
100
-1
100
200
200
170
-1
136
-1
198
13...

result:

ok 1000 numbers

Test #66:

score: 0
Accepted
time: 243ms
memory: 6080kb

input:

100
1996 146158349
145603481 107318748 129139694 62729232 47636174 123825792 57770925 11190649 39769363 25275446 67963555 107361837 85377987 2396063 23875122 27907923 127175218 89918286 66510292 136749564 89007603 28422462 130317387 100273458 39605137 120365026 16626735 112433982 111754074 63283195 ...

output:

1230
1999
-1
1996
2000
1802
1269
1346
1138
-1
1115
-1
2000
1996
2000
1997
1999
999
2000
-1
-1
1997
-1
1997
1000
1996
1998
-1
1009
1531
1998
999
-1
998
2000
-1
1347
1211
-1
1352
1999
-1
1766
1999
-1
1999
-1
999
1996
-1
-1
1230
1012
1000
1053
1003
-1
-1
-1
1466
998
1437
1996
1997
1999
1999
2000
1997
1...

result:

ok 100 numbers

Test #67:

score: 0
Accepted
time: 341ms
memory: 7340kb

input:

10
19996 394172071
202261820 377626042 114921145 302259105 203496323 221113770 343108619 161968546 259753539 194183118 200245449 345939756 190107847 126128821 269844957 102163063 82521015 270550267 125730785 217067698 155491169 165025476 296971167 376519288 107468526 337793117 139936909 98036697 118...

output:

19996
-1
-1
-1
-1
11430
19998
19999
19999
10982

result:

ok 10 numbers

Test #68:

score: 0
Accepted
time: 493ms
memory: 19388kb

input:

1
199996 503181461
19705638 361115738 173496425 403331913 2701725 151719672 230760021 430346260 255909201 274332143 276346571 131403812 427507018 295894689 419645693 262095420 155831397 293691218 116518718 61321935 323361140 101019327 134375111 405462265 261533441 424779585 417975779 502092748 25870...

output:

-1

result:

ok 1 number(s): "-1"

Test #69:

score: 0
Accepted
time: 509ms
memory: 19444kb

input:

1
199998 675454867
630540319 492770853 672408287 433857197 550148655 604901131 615703802 547742151 434889666 558654529 609967911 387989185 331211553 465109461 220794029 257328223 99494129 244419648 546294138 590596631 663314932 654893678 125774374 164104574 94700978 235163032 511055731 210956359 539...

output:

157830

result:

ok 1 number(s): "157830"

Test #70:

score: 0
Accepted
time: 493ms
memory: 19572kb

input:

1
200000 60324409
15767495 35223292 40573168 57331893 7558351 21877392 32522608 50851997 41504393 30470814 23976738 2635572 41575377 24807225 38097569 17964250 48334058 29259205 28616434 31481975 29571699 24669254 13175831 29321847 57660960 20428508 54510491 38504794 12012429 34632111 28898478 86148...

output:

200000

result:

ok 1 number(s): "200000"

Test #71:

score: 0
Accepted
time: 502ms
memory: 19524kb

input:

1
199996 392960111
162684094 29884557 319056515 316328858 297878954 36110979 156469753 318931241 333767251 242669110 303170872 261535984 157524715 214914616 286757014 370784210 239291422 56711095 343995922 78335694 92392954 225264551 387793120 297552894 282160604 108374510 117165237 185889058 348449...

output:

-1

result:

ok 1 number(s): "-1"

Test #72:

score: 0
Accepted
time: 29ms
memory: 3960kb

input:

1000
196 17
7 8 14 16 11 15 5 13 10 9 3 1 6 2 12 4 7 8 14 16 11 15 5 13 10 9 3 1 6 2 12 4 7 8 14 16 11 15 5 13 10 9 3 1 6 2 12 4 7 8 14 16 11 15 5 13 10 9 3 1 6 2 12 4 7 8 14 16 11 15 5 13 10 9 3 1 6 2 12 4 7 8 14 16 11 15 5 13 10 9 3 1 6 2 12 4 7 8 14 16 11 15 5 13 10 9 3 1 6 2 12 4 7 8 14 16 11 15...

output:

196
185
190
197
198
197
174
182
196
197
182
197
195
198
200
182
194
195
198
192
196
189
194
197
200
184
171
197
196
192
188
182
192
199
181
200
198
197
193
197
200
196
196
185
195
198
192
198
195
200
199
199
196
196
196
176
177
197
186
194
199
194
184
197
197
193
174
199
199
198
184
200
189
175
162
...

result:

ok 1000 numbers

Test #73:

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

input:

1000
196 7
3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3 2 6 4 5 1 3...

output:

196
188
197
196
191
196
196
188
198
196
196
196
199
178
196
199
199
195
199
198
195
200
197
195
190
199
197
197
196
200
185
195
197
194
200
192
197
186
197
199
182
195
178
198
199
196
181
199
196
191
174
192
187
196
192
198
194
191
199
200
187
192
194
189
200
196
196
194
181
199
199
198
198
198
187
...

result:

ok 1000 numbers

Test #74:

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

input:

100
2000 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

2000
1990
1996
1987
1979
1985
1998
1999
1968
1995
1990
1997
1996
1996
1996
1997
1987
1980
1997
1989
1986
1998
1996
1997
1996
1999
1998
1998
1992
1996
1996
1998
1995
1998
1999
1983
1998
1992
1995
1996
1999
1994
1999
1999
1996
1986
1996
1999
1999
1995
2000
1998
1989
1996
1999
1995
1998
1979
1990
1989
...

result:

ok 100 numbers

Test #75:

score: 0
Accepted
time: 19ms
memory: 5984kb

input:

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

output:

1979
1994
1997
1986
1983
1998
1997
1994
1998
1999
1998
1991
1999
1995
1999
1998
2000
1997
1996
1998
1996
1996
2000
1999
1998
1987
1997
1993
1989
1997
1998
1978
2000
1990
1997
1995
1994
1972
1990
1992
1995
1998
1997
1994
1997
1998
1998
1996
1981
2000
1996
1997
1999
1975
1994
1998
1999
1988
1996
1996
...

result:

ok 100 numbers

Test #76:

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

input:

10
19996 5
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

19994
19996
19993
19999
19986
19999
19999
19980
19980
19992

result:

ok 10 numbers

Test #77:

score: 0
Accepted
time: 23ms
memory: 6156kb

input:

10
19998 29
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

output:

19997
19999
19995
19988
19995
19999
19987
20000
19980
19993

result:

ok 10 numbers

Test #78:

score: 0
Accepted
time: 29ms
memory: 7028kb

input:

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

output:

199969

result:

ok 1 number(s): "199969"

Test #79:

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

input:

1
199998 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

199998

result:

ok 1 number(s): "199998"

Test #80:

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

input:

1
199999 7
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

199999

result:

ok 1 number(s): "199999"

Test #81:

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

input:

1
200000 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

200000

result:

ok 1 number(s): "200000"

Test #82:

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

input:

1
199999 11
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...

output:

199998

result:

ok 1 number(s): "199998"

Test #83:

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

input:

1
200000 5
4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4 3 1 2 4...

output:

200000

result:

ok 1 number(s): "200000"

Test #84:

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

input:

1
199996 11
3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 9 3 1 4 5 ...

output:

199996

result:

ok 1 number(s): "199996"

Test #85:

score: 0
Accepted
time: 21ms
memory: 6892kb

input:

1
199997 17
9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 16 2 13 8 1 15 4 9 1...

output:

199989

result:

ok 1 number(s): "199989"

Test #86:

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

input:

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

output:

-1
200
159
-1
169
-1
124
114
200
-1
160
184
-1
192
148
-1
123
-1
105
-1
108
158
-1
143
189
192
161
-1
105
171
199
120
-1
-1
-1
161
-1
-1
200
200
-1
182
-1
-1
142
122
200
171
170
166
165
-1
191
-1
-1
200
125
-1
-1
182
200
-1
186
-1
-1
-1
-1
-1
121
160
142
108
-1
-1
133
172
156
109
-1
-1
-1
-1
-1
145
...

result:

ok 1000 numbers

Test #87:

score: 0
Accepted
time: 39ms
memory: 5832kb

input:

100
2000 23
1 9 15 11 8 18 6 7 2 16 13 5 9 14 12 15 4 8 13 9 3 1 8 8 18 6 2 12 16 22 13 9 7 12 21 11 4 9 3 6 1 8 18 6 1 2 16 7 13 12 4 9 8 3 15 1 8 18 16 6 20 6 9 2 16 13 12 4 9 6 7 3 22 1 8 10 18 11 6 2 16 1 13 8 12 12 1 4 18 9 5 14 1 22 3 1 8 1 8 8 10 18 6 2 16 7 13 12 9 4 9 3 1 18 15 13 12 3 8 1 ...

output:

1060
1970
-1
1601
1114
-1
2000
2000
1588
-1
1088
-1
-1
1013
1319
2000
1709
-1
2000
1300
-1
-1
2000
1345
-1
1452
-1
-1
1668
1439
-1
1530
-1
1895
2000
-1
-1
2000
1395
1042
1728
1709
-1
1021
1103
-1
-1
-1
1806
1530
2000
1843
-1
1014
-1
1386
1604
-1
-1
2000
1346
-1
-1
-1
1996
2000
-1
-1
1505
1821
1332
1...

result:

ok 100 numbers

Test #88:

score: 0
Accepted
time: 36ms
memory: 6020kb

input:

10
20000 7
5 5 6 6 1 1 1 3 6 5 4 5 6 4 2 5 4 1 1 2 3 1 1 5 4 6 5 1 6 4 3 6 1 4 5 1 5 1 2 6 5 2 6 1 6 2 2 6 4 6 1 3 1 6 5 4 1 5 1 2 6 1 5 1 6 4 5 4 1 1 3 4 2 5 2 6 3 2 3 4 2 2 3 5 1 2 6 3 2 6 2 3 6 6 5 2 1 6 5 5 2 4 6 6 5 5 3 1 6 6 6 4 3 3 1 4 3 5 5 4 4 5 6 1 1 4 4 5 3 3 3 1 2 5 3 5 3 3 4 6 1 1 1 5 5...

output:

-1
-1
13812
-1
10803
15968
20000
18918
-1
16489

result:

ok 10 numbers

Test #89:

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

input:

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

output:

-1

result:

ok 1 number(s): "-1"

Test #90:

score: 0
Accepted
time: 105ms
memory: 6972kb

input:

1
200000 13
12 8 4 9 4 6 4 10 11 6 2 4 6 12 8 1 2 1 10 5 7 2 3 8 5 6 4 2 10 10 9 11 12 8 1 2 6 6 9 10 12 9 5 4 6 6 12 11 2 11 7 11 3 3 6 7 6 10 11 7 8 7 4 2 10 6 1 8 7 9 4 10 6 7 4 5 10 5 10 3 4 7 7 2 5 9 8 7 9 3 4 12 9 12 2 6 2 4 9 12 12 10 6 10 3 11 1 8 5 9 8 8 10 9 6 3 11 8 6 12 4 10 1 5 3 2 7 12...

output:

-1

result:

ok 1 number(s): "-1"

Test #91:

score: 0
Accepted
time: 19ms
memory: 6940kb

input:

1
200000 3
2 2 1 2 2 2 2 2 2 2 2 1 1 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 1 2 1 2 1 2 2 2 2 2 2 2 2 1 1 2 2 1 2 2 2 2 1 2 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 1 2 1 1 2 2 1 2 1 2 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 1 2 2 2 2 2 2 2 2 2 2 1...

output:

163042

result:

ok 1 number(s): "163042"