QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#270219#1427. FlipzhouhuanyiAC ✓362ms242852kbC++202.1kb2023-11-30 16:40:152023-11-30 16:40:16

Judging History

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

  • [2023-11-30 16:40:16]
  • 评测
  • 测评结果:AC
  • 用时:362ms
  • 内存:242852kb
  • [2023-11-30 16:40:15]
  • 提交

answer

#include<iostream>
#include<cstdio>
#define N 200002
#define Base 300
#define mod 998244353
using namespace std;
int read()
{
    char c=0;
    int sum=0;
    while (c<'0'||c>'9') c=getchar();
    while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
    return sum;
}
void Adder(int &x,int d)
{
    x+=d;
    if (x>=mod) x-=mod;
    return;
}
int fast_pow(int a,int b)
{
    int res=1,mul=a;
    while (b)
    {
	if (b&1) res=1ll*res*mul%mod;
	mul=1ll*mul*mul%mod,b>>=1;
    }
    return res;
}
int n,q,k,inv2,fac[N+1],invfac[N+1],b[N+1],f[N+1],s[N+1],sr[Base+1][N+1],ans;
int C(int x,int y)
{
    if (x<y) return 0;
    return 1ll*fac[x]*invfac[y]%mod*invfac[x-y]%mod;
}
int MD(int x)
{
    return (x>=mod)?x-mod:x;
}
int MD2(int x)
{
    return (x<0)?x+mod:x;
}
int F(int x,int y)
{
    if (x>n||y>n||x<0||y<0) return 0;
    return C((n<<1)-x-y,n-x);
}
int G(int l,int r)
{
    return (!l)?s[r]:MD2(s[r]-s[l-1]);
}
int main()
{
    fac[0]=f[0]=1,inv2=(mod+1)>>1;
    for (int i=1;i<=N;++i) fac[i]=1ll*fac[i-1]*i%mod,f[i]=1ll*f[i-1]*inv2%mod;
    invfac[N]=fast_pow(fac[N],mod-2);
    for (int i=N-1;i>=0;--i) invfac[i]=1ll*invfac[i+1]*(i+1)%mod;
    n=read(),q=read();
    for (int i=1;i<=N;++i) s[i]=MD(s[i-1]+1ll*C(i,n-1)*f[i]%mod);
    for (int i=2;i<=Base;++i)
    {
	sr[i][n<<1]=0;
	for (int j=(n<<1)-1;j>=1;--j) sr[i][j]=MD(sr[i][j+1]+1ll*F((n<<1)-j,i+1)*f[j]%mod);
    }
    while (q--)
    {
	k=read(),ans=0;
	for (int i=1;i<=k;++i) b[i]=read();
	//[b[k]+1,n]
	if (k<=Base) Adder(ans,sr[k][b[k]+1]);
	else
	{
	    for (int i=b[k]+1;i<(n<<1);++i) Adder(ans,1ll*F((n<<1)-i,k+1)*f[i]%mod);
	}
	//b[k]
	if (b[k]!=(n<<1)) Adder(ans,1ll*F((n<<1)-b[k],k)*f[b[k]]%mod);
	//[1,b[1]-1]
        if (1<=b[1]-1) Adder(ans,1ll*s[b[1]-2]*f[1]%mod);
	//[b[i]+1,b[i+1]-1]
	for (int i=1;i<=k-1;++i)
	    if (b[i]+1<=b[i+1]-1)
	        Adder(ans,1ll*G(b[i]-i,b[i+1]-i-2)*f[i+1]%mod);
	//[b[k]+1,(n<<1)-1]
	if (b[k]+1<=(n<<1)-1) Adder(ans,1ll*G(b[k]-k,(n<<1)-k-2)*f[k+1]%mod);
	printf("%lld\n",2ll*ans%mod);
    }
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 5ms
memory: 39548kb

input:

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

output:

499122177
748683265
748683265
748683265
748683265
499122177

result:

ok 6 numbers

Test #2:

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

input:

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

output:

935854081
623902721
374341633
935854081
686292993

result:

ok 5 number(s): "935854081 623902721 374341633 935854081 686292993"

Test #3:

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

input:

2 1
2 1 2

output:

499122177

result:

ok 1 number(s): "499122177"

Test #4:

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

input:

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

output:

623902721
561512449
873463809
935854081
873463809
873463809
561512449
499122177
686292993
873463809
623902721
935854081
935854081
623902721
374341633
686292993
686292993
686292993
935854081
935854081
748683265
935854081
935854081
686292993
873463809
873463809
935854081
935854081
748683265
686292993
...

result:

ok 35 numbers

Test #5:

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

input:

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

output:

873463809
811073537
811073537
904658945
982646785
904658945
904658945
748683265
499122177
904658945
904658945
967049217
904658945
967049217
655097857
655097857
811073537
982646785
873463809
982646785
904658945
982646785
982646785
655097857
967049217
748683265
982646785
499122177
982646785
982646785
...

result:

ok 154 numbers

Test #6:

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

input:

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

output:

970948609
990445569
935854081
935854081
994344961
990445569
970948609
885161985
885161985
826671105
885161985
935854081
779878401
970948609
850067457
982646785
994344961
994344961
967049217
963149825
990445569
959250433
994344961
635600897
873463809
994344961
885161985
935854081
970948609
970948609
...

result:

ok 627 numbers

Test #7:

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

input:

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

output:

962174977
962174977
795475969
988495873
984596481
996294657
830570497
996294657
986546177
889061377
744783873
958275585
514719745
935854081
986546177
997269505
976797697
962174977
978747393
889061377
986546177
994344961
990445569
997269505
997269505
982646785
986546177
997269505
978747393
997269505
...

result:

ok 2497 numbers

Test #8:

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

input:

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

output:

955351041
601481217
994588673
995563521
908558337
987033601
998000641
987033601
988495873
997756929
995563521
997756929
998000641
976797697
997269505
996050945
993857537
997269505
915382273
992882689
995563521
994832385
995563521
983621633
847142913
987033601
997756929
995563521
998000641
998000641
...

result:

ok 9893 numbers

Test #9:

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

input:

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

output:

998122497
997756929
987521025
996538369
997635073
982646785
998122497
996538369
997269505
947552257
998122497
998122497
994832385
997635073
997269505
887111681
998183425
944993281
984596481
901490689
901734401
994832385
997635073
998183425
981671937
917331969
997025793
998183425
975335425
534216705
...

result:

ok 29892 numbers

Test #10:

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

input:

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

output:

997391361
993568129
996888705
996203265
998076801
993689985
931771905
997970177
997848321
990308481
997223809
998229121
998229121
998213889
998213889
960560385
997223809
998076801
971024769
998229121
998076801
998076801
997970177
998046337
995807233
998229121
998213889
998213889
996812545
998213889
...

result:

ok 26355 numbers

Test #11:

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

input:

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

output:

997928289
998122497
998046337
998191041
998168193
998152961
998122497
997543681
998198657
998168193
997852129
998107265
998000641
997852129
998168193
997821665
998168193
995106561
982646785
991481345
997760737
997817857
998236737
998240545
998229121
989642081
998236737
998229121
979417601
997795009
...

result:

ok 23516 numbers

Test #12:

score: 0
Accepted
time: 17ms
memory: 17704kb

input:

424 100000
2 573 614
2 97 472
2 80 738
2 496 689
2 67 689
2 255 782
2 236 760
2 768 807
2 78 634
2 574 839
2 16 277
2 208 649
2 700 833
2 495 673
2 67 550
2 33 676
2 623 755
2 248 452
2 209 650
2 302 731
2 683 794
2 181 484
2 142 637
2 453 689
2 75 363
2 470 832
2 83 438
2 139 591
2 305 820
2 192 64...

output:

500251737
71459114
376281957
781245545
926558642
130535826
492689612
836331657
451512960
520340648
499122177
482622651
968197558
660496914
528359545
682199824
650647126
151173145
954520149
753606460
886885828
185546645
300257773
147509300
499122177
978183660
941043090
763672826
375756651
263701426
8...

result:

ok 100000 numbers

Test #13:

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

input:

424 80016
3 216 714 738
2 457 655
2 2 652
3 110 569 803
2 242 844
3 450 645 794
2 111 431
2 465 470
3 64 210 450
2 61 477
3 399 695 814
2 653 785
2 518 753
2 616 768
3 43 57 837
2 40 333
2 27 91
3 254 416 527
2 377 566
2 157 500
3 64 177 576
3 117 400 599
3 27 276 368
2 337 569
3 59 167 429
3 196 49...

output:

673405868
59074833
229195676
37867611
544266613
741017403
773005893
630559342
518319993
101206093
964469263
964478874
371468700
672178956
302417057
499122177
499122177
33812301
465919058
22625518
430738213
537605766
748683265
379902066
794856790
58638817
499122177
663272510
388603892
994452316
39759...

result:

ok 80016 numbers

Test #14:

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

input:

424 57094
2 556 699
2 67 779
3 591 652 777
5 181 282 656 714 824
3 219 382 722
2 385 442
2 6 240
3 23 599 803
4 330 370 781 809
2 247 569
5 149 204 493 721 722
4 78 112 713 768
2 33 309
4 222 355 513 772
2 523 539
5 205 255 456 605 804
3 319 557 586
5 1 137 369 425 841
2 79 498
5 9 331 511 543 729
5...

output:

700511585
336208066
250427669
700063600
114567743
597481640
499122177
582205248
916891013
379902066
254425723
384862392
499122177
567618838
947783404
610815158
680031142
972253816
989492967
728992246
382946737
160032912
432451476
836673776
461550803
265481698
195706775
935854081
972829715
246146602
...

result:

ok 57094 numbers

Test #15:

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

input:

424 33397
5 3 14 571 600 641
4 26 32 570 715
4 176 337 471 704
3 327 586 844
2 78 712
2 69 267
8 5 187 388 467 489 531 730 824
4 5 247 301 506
3 320 501 780
8 117 135 345 366 444 551 777 806
2 368 648
5 93 203 453 540 634
3 233 263 494
4 225 599 750 832
6 70 338 431 513 629 630
7 153 243 326 374 699...

output:

258554399
973701407
352006816
672016306
676237528
499122177
448374058
409445405
923158804
884938384
662043080
90899724
940514139
439410877
222127318
991644943
324918103
24312910
385129743
499122177
402263349
348504002
499122177
736265698
930707244
932328766
661738363
101507938
429075514
863284754
24...

result:

ok 33397 numbers

Test #16:

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

input:

424 9013
21 85 134 167 231 309 326 328 345 374 385 393 427 478 563 564 680 727 756 759 768 782
3 138 347 512
8 2 205 414 554 559 650 720 796
42 18 20 58 70 140 178 198 209 217 227 228 243 253 293 296 314 323 330 346 389 397 437 442 470 477 484 486 519 520 533 549 554 613 635 649 668 757 758 771 815 ...

output:

359947232
345763476
153168287
931606672
132253200
661428734
151622956
128128349
248129845
446074605
47681533
890652173
134247310
369407769
814026022
994605875
24496488
609233975
613783092
18536037
802562067
611194094
56786797
488810216
393598191
731411462
781136346
901255528
515714293
365096742
6388...

result:

ok 9013 numbers

Test #17:

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

input:

424 1631
177 2 6 8 10 11 18 25 27 28 31 34 46 47 55 63 64 68 73 74 84 89 92 97 98 110 111 112 115 118 123 127 128 145 147 148 159 161 164 170 173 175 178 180 186 189 194 205 208 210 215 221 223 227 230 232 233 246 250 256 257 258 263 265 270 271 272 286 291 292 295 296 303 306 315 317 323 326 333 33...

output:

694194039
153688206
97225167
327462442
270952193
64454052
471239184
898340252
617538198
772377341
145335918
657026753
654487524
596209356
249986418
144243345
859974184
695542182
451209541
582643515
705256294
389043541
832877353
686526211
985181702
693330512
472626975
938314438
615660280
302969085
74...

result:

ok 1631 numbers

Test #18:

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

input:

424 936
208 8 11 22 24 25 29 34 40 43 48 50 51 53 55 56 58 64 66 69 72 75 77 83 87 89 92 95 97 98 121 133 137 144 147 148 150 158 162 164 166 168 171 172 174 175 177 181 192 198 202 203 205 206 209 213 218 221 225 235 237 243 244 246 249 253 254 259 264 267 276 277 278 279 280 293 295 301 304 313 31...

output:

637032381
804722067
518128766
978435534
354291117
102765860
958720517
578141252
857214629
149021310
458138399
985557886
564646278
306018356
229047947
284820745
224063804
483594130
95114741
227532085
351192862
735043850
282960612
13266812
781740524
962416625
706515260
615095936
794550857
691186191
73...

result:

ok 936 numbers

Test #19:

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

input:

908 100000
2 602 1144
2 643 1735
2 666 871
2 270 371
2 317 958
2 334 753
2 238 684
2 384 1545
2 664 1519
2 1553 1614
2 671 837
2 201 448
2 1100 1229
2 823 1528
2 504 1544
2 361 1133
2 1088 1491
2 564 1227
2 484 1439
2 40 154
2 663 1275
2 988 1353
2 103 1496
2 529 982
2 465 726
2 1441 1609
2 858 1678...

output:

432469389
435243083
499122177
499122177
829787609
499122177
499122177
804904146
769298409
469986033
499122177
499122177
606841122
503571031
260810735
150328567
582094515
254992895
210488507
499122177
238184989
383271412
783772468
312261328
499122177
956211490
508330899
499122177
499122177
265928621
...

result:

ok 100000 numbers

Test #20:

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

input:

908 80013
2 594 1257
2 15 1649
2 349 736
3 531 777 1308
2 24 480
2 1061 1401
2 367 709
3 838 1048 1427
3 283 413 1588
2 513 1208
2 151 801
2 907 1149
3 250 458 1186
3 865 1412 1785
2 523 1726
2 400 1452
3 5 1481 1697
2 39 555
3 872 973 1755
2 52 287
3 603 835 1511
3 790 1001 1086
2 1066 1515
2 989 1...

output:

632546817
274424826
499122177
698761716
499122177
365205676
499122177
88714289
911798516
281291738
499122177
805357867
754761170
259946376
43362555
488685527
2192658
499122177
804704813
499122177
946903403
901640397
587720717
166656670
277636163
219433210
934425197
127515040
228760560
380589266
7115...

result:

ok 80013 numbers

Test #21:

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

input:

908 57015
5 435 731 844 986 993
3 837 1278 1523
5 282 558 916 1055 1423
4 66 377 1375 1474
5 213 915 1150 1367 1702
3 316 587 1564
3 1136 1363 1762
5 300 585 1284 1291 1361
3 115 141 305
4 436 624 1228 1504
4 416 490 764 1493
4 515 598 642 1603
5 43 260 505 1123 1249
3 748 1101 1637
2 576 749
5 230 ...

output:

988976599
129702419
755388476
676296593
243230068
690933289
542601916
569946365
748683265
226656245
579062397
239819203
832795720
506577775
499122177
389854255
241571803
499122177
499122177
87223422
12008562
953410021
780624479
499122177
490447832
695999711
194024541
811850361
451556207
384008170
60...

result:

ok 57015 numbers

Test #22:

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

input:

908 33295
4 48 210 601 928
7 137 412 1116 1138 1217 1304 1729
10 41 335 624 733 812 1370 1416 1653 1679 1743
5 113 123 399 1030 1719
4 1022 1238 1253 1804
4 35 46 817 1027
2 295 527
5 119 311 484 1011 1588
4 434 529 650 654
5 496 856 967 1342 1701
6 239 387 610 710 834 1303
8 346 459 626 913 1070 11...

output:

479553800
483145800
845059321
894502961
19997121
755783610
499122177
157575622
873463809
249350177
905302670
223023041
935854081
472767241
77979538
60842379
683141814
705050572
215061784
686975673
287559677
358024870
329045213
851501827
499122177
477991365
748683265
370020528
650370407
298825801
197...

result:

ok 33295 numbers

Test #23:

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

input:

908 9016
34 74 90 142 179 209 210 234 283 294 297 311 318 350 363 452 542 633 655 676 680 885 940 945 1062 1231 1321 1396 1481 1527 1558 1620 1667 1716 1726
28 15 192 204 251 354 355 398 426 438 605 640 702 824 1149 1166 1172 1224 1248 1266 1274 1296 1340 1364 1513 1606 1661 1719 1720
22 25 128 151 ...

output:

684850922
102685465
587602018
192803081
104356753
886094449
339644376
684905730
986235788
397866013
629989612
178560870
179916283
993853267
409989514
595179362
364598370
364432178
411029211
491675779
997621910
435973655
722810556
793831288
404271642
317295242
388266240
157032313
915948369
996397673
...

result:

ok 9016 numbers

Test #24:

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

input:

908 1635
18 16 21 31 130 146 251 430 454 800 816 1019 1037 1128 1160 1163 1299 1654 1759
123 12 22 31 44 101 114 124 125 136 176 188 213 225 254 256 257 258 293 298 325 351 355 361 370 372 405 422 434 435 443 550 582 596 601 604 606 619 641 645 647 668 701 718 723 734 737 743 765 778 796 797 813 822...

output:

776414659
966574330
929954042
583747197
281282988
434326834
31556607
899407597
961260367
570768904
423675446
658161366
382009235
933429025
925465940
186719797
783228767
722585074
552223410
233334409
512223827
435519626
190286079
392230404
976978121
856828918
195264966
810478712
444283232
17936506
99...

result:

ok 1635 numbers

Test #25:

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

input:

908 438
604 4 6 9 11 14 15 19 21 24 28 29 34 37 38 39 44 45 47 52 53 54 55 57 60 62 63 75 79 81 82 86 87 90 91 95 97 100 105 106 108 110 111 113 115 116 118 119 122 128 130 131 133 134 138 139 141 142 147 154 159 160 166 170 172 178 179 183 185 192 193 194 195 196 205 211 212 213 216 221 222 231 235...

output:

8874719
978103948
216347762
150730405
234108521
403971551
871699306
492073378
258631866
616427154
142870225
593743354
127762407
665284909
867565706
973174176
597870964
932641423
908730094
77063154
668119019
370933544
290374999
20996680
165936721
697304357
631693643
348986941
658126902
198323352
3341...

result:

ok 438 numbers

Test #26:

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

input:

1000 100000
2 5 1306
2 809 1238
2 106 1911
2 322 760
2 765 1915
2 1706 1943
2 305 792
2 250 1191
2 152 1802
2 421 1720
2 218 277
2 940 1499
2 38 657
2 157 543
2 1496 1654
2 1222 1600
2 448 1475
2 629 1189
2 968 1433
2 483 536
2 470 1322
2 101 206
2 809 1546
2 142 1679
2 998 1251
2 206 1330
2 6 297
2...

output:

461072407
618532200
635672046
499122177
150761876
536232691
499122177
16863774
183968102
365296282
499122177
332550455
499122177
499122177
530974872
833563576
393138104
896730731
184585004
499122177
126148624
499122177
531464645
123018767
379597290
261949548
499122177
499122177
583253406
725478266
4...

result:

ok 100000 numbers

Test #27:

score: 0
Accepted
time: 17ms
memory: 14228kb

input:

1000 80037
2 790 1432
3 196 751 1622
3 55 291 1378
2 367 1611
3 336 513 1720
3 544 857 1477
2 19 863
3 1315 1439 1803
3 309 1069 1529
2 275 1998
3 531 1114 1174
2 1038 1715
2 424 830
2 284 317
2 89 913
3 638 1473 1984
3 76 368 1925
3 1039 1076 1372
3 398 904 1788
2 4 816
3 273 1026 1727
3 254 811 19...

output:

64360552
680147341
924586857
308333209
614857370
882591355
499122177
576098832
110247542
128928877
176768765
336267947
499122177
499122177
499122177
244882497
370990200
267750996
876918713
499122177
403509656
324491909
876752317
697133465
132265652
544116326
89094649
748683265
473686315
526858327
67...

result:

ok 80037 numbers

Test #28:

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

input:

1000 57071
4 453 939 1102 1240
4 42 632 1262 1776
4 46 777 1301 1988
4 309 542 609 665
5 451 896 917 1322 1460
5 281 1467 1760 1815 1847
2 833 1374
4 519 802 1365 1562
5 269 477 935 1400 1485
2 208 1746
2 883 1099
3 565 1267 1324
2 451 1919
3 888 1754 1961
2 254 465
2 436 831
2 799 1897
2 1640 1694
...

output:

334164362
63611945
468356671
873463809
463163257
636386848
213774240
304964654
946112830
175983160
727959123
802929023
633805109
313596787
499122177
499122177
176865197
278032754
447336726
612527929
891388978
150761876
499122177
292229500
508451066
862126345
809312824
807242786
832074471
218869217
9...

result:

ok 57071 numbers

Test #29:

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

input:

1000 33411
9 186 408 494 520 549 802 1060 1422 1942
8 21 312 406 478 495 613 652 1553
8 626 671 793 839 990 1197 1624 1826
8 712 923 988 1439 1757 1831 1959 1961
5 632 640 872 1687 1727
10 348 395 608 762 1353 1382 1688 1820 1884 1988
2 1150 1612
7 193 261 301 371 638 1594 1775
3 451 1822 1913
5 264...

output:

783071650
879361056
712438530
87941039
752527806
576201403
93051353
458068021
876377918
461888158
389816871
889156906
869579673
23144493
111925156
472751060
635526842
671610399
113556153
909221012
810730991
723888316
514301430
205496995
242426632
564212446
499122177
599529771
396121394
124062330
445...

result:

ok 33411 numbers

Test #30:

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

input:

1000 9065
10 48 64 213 581 1170 1302 1337 1551 1682 1999
7 1 2 1038 1110 1724 1791 1911
15 39 391 486 576 592 688 822 847 925 933 940 991 1021 1362 1933
9 720 762 872 929 950 955 1590 1755 1899
11 109 129 214 240 379 817 1321 1473 1594 1612 1657
35 40 60 61 180 235 325 362 544 610 627 642 662 679 74...

output:

898795304
69360371
150329788
697099451
407149592
634852290
538579791
652623196
1200742
47685366
270024627
976855118
488736876
880042496
59777035
577543744
712415117
495931564
566660830
667332267
162545259
748005013
903952572
467763975
771446190
522970315
262057830
20722403
982369038
181876703
293327...

result:

ok 9065 numbers

Test #31:

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

input:

1000 1683
128 3 17 33 46 50 55 58 63 73 85 116 144 157 197 217 229 243 252 256 275 295 319 321 324 328 343 350 400 409 424 429 431 436 440 444 469 492 503 544 555 559 575 582 585 607 618 622 629 647 651 684 692 703 733 763 770 786 788 807 808 819 825 829 832 885 901 912 953 987 989 993 997 1001 1015...

output:

624712570
555970681
142276974
880338058
459253539
443842894
987754490
144538388
299714805
857067442
109504005
840964113
955909875
412556064
742721771
544084126
421008944
697955998
500966143
174496901
921107295
781175080
863440606
143642513
337736560
568585107
361418691
595833702
839430031
421188800
...

result:

ok 1683 numbers

Test #32:

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

input:

1000 386
949 1 2 4 6 8 11 13 15 17 19 21 23 24 26 28 29 30 33 34 35 36 38 39 41 43 44 50 52 55 56 57 62 63 64 65 66 67 70 75 76 77 80 82 83 87 92 93 94 95 97 100 103 107 109 111 112 116 119 127 129 130 131 132 133 135 137 141 142 143 144 145 146 147 150 151 153 156 159 163 166 167 168 169 170 171 17...

output:

167324407
535384118
506186107
145446725
661673145
110891065
622909173
609757981
22965290
827842946
111216736
976515752
911003748
532549034
412402561
526791780
41604828
480442269
973186266
951176447
13638307
199501161
227038849
334337439
222703013
68805267
104559025
244072885
48164590
365506110
17838...

result:

ok 386 numbers

Test #33:

score: 0
Accepted
time: 103ms
memory: 128148kb

input:

40211 100000
2 13602 33495
2 22521 43095
2 9285 28105
2 36531 53101
2 34750 78552
2 17202 48763
2 565 18755
2 40308 69681
2 51120 51865
2 25067 35192
2 57801 74384
2 21421 63509
2 50036 57314
2 44264 73804
2 9301 79858
2 15277 33465
2 623 62871
2 46357 64170
2 44522 65729
2 33792 76118
2 35663 60797...

output:

499122177
791078450
499122177
580665213
833751686
775700222
499122177
262414963
795569380
499122177
976158321
386043343
31834524
282301057
772529712
499122177
432082522
614561649
835462479
29766727
79842648
499122177
977962810
783255856
497955563
148176883
588978251
499122177
876367501
517582948
499...

result:

ok 100000 numbers

Test #34:

score: 0
Accepted
time: 96ms
memory: 123276kb

input:

40211 80052
3 15025 28071 67073
3 20121 47324 80151
3 4354 18731 69746
2 39234 47988
2 67860 77836
2 27518 43441
2 16104 76277
2 25597 43070
3 6797 19240 78499
3 25873 43182 62700
2 63854 75614
2 22019 61500
2 67540 69024
3 12547 39522 67694
3 8683 17655 58907
3 17622 51181 53133
3 1945 8459 30728
2...

output:

420730842
989915855
768008305
152803540
166905870
125431040
793846988
157268460
803488160
478777783
896484159
978926632
854560034
432367293
756028075
139549303
748683265
499122177
23247947
982464384
505561127
289279150
926912423
840691100
486518797
817468665
476227643
132766919
154884223
904299652
8...

result:

ok 80052 numbers

Test #35:

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

input:

40211 57062
5 11931 36755 41746 50147 60386
2 16078 32674
4 3879 10666 18942 62605
4 1402 12452 14763 26574
3 19083 29460 35084
3 14397 35804 39734
2 32199 58961
3 52229 62612 79935
4 17350 42501 56545 64086
3 5685 27721 45226
5 1487 26753 37245 70835 76819
2 35852 37172
2 30252 71095
3 44056 53223 ...

output:

84410991
499122177
667325413
873463809
748683265
748683265
263516546
254986080
411902519
306448901
173536389
499122177
320982690
525677993
956196224
984286393
838584496
167513901
652945923
453915490
118461194
474054269
205749194
671230590
963629262
415033512
748683265
808822631
694645681
790334324
7...

result:

ok 57062 numbers

Test #36:

score: 0
Accepted
time: 99ms
memory: 118396kb

input:

40211 33279
2 47591 76705
8 19395 55380 59615 60904 65094 71224 78596 80036
5 512 9328 27590 31074 46996
10 33184 33563 34050 37740 45595 48505 49242 58487 64344 66126
10 16429 17094 20989 45988 47018 47277 50771 71499 78971 79828
8 12222 12425 13733 33408 58299 73087 77976 79336
2 50239 56822
7 744...

output:

341887307
376398411
702250192
955678420
594294777
292567501
607921281
730702711
802472277
84971699
147446120
435175100
585308749
260860182
302443565
652240886
257574454
342770735
748683265
595025614
533039552
189485594
148251195
748683265
899608858
328474034
453037009
687663041
401314970
182590638
7...

result:

ok 33279 numbers

Test #37:

score: 0
Accepted
time: 87ms
memory: 128612kb

input:

40211 9078
4 3478 14951 45751 55495
6 15182 38686 38821 50339 62027 72910
21 1247 2016 6383 8487 11391 14636 17795 21974 22068 25664 25792 43761 46294 46902 47841 51383 67438 70789 73260 77819 79953
35 5891 7959 9850 11276 12760 14330 14775 15242 15393 19093 20851 21040 23586 26147 26829 27084 29143...

output:

577329830
753006895
151777145
835483662
258548499
55415783
445767377
69422755
692113594
903230784
611606728
985897714
890377379
168443707
814252345
446883659
586784085
623191208
804159877
173755470
109716804
170251856
20051754
821513794
658913347
932933299
299156457
925971945
717944793
464004317
855...

result:

ok 9078 numbers

Test #38:

score: 0
Accepted
time: 91ms
memory: 117376kb

input:

40211 1641
23 1828 4791 5173 15025 16298 23113 28263 32438 36578 37786 37902 44461 46189 52703 56028 58416 60957 63349 65685 68710 68950 71410 73160
94 605 1353 1483 1843 1999 2818 3089 3823 4275 4314 5349 5840 8373 11089 11964 12194 12235 13140 13396 16415 16798 17142 18713 20144 21080 21114 21532 ...

output:

51225244
627364892
963081936
844376698
611200490
554201106
504605322
841547844
631754462
39467946
639573902
642284583
33356843
156045716
414282305
678495039
968956748
608034004
774299046
567976548
653463382
821316633
211919471
155073027
73734216
403646846
638995246
489360206
883821795
44491016
68248...

result:

ok 1641 numbers

Test #39:

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

input:

40211 338
314 112 120 666 1000 1051 1144 1330 1339 2308 2795 3079 3278 3313 4741 4922 5048 5506 5883 5915 6506 6554 6869 7002 7062 7155 7315 7439 7495 7604 7662 8491 8496 8513 8556 8809 9104 9326 9744 9794 10338 10343 10573 10745 10922 11660 11888 12034 12550 12616 13142 13635 13805 13832 13846 1441...

output:

909102945
550048933
628553834
509511038
52295539
716451730
651106321
843912336
797007977
959284150
831979337
784616593
923010935
354114487
853118794
535736075
660687157
719658207
793270585
848165173
17775155
782042320
607190672
987262603
390356724
727454030
452380949
6408365
415939672
169728638
9084...

result:

ok 338 numbers

Test #40:

score: 0
Accepted
time: 83ms
memory: 118076kb

input:

40211 31
6169 22 35 58 59 62 70 76 93 116 133 141 176 189 204 239 249 253 274 280 285 306 315 335 341 355 357 364 416 422 427 459 464 475 480 485 487 491 518 519 533 572 575 581 595 614 620 632 638 650 660 684 699 720 723 724 739 743 749 760 797 802 806 807 817 836 838 853 881 897 915 917 930 944 94...

output:

1036046
831863415
894838905
4630371
361432695
42354724
413624923
529199965
369623750
266747881
64167554
369752582
252823200
318643752
341768866
629370394
537844080
130193613
132143234
36484111
791751265
845708003
870008445
151601689
363937426
916891587
937508455
944692649
615294192
435383662
499122177

result:

ok 31 numbers

Test #41:

score: 0
Accepted
time: 87ms
memory: 119896kb

input:

40211 22
39282 2 10 11 14 19 20 22 24 25 26 27 30 36 39 42 43 45 46 48 50 53 54 58 59 60 63 67 68 69 70 71 72 76 77 83 85 89 90 92 94 96 97 101 106 110 112 117 122 124 127 128 129 130 131 133 134 136 137 138 143 144 146 147 148 149 150 151 153 154 155 160 161 162 165 167 169 170 171 172 175 176 179 ...

output:

478670876
967954284
303712175
439254500
796544729
573615028
364894511
657322566
621419904
405561863
872417004
119271243
512442014
132855204
716940153
817507908
174706273
773712504
244177656
807371261
496442717
540505489

result:

ok 22 numbers

Test #42:

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

input:

97708 100000
2 88069 93693
2 24671 96212
2 21203 81148
2 70751 151047
2 47680 88488
2 63454 145578
2 92202 151392
2 48183 176030
2 9366 112306
2 86876 89322
2 48051 169014
2 103864 135648
2 190098 194567
2 29292 139808
2 66965 110008
2 19276 175620
2 31932 110886
2 20494 35870
2 100687 118390
2 8737...

output:

499122177
499122177
499122177
76630794
499122177
154745141
442853957
397991002
371605821
499122177
275626371
729653872
784117009
527139403
402121200
36264089
929166763
499122177
231190266
499122177
239756571
499122177
499122177
410394036
254977129
499122177
499122177
499122177
862995551
323643602
49...

result:

ok 100000 numbers

Test #43:

score: 0
Accepted
time: 201ms
memory: 238840kb

input:

97708 80027
2 158159 184036
2 132195 136447
3 9606 51981 123422
2 95863 108389
3 70134 162446 181160
2 88761 188745
2 39574 136561
2 138529 143168
2 22332 104573
2 8287 127136
3 75712 99740 120939
2 52072 58680
2 26479 160131
3 49556 79761 93840
3 72968 116216 175605
2 79161 170231
3 28367 76181 146...

output:

960060331
115868692
382154984
703165567
136998804
292681287
889469338
299724196
225548214
619233573
364606113
499122177
630241800
748683265
249952407
380303471
171228427
124802838
224779195
405397700
567379541
627336185
499122177
858761904
568936540
594738715
499122177
500343946
499122177
96477336
4...

result:

ok 80027 numbers

Test #44:

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

input:

97708 57098
3 53820 179692 191120
5 67746 80566 133552 142939 161404
4 74938 85935 140147 165840
5 17634 53826 59799 64186 156961
4 34683 36657 59694 82418
5 37792 68703 82234 89387 121831
4 122489 130225 143263 169711
3 99434 104182 116414
3 62619 84211 163255
4 43498 96705 110818 121917
4 12658 60...

output:

519920455
558874498
350573609
997826945
873463809
760698230
919485115
77951064
656565996
990575828
902311584
499122177
286773459
609410834
499122177
499122177
505169747
874032336
275466859
499122177
297227483
388390197
250221294
183013697
275577182
643903625
556275303
683203597
800465086
168779889
1...

result:

ok 57098 numbers

Test #45:

score: 0
Accepted
time: 228ms
memory: 240408kb

input:

97708 33348
6 8507 10029 29200 95597 107354 166076
2 111950 173530
7 51194 65960 68122 69672 101711 150904 186855
5 2852 48680 157507 163924 167888
4 15684 42308 59250 62869
10 46017 51044 52319 84520 151704 163693 166319 170193 172608 175093
2 44391 118767
2 60818 100936
7 6594 32932 44841 68708 70...

output:

407356192
97859851
661593495
188614468
873463809
530556800
152080790
844491394
199454390
427747431
172671157
781617452
325006617
665229916
948393817
185252302
86372365
35579346
78141977
342346364
116139693
70542222
314309392
896393363
337957569
282536175
677131016
231896472
574872775
731539690
15597...

result:

ok 33348 numbers

Test #46:

score: 0
Accepted
time: 218ms
memory: 240008kb

input:

97708 9129
2 132548 150554
4 32407 39091 56176 83952
27 4519 6309 19617 40948 64004 67529 74510 77125 81645 86091 92995 95125 97947 98033 111083 111477 117824 121571 124131 133502 143917 145338 147077 161841 172159 180381 186843
2 58230 174244
21 20303 23352 25401 37881 42737 56562 74547 76664 85209...

output:

367813225
873463809
298488149
697833479
569335789
368414215
302279488
488732966
272802742
729629117
389812209
620039997
435075253
192109715
561732711
670047903
914117024
186245527
17173023
823551686
286388214
306647001
866478866
894111165
538740712
475995527
776798133
120048612
862079427
576127426
6...

result:

ok 9129 numbers

Test #47:

score: 0
Accepted
time: 201ms
memory: 240304kb

input:

97708 1694
210 184 423 1125 1279 1525 1686 2131 2674 3229 3534 3881 6096 9069 9108 11790 12970 14445 15790 15860 16048 16758 16958 18050 20304 21685 22003 23314 23863 25767 25933 26931 30555 30610 32867 35470 35985 40191 40522 40800 42919 44133 45430 46403 48212 48555 48803 51991 53962 54475 54742 5...

output:

752663287
201023064
669069412
193607465
555039547
178003999
889822735
527786001
966346242
811069985
632746179
345387016
272266366
529054249
669256432
194471525
118182414
275992445
291489509
622417893
622256951
931113666
22157204
166677410
777053115
388437084
712908109
54663584
659725069
452851406
93...

result:

ok 1694 numbers

Test #48:

score: 0
Accepted
time: 226ms
memory: 240656kb

input:

97708 329
315 51 713 804 989 1154 2271 2638 2977 5536 5807 5873 6108 6474 6817 8339 8563 10221 10268 10485 10761 11271 11945 13030 13038 13877 13928 13934 14523 15367 15399 15912 18196 19140 19467 20560 22140 22391 23149 23875 24007 27214 28345 28616 29235 29743 29787 29805 29845 30023 30076 30130 3...

output:

826627229
310678943
143697311
146407897
253295313
493805795
280930399
269810892
344693529
384089239
871337013
458556404
186705236
670405469
342597908
965565021
676375929
953219393
292293188
422381327
540139346
125223160
633090261
890763298
500496268
599016597
574778705
229127890
974806784
420564346
...

result:

ok 329 numbers

Test #49:

score: 0
Accepted
time: 202ms
memory: 239492kb

input:

97708 41
9332 63 89 104 130 178 212 219 220 233 252 343 356 362 363 393 407 437 446 483 528 537 544 548 566 589 594 596 597 631 644 694 699 704 728 759 765 813 861 863 888 1000 1024 1079 1080 1083 1086 1089 1113 1115 1116 1121 1122 1131 1139 1197 1228 1230 1238 1327 1339 1357 1361 1373 1401 1403 142...

output:

84982392
294806670
950992952
38980770
262708146
706895230
2459215
514541406
555793538
715535129
596993502
841927187
279686801
113916663
817616002
26162431
841623794
682415979
342095125
239731850
228227981
438568623
832161974
933656561
901373102
215324301
557132998
603600805
405204195
305261672
86248...

result:

ok 41 numbers

Test #50:

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

input:

97708 10
17088 5 50 54 79 85 93 104 113 115 124 132 137 139 149 154 159 187 195 197 201 223 248 251 266 289 325 345 346 354 356 369 390 392 394 397 402 404 415 419 459 461 470 484 528 538 558 561 599 612 624 625 641 652 656 668 685 688 697 711 735 736 760 777 784 811 816 821 837 839 842 856 888 914 ...

output:

21111525
363327815
777454095
47313089
551957667
958928282
356391017
7722145
147767611
690674160

result:

ok 10 numbers

Test #51:

score: 0
Accepted
time: 220ms
memory: 240072kb

input:

97708 12
94932 1 2 3 6 9 10 16 17 19 21 23 24 27 30 32 35 36 37 40 41 43 47 48 49 50 54 55 58 61 65 66 70 75 76 77 78 81 84 87 89 92 96 97 99 101 104 105 108 113 114 116 119 123 125 126 127 130 133 134 136 137 139 140 142 143 144 147 150 154 157 158 159 160 161 162 163 165 171 173 174 175 177 181 18...

output:

108079605
198561844
209849845
915461630
524154985
91980678
485482416
103616798
846747078
497271263
664641410
82360953

result:

ok 12 numbers

Test #52:

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

input:

100000 100000
2 29228 55567
2 72565 131240
2 3034 50885
2 98869 190122
2 23106 101723
2 40487 100032
2 7652 8930
2 151873 157161
2 189151 191479
2 73609 90306
2 57234 137828
2 51530 88463
2 128733 149404
2 37125 155143
2 26538 184887
2 35597 144639
2 28131 186998
2 6635 101570
2 54534 55284
2 47470 ...

output:

499122177
48471493
499122177
677556152
424495578
470364141
499122177
993592189
167328542
499122177
394788742
499122177
730331985
640279117
373183263
558125583
267271798
58289205
499122177
499122177
103152381
988141101
238030699
143781528
217644702
277759466
499122177
499122177
11428575
108255937
499...

result:

ok 100000 numbers

Test #53:

score: 0
Accepted
time: 235ms
memory: 241268kb

input:

100000 80034
2 91291 137939
3 37677 48680 51779
2 159741 194989
3 110263 181808 197820
3 53848 67632 193853
2 92278 100698
3 57493 60802 101683
2 41351 193956
2 25650 54942
2 17109 145294
2 89295 194112
3 50624 115659 172316
3 10981 88781 141746
2 157413 194394
2 11985 27438
2 33174 186029
3 19713 8...

output:

514173216
748683265
593812298
99677312
351766830
549836432
588468841
559237509
499122177
437067417
637440004
448802963
63351697
691552774
499122177
229943922
228866964
499122177
499122177
414432258
61970110
466493883
499122177
426043197
458862378
606683014
748683265
447542792
446567332
298861527
113...

result:

ok 80034 numbers

Test #54:

score: 0
Accepted
time: 232ms
memory: 241048kb

input:

100000 57065
3 31814 132609 139732
2 149310 169875
5 6905 48310 140975 187058 197066
5 35621 47922 59606 131482 152435
5 3648 100742 105852 155240 158949
4 70489 113767 126586 165239
3 45286 94719 186476
2 92683 163400
4 29058 136279 144753 191459
5 97471 107779 118400 127268 156491
4 10941 92183 12...

output:

113347476
967789215
44723078
778034692
338975918
514987191
712578624
285995897
854846327
627167791
323530456
873463809
795186711
672595023
748683265
905716385
351373843
391060827
395362176
963736916
163468323
462266701
191441015
443681673
95251433
873463809
389697770
604467184
297599768
475024265
66...

result:

ok 57065 numbers

Test #55:

score: 0
Accepted
time: 222ms
memory: 240876kb

input:

100000 33265
8 7857 91632 107628 124249 126391 129551 131655 180388
8 15919 28371 112144 139496 179976 189835 196041 197292
2 72539 98163
10 26801 36576 46107 97762 116993 135500 145126 162353 166539 174881
8 7796 14080 45331 71103 78107 101046 124404 144796
4 5885 73705 118259 197100
7 17753 34990 ...

output:

304377356
126106778
499122177
830955227
119664251
598032527
942918923
120250773
748683265
827121215
461728686
269066273
851747846
651098874
541525260
142076613
980160799
349639945
892815811
640889720
499122177
236053634
947708373
747396430
501673208
892140962
128205527
261639859
68397050
878695962
5...

result:

ok 33265 numbers

Test #56:

score: 0
Accepted
time: 232ms
memory: 241816kb

input:

100000 9123
33 1949 2573 4808 7879 25502 36558 41865 42100 48194 79665 83343 85827 89543 89674 98352 106228 108403 115089 128266 131190 137216 137336 137758 139346 145392 168911 170984 173485 183349 196253 196578 199032 199416
24 7660 8419 9268 11417 19999 28152 30634 35813 46702 69006 92662 101357 ...

output:

8036996
412496751
819691976
255968244
362645102
633544193
499122177
658544619
756373295
836865870
193944996
488034788
904374611
940826757
856176052
673807124
138738954
242807754
344104474
379281490
922345910
442459837
53037081
48700879
203476899
385261655
778551927
249253893
350278477
16891307
59260...

result:

ok 9123 numbers

Test #57:

score: 0
Accepted
time: 201ms
memory: 242164kb

input:

100000 1682
15 9737 14538 23088 27548 30785 69160 91143 94089 109590 111453 119867 124542 140972 164681 194827
142 423 1639 2296 4573 7881 11953 14526 14905 17071 18112 19649 20717 21190 24072 25290 30963 31242 31413 31504 31794 34281 36369 39562 42153 43454 46127 46401 49631 49750 50018 51464 53433...

output:

404432872
200427783
559886419
611004793
82845858
812585797
176084492
979018438
565731838
202917778
676811088
97009725
578599018
266529891
987041802
463908526
751370079
667015422
987255592
604978534
840052571
307427590
236732280
272652028
392462458
802216481
50662312
897850361
970487493
197805099
328...

result:

ok 1682 numbers

Test #58:

score: 0
Accepted
time: 239ms
memory: 241720kb

input:

100000 330
795 420 1485 1665 1768 1920 2719 2746 3154 3438 3872 4084 4477 4544 4699 5000 5371 5454 5634 5668 5812 6191 6276 6329 6684 7129 7207 7565 7647 7650 7813 7820 8171 8209 8363 8783 8886 8999 9341 9345 9351 9596 9633 10559 10625 11002 11358 11483 11813 11821 12006 12465 12817 13348 13356 1337...

output:

829401702
77291120
585505198
296373014
279881227
351078880
590277059
297728842
910686778
297402750
712743110
489270684
370352468
972142116
581599036
512214067
728284170
689334055
502845201
286008421
406919145
117677592
107323355
974558192
79362490
765924265
360173588
387085923
424022572
16820553
898...

result:

ok 330 numbers

Test #59:

score: 0
Accepted
time: 208ms
memory: 242588kb

input:

100000 34
11741 67 71 76 99 106 108 149 155 173 187 196 218 259 260 273 274 280 281 295 296 323 330 343 354 379 403 441 444 477 482 483 487 508 514 523 542 575 579 589 599 600 625 628 642 675 682 685 694 719 743 754 784 787 813 886 918 928 947 950 953 969 987 991 993 994 1013 1040 1059 1081 1096 109...

output:

211233690
869662802
469698400
386348969
276139610
719583573
139977588
745751123
610604954
443325156
476350691
209730042
336386742
45460388
562690296
763340284
288131221
246639531
614650873
476804029
666357445
596799536
800196949
241147107
758343227
72844737
404896503
128701286
604358652
307234044
15...

result:

ok 34 numbers

Test #60:

score: 0
Accepted
time: 234ms
memory: 242852kb

input:

100000 14
49898 5 7 12 13 16 17 24 25 28 30 34 42 51 52 60 61 63 64 65 72 77 85 86 88 89 93 94 102 103 109 113 120 123 124 125 130 131 133 140 142 148 150 155 157 160 161 171 172 177 180 188 189 191 193 194 202 203 204 206 212 215 216 225 226 236 238 239 242 244 248 251 253 256 257 260 270 271 275 2...

output:

340999175
721130433
577213460
648462041
465348219
301946739
608358091
186829406
687223458
89430701
341073979
50498726
20529624
793785276

result:

ok 14 numbers

Test #61:

score: 0
Accepted
time: 226ms
memory: 241528kb

input:

100000 17
72526 4 6 9 16 17 19 20 22 24 25 33 35 38 40 41 43 45 48 49 50 52 54 56 57 58 59 61 62 63 68 71 72 74 76 77 81 82 86 87 88 93 96 98 99 103 116 118 121 124 125 128 130 136 138 139 146 147 148 149 152 159 161 162 164 165 170 171 174 176 179 182 185 186 188 189 190 196 197 201 210 211 214 215...

output:

331285972
372310292
326140021
906143479
42641445
4612007
369950564
12991424
232217368
829558457
903169295
623469548
683610930
867339096
321474711
628581969
183318550

result:

ok 17 numbers

Test #62:

score: 0
Accepted
time: 200ms
memory: 241348kb

input:

100000 2
100000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

output:

714368571
714368571

result:

ok 2 number(s): "714368571 714368571"

Test #63:

score: 0
Accepted
time: 211ms
memory: 240908kb

input:

100000 630
436 1122 1883 3081 3123 3238 3997 4005 4245 4654 4684 6532 6860 7178 7321 7625 7825 7828 8320 8701 8745 9636 10402 11544 11898 12066 12665 12751 13364 13876 14047 14798 14954 15336 16124 16170 16843 17565 17568 17664 17842 17948 18590 18769 18877 18939 19104 19169 19624 19796 20264 20297 ...

output:

683897108
556176061
333924022
939675264
203809806
781788978
693726866
887246202
643951793
580924535
382478863
469945039
986705315
132831003
259437609
288405641
326792022
60750633
795227169
570187469
529160463
548986939
22225853
671068560
475508558
481173915
992446466
385044880
528006533
575925919
17...

result:

ok 630 numbers

Test #64:

score: 0
Accepted
time: 220ms
memory: 241564kb

input:

100000 446
446 283 730 765 1016 2388 2626 2700 3135 3698 5720 7392 7987 8107 8140 8242 9953 11188 11765 13753 13827 14141 14230 15278 15360 15603 16301 16309 16375 17477 18159 18581 19030 19139 19261 19588 19795 20079 20298 20639 20939 21105 21279 22458 22870 22976 22981 23258 23588 23621 23854 2387...

output:

463800890
313093876
684855887
71053911
759066640
165953542
407320842
765303571
186572820
497211868
686254181
707075903
529544803
105092
162785221
837669428
460179705
279588656
719466718
562553816
64379647
779960254
603718782
158444057
244161274
690115950
243020841
58606523
765187694
100191512
854037...

result:

ok 446 numbers

Test #65:

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

input:

100000 630
449 100344 100560 100587 100719 100855 101076 101126 101215 101313 101666 101684 101800 102135 102739 102780 102848 102907 102986 103184 103505 103841 103980 104151 104189 104848 105036 105090 105479 106175 106601 106721 106914 107701 108352 108465 108566 108659 108852 108988 109072 10918...

output:

587379009
82318746
944436535
287133792
759455435
339062527
270942142
541970102
385950002
737429325
922112660
243099512
786602391
132330484
938079108
196062137
872449271
658329896
671091152
612063522
152061541
585263909
606786950
493937786
525300793
929654852
770986736
994145468
744233080
838059146
2...

result:

ok 630 numbers

Test #66:

score: 0
Accepted
time: 227ms
memory: 241748kb

input:

100000 446
234 100090 100149 100540 101381 101689 102831 103090 103164 104821 104917 105973 107010 107172 107520 108138 110243 110507 110527 110639 111499 111763 112406 112599 112654 113407 113923 114028 114581 115124 116504 116849 117092 117398 119165 119440 119526 119749 119787 119887 119926 11997...

output:

210607019
320548775
753305785
525041321
23040368
494473674
43155017
499207099
789355876
362657357
730585840
301549872
907542944
564701435
235392659
113439273
358947962
641868217
576567990
489726403
181289607
189822505
620852091
257321633
765581947
664578630
797892186
108502165
856208945
70832986
261...

result:

ok 446 numbers

Test #67:

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

input:

100000 2
100000 1 5 7 11 15 16 17 18 19 24 25 26 28 33 36 38 40 42 47 48 49 50 51 52 53 54 55 57 61 65 66 69 71 76 78 82 84 86 87 89 91 94 95 96 98 99 102 103 104 107 108 114 116 117 121 123 128 130 133 137 138 139 140 141 142 143 145 146 147 148 149 151 153 158 159 162 165 166 169 171 174 175 176 1...

output:

51542160
103084320

result:

ok 2 number(s): "51542160 103084320"

Test #68:

score: 0
Accepted
time: 230ms
memory: 241912kb

input:

100000 50001
2 72739 95607
2 181457 199496
2 915 29272
2 4236 84319
2 16775 56899
2 19315 67365
2 62431 187868
2 10873 93777
2 17316 195108
2 54869 119752
2 139464 179565
2 29718 198454
2 103641 126448
2 65205 185911
2 19231 124159
2 81087 146622
2 15506 108641
2 90990 124114
2 39640 186125
2 76046 ...

output:

499122177
245676502
499122177
499122177
499122177
499122177
531718163
499122177
308621445
233333853
560133194
929076690
464957483
892595790
746974015
291708021
836753743
508302415
639501396
469511780
864716222
980429546
494363133
691877860
728637495
785401019
139200263
728985678
499122177
211508961
...

result:

ok 50001 numbers

Test #69:

score: 0
Accepted
time: 362ms
memory: 241540kb

input:

100000 630
326 100005 100012 100013 100043 100053 100061 100072 100101 100104 100110 100112 100124 100167 100187 100189 100190 100193 100195 100205 100228 100254 100256 100257 100266 100268 100285 100303 100329 100359 100361 100363 100367 100441 100445 100452 100461 100469 100477 100482 100488 10049...

output:

618068497
919246949
368055674
320067454
331502439
614528150
514952900
842551111
159242253
51951267
683326724
789070163
964070293
66608963
431198478
158163482
170082505
206886152
164492717
402032340
965001713
896118775
245675093
483477051
145311787
861240583
550079508
444912348
685067317
300554969
23...

result:

ok 630 numbers