QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#340937#984. Happinessucup-team1209#AC ✓4438ms20860kbC++203.3kb2024-02-29 14:17:172024-02-29 14:17:19

Judging History

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

  • [2024-02-29 14:17:19]
  • 评测
  • 测评结果:AC
  • 用时:4438ms
  • 内存:20860kb
  • [2024-02-29 14:17:17]
  • 提交

answer

#include<bits/stdc++.h>
using std::cin;
using std::cout;
using db = double;
using ll = long long;
using u64 = unsigned long long;
const int mod = 998244353;
const int N = 1 << 19;
int pow(int a, int b, int ans = 1) {
	for(;b;b >>= 1, a = (u64) a * a % mod) if(b & 1) {
		ans = (u64) ans * a % mod;
	}
	return ans;
}
int wn[N], rev[N];
int lim, invlim;
void init(int len) {
	lim = 2 << std::__lg(len - 1);
	invlim = mod - (mod - 1) / lim;
	for(static int i = 1;i < lim;i += i) {
		wn[i] = 1;
		const int w = pow(3, mod / i / 2);
		for(int j = 1;j < i;++j) {
			wn[i + j] = (u64) wn[i + j - 1] * w % mod;
		}
	}
	for(int i = 1;i < lim;++i) {
		rev[i] = rev[i >> 1] >> 1 | (i % 2u * lim / 2);
	}
}

void DFT(int * a) {
	static u64 t[N];
	for(int i = 0;i < lim;++i) t[i]=  a[rev[i]];
	for(int i = 1;i < lim;i += i) {
		for(int j = 0;j < lim;j += i + i) {
			for(int k = 0;k < i;++k) {
				const u64 x = t[i + j + k] * wn[i + k] % mod;
				t[i + j + k] = t[k + j] + mod - x, t[k + j] += x;
			}
		}
	}
	for(int i = 0;i < lim;++i) a[i]=  t[i] % mod;
}
void IDFT(int * a ){
	DFT(a), std::reverse( a + 1, a + lim);
	for(int i = 0;i < lim;++i) a[i] = (u64) a[i] * invlim % mod;
}
int n, q;
int v[N], vv[N];

int x[N], b[N];
int preb[N];
int prev[N];

int A;
int B;

int S;

void sub(int & x, int y) {
	x -= y, x += x >> 31 & mod;
}
void add(int & x, int y) {
	x += y;
	if(x >= mod) x -= mod;
}
void build() {
	memset(b, 0, lim << 2);
	for(int i = 0;i < n;++i) {
		int need = A + x[i];
		b[(n * 4u - need) % n] += 1;
	}
	DFT(b);
	for(int i = 0;i < lim;++i) {
		b[i] = (u64) b[i] * vv[i] % mod;
	}
	IDFT(b);
	for(int i = n;i < n + n;++i) {
		add(b[i - n], b[i]);
		b[i] = 0;
	}
	for(int i = n;i < n + n;++i) {
		b[i] = b[i - n];
	}
	for(int i = 0;i < n + n;++i) {
		preb[i] = b[i];
	}
	for(int i = n + n - 1;i >= 0;--i) {
		add(preb[i], preb[i + 1]);
	}

}
int main() {
#ifdef zqj
	freopen("$.in", "r", stdin);
#endif
	std::ios::sync_with_stdio(false), cin.tie(0);

	cin >> n >> q;
	if(n % 2) {
		for(int i = 0;i <= q;++i) {
			puts("0");
		}
		return 0;
	}
	if(n % 4 == 2) {
		A = (n + 2) / 4;
		B = n / 2;
	} else {
		A = n / 4 + 1;
		B = n / 2 - 1;
	}
	for(int i = 0;i < n;++i) {
		cin >> v[i];
		vv[i] = v[i];
	}
	for(int i = 0;i < n;++i) {
		x[i] = i;
	}
	for(int i = 0;i < n * 2;++i) prev[i] = v[i % n];
	for(int i = n * 2 - 1;i >= 0;--i) add(prev[i], prev[i + 1]);
	init(n + n);
	DFT(vv);
	build();
	std::vector<int> ins, del;
	auto calc = [&]() {
		int move = (n - S) % n;
		int ans = preb[move] - preb[move + B];
		ans = (ans + mod) % mod;
		for(int x : ins) {
			int p = A - S + x;
			if(p < 0) p += n;
			if(p >= n) p -= n;
			add(ans, prev[p]);
			sub(ans, prev[p + B]);
		}
		for(int x : del) {
			int p = A - S + x;
			if(p < 0) p += n;
			if(p >= n) p -= n;
			sub(ans, prev[p]);
			add(ans, prev[p + B]);
		}
		return ans;
	};
	cout << calc() << '\n';
	const int B = 1000;
	for(int i = 0;i < q;++i) {
		int op, q, k;
		cin >> op;
		if(op == 1) {
			cin >> k;
			S = (S - k + n) % n;
		} else {
			cin >> q >> k;
			q = (q + S) % n;
			del.push_back(x[q]);
			x[q] = (x[q] - k + n) % n;
			ins.push_back(x[q]);
		}
		if(del.size() >= B) {
			build();
			del = ins = {};
		}
		cout << calc() << '\n';
	}
	

}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3876kb

input:

6 3
1 2 4 8 16 32
2 1 4
1 5
2 4 2

output:

189
168
210
252

result:

ok 4 number(s): "189 168 210 252"

Test #2:

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

input:

291 297
690864 66051 879316 361679 613199 616 951868 674311 509731 765530 914257 643036 149469 265479 385645 752029 360309 48606 545052 618893 70334 418974 673141 754792 299130 398298 719505 772883 898465 697947 205006 95537 798625 696927 962164 140276 704224 146457 73196 100864 371302 485115 950286...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 298 numbers

Test #3:

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

input:

295 295
552765 106849 337718 329913 575893 164618 897059 355495 919669 763217 652119 598602 375615 550063 362338 802065 404469 248822 475588 743741 236314 886569 896687 949368 736118 824720 290749 488403 70211 243198 671570 94895 649763 349076 476023 628472 417057 350655 342355 826342 147267 922532 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 296 numbers

Test #4:

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

input:

296 292
197804 718425 56634 403100 978753 617316 121593 944167 884895 801844 613148 623615 822920 116431 372795 179915 790109 774901 961724 265875 718476 818274 593528 45207 199271 233902 751601 242247 11775 88033 912182 946726 998679 382162 791540 990712 283984 188914 36965 121390 716244 896446 236...

output:

712685820
712685820
712685820
712685820
712685820
717318054
716983869
717589993
710256209
706016424
707153891
701271087
724635284
724417845
719673709
704630730
712569827
708723732
703114919
697699010
704624679
702212682
721430608
700393096
702244685
703289901
721707329
727986071
691394429
721590721
...

result:

ok 293 numbers

Test #5:

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

input:

294 291
503603 1295 528959 874005 16784 356063 407396 710552 364457 854105 81255 277227 337622 924237 786842 937442 324199 347508 759112 474964 795014 41077 989187 995407 337551 790107 640382 634943 493635 300299 850365 259818 324049 363697 636774 727713 680955 275129 475482 233431 36465 715331 5493...

output:

243211064
243211064
243211064
241304462
246487749
244149180
242849351
243729937
242981876
240473501
241289144
239589122
242722412
243440252
240166011
244646621
239804677
244016243
246138296
246359596
244043738
245210022
244984337
243219614
242919477
249046022
239542717
237287596
243926344
240551676
...

result:

ok 292 numbers

Test #6:

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

input:

290 295
634846 383682 38882 644797 112952 89231 370780 569445 45432 884805 995805 720763 851778 285921 170815 784518 955568 544322 4855 150378 799076 255752 760947 318089 774545 687763 86803 83267 675405 875841 577183 235032 795668 213958 200001 669641 703427 879349 974729 166286 705661 99867 768052...

output:

661217387
662720782
664133599
667055435
657358941
651597268
657027416
667545462
669288496
673748254
666644307
663744430
656531174
653988862
653971836
654448278
656922978
658083597
652087448
651320779
643062959
643110255
648191618
649160297
649025433
645422902
646683457
641868826
648343369
675058634
...

result:

ok 296 numbers

Test #7:

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

input:

296 299
576338 488913 542853 19862 318192 797562 789873 768709 471762 942794 340062 306502 602999 92722 873773 803924 629926 746752 630109 673400 285755 264681 739304 753534 725126 412467 42700 679018 472050 415678 782065 998053 524534 670135 4509 634161 251237 317905 241361 809368 103497 453789 551...

output:

546525987
548661825
550242498
552059588
549748106
551415281
548838169
548828143
543338259
542314650
541329112
536944262
537750574
538633714
535613227
531320381
530327955
529830727
528071082
526052276
529587817
522829507
522380369
523175114
523338147
518718284
520653264
522763096
515176718
517589791
...

result:

ok 300 numbers

Test #8:

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

input:

290 298
151200 308307 900299 878140 223630 304554 269381 668041 60602 812740 766872 602070 222004 180951 834538 488511 129084 736264 166993 606493 145061 189042 712088 609067 158544 950103 957775 440199 679482 15931 180678 699695 531055 226971 631904 290559 144208 135884 30014 642873 465203 694973 5...

output:

893351222
895575721
893047662
895517900
892249060
893309964
895692688
896052372
894004390
895205404
895535502
892972727
892584945
892506117
895929901
891956833
890661249
892744200
889295979
888679699
889008094
884827111
885668384
890467434
892747934
896147236
896667140
894980669
897000912
894129337
...

result:

ok 299 numbers

Test #9:

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

input:

296 298
425281 421489 461896 866489 536895 67961 72400 379755 625272 468574 822933 179873 855224 810597 102758 305742 869092 739997 402170 717754 585255 482055 277570 992051 688845 259461 789058 288320 987711 626161 319504 212094 26601 394072 696898 660687 844239 656280 223631 20777 389037 904384 18...

output:

263487777
262600013
272182443
276559065
271341904
273605796
279384006
278653078
270815654
272650989
280729803
280282905
282779644
292309794
293991227
295060256
285788655
284328919
249355690
247359878
247687195
286643787
276079031
273067081
273406277
265470938
285860917
275266405
277391440
271310660
...

result:

ok 299 numbers

Test #10:

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

input:

294 294
499344 613463 108432 253232 87241 321758 353501 431564 457147 677802 499260 641105 802301 552240 182592 56884 285407 964992 188688 827027 946475 163913 961690 913830 118193 701604 846246 83865 927069 813398 823361 458494 646628 649547 904552 40435 714332 588582 976811 566510 694806 404161 98...

output:

442254931
441444783
439780351
436137202
438701542
439049415
449382366
445009322
450669286
446603717
441837184
444178344
440481413
437966802
432528147
431514855
433047909
432988889
433088279
436782416
435752755
442506853
447059790
444930641
439523512
439676301
436460229
437876893
432278319
432212815
...

result:

ok 295 numbers

Test #11:

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

input:

300 293
176941 206958 800930 287691 315331 101605 771110 653884 595905 521021 566074 833285 185348 797081 27113 55232 155239 478879 786683 459848 375013 791591 836072 775374 443569 61956 397251 185997 531359 366812 430405 553512 968729 835358 19742 233562 487112 737151 589133 757106 75237 115225 636...

output:

345276637
343152604
342183550
341560095
347692889
343075451
347239383
348493607
339334204
338845322
339313723
336219886
337421843
347492342
348516254
349909347
351225867
341952444
346099043
346499456
351257635
351617801
360737036
357881558
363889484
358359972
361662538
349669834
355645347
354566130
...

result:

ok 294 numbers

Test #12:

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

input:

2 296
491672 128320
1 1
2 1 1
1 1
1 1
2 0 1
2 1 1
2 1 1
2 0 1
2 0 1
2 1 1
2 1 1
1 1
1 1
1 1
2 0 1
2 1 1
1 1
1 1
1 1
2 0 1
1 1
1 1
2 1 1
1 1
2 0 1
2 1 1
1 1
2 0 1
2 0 1
1 1
1 1
2 1 1
1 1
1 1
2 1 1
1 1
1 1
1 1
1 1
2 1 1
2 0 1
1 1
1 1
2 0 1
1 1
2 0 1
2 1 1
1 1
1 1
1 1
1 1
2 1 1
2 0 1
2 0 1
2 1 1
1 1
2 ...

output:

619992
619992
256640
983344
256640
619992
983344
619992
256640
619992
983344
619992
619992
619992
619992
256640
619992
619992
619992
619992
983344
256640
983344
619992
619992
256640
619992
619992
983344
619992
619992
619992
256640
983344
256640
619992
619992
619992
619992
619992
256640
619992
619992...

result:

ok 297 numbers

Test #13:

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

input:

293 300
539792 607476 714416 326858 535343 411400 267409 988390 60911 668742 931493 956011 528193 855993 367235 549239 105615 502706 17167 921309 386464 12831 256984 427485 773206 611080 733757 831462 607870 761942 105161 967256 831191 605522 582360 290954 899262 523044 135650 157737 543171 274867 8...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 301 numbers

Test #14:

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

input:

2 299
549355 144658
1 1
1 1
1 1
1 1
2 1 1
1 1
1 1
2 0 1
1 1
1 1
1 1
2 1 1
2 1 1
2 0 1
1 1
1 1
2 0 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
2 0 1
2 0 1
1 1
1 1
2 1 1
1 1
1 1
2 1 1
1 1
2 1 1
2 0 1
2 0 1
1 1
1 1
2 0 1
1 1
2 1 1
2 0 1
2 0 1
2 0 1
1 1
1 1
1 1
2 1 1
2 1 1
1 1
2 1 1
2 1 1
1 1
1 1
2 1 1
1 1
1 1
2 1 1
...

output:

694013
694013
694013
694013
694013
289316
1098710
289316
694013
694013
694013
694013
1098710
694013
289316
1098710
289316
694013
694013
694013
694013
694013
694013
694013
694013
289316
694013
694013
694013
1098710
289316
1098710
694013
694013
1098710
694013
1098710
289316
1098710
694013
694013
28931...

result:

ok 300 numbers

Test #15:

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

input:

3 291
421433 380426 269925
2 1 1
1 2
2 1 2
1 2
1 2
1 2
1 1
1 2
1 1
2 1 1
1 2
2 0 1
1 1
1 1
2 0 1
1 2
2 0 2
1 1
1 2
2 1 2
1 2
2 1 2
1 1
2 1 1
1 2
2 1 2
1 1
2 2 1
2 0 1
2 1 1
1 1
1 1
1 2
1 1
2 2 1
2 0 2
2 0 1
2 1 1
2 0 1
1 1
2 1 1
1 2
2 2 2
1 2
1 2
2 1 2
1 1
1 1
2 1 1
2 1 2
1 2
1 2
1 1
2 0 2
2 0 1
2 1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 292 numbers

Test #16:

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

input:

296 291
443573 87168 70509 121283 207008 676413 207870 305388 900593 900207 519086 496912 380909 31375 715795 842545 521180 672912 572143 543823 89521 364773 84775 109262 398052 196913 221486 784609 246527 110072 346720 905264 512272 284114 130199 87990 265837 658150 767614 444366 976325 119461 9876...

output:

408209264
410904069
407783354
407889591
404612719
408222638
408329118
410871095
410553419
410760225
404771330
396583805
410618199
424918180
430830969
433996583
438298445
407981513
405650757
405250781
405059413
406399976
438502154
440402308
399005857
403800858
382250486
423905275
424855948
424045449
...

result:

ok 292 numbers

Test #17:

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

input:

296 294
370806 875916 769238 796332 473968 630635 495988 355719 713496 85351 342821 862256 230081 387167 194363 70269 71058 920136 389543 210820 751418 999083 642329 974428 947727 772601 903349 371476 899951 812237 313814 756252 13190 45438 469838 727029 507273 575501 974326 373310 528619 858477 393...

output:

812154399
812282415
809217594
808896578
812561564
818669736
815154285
807184486
805414722
804180713
808631046
813666601
816241667
815870552
811034805
806778615
815605046
814661152
809366102
809214057
810373552
819886895
809682752
808318793
820071624
813580972
817504349
802780302
804915093
803745051
...

result:

ok 295 numbers

Test #18:

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

input:

292 299
92412 17245 409628 838582 726437 952708 506916 645415 328927 311600 879757 420387 195018 893486 165957 732299 693905 181057 778000 752226 460435 313517 943925 606583 931834 328800 429492 12530 938488 518134 530991 496173 266331 332698 573204 962515 23859 255186 860029 145825 674827 300651 74...

output:

214241547
214241547
214241547
216447784
215312916
220741565
221170566
224715089
226089093
227618210
207443226
208257890
208520470
202466760
201776778
200810181
200562627
208649535
198694636
196398731
200310391
195816489
230483659
199905114
229959911
206785713
202908538
199472988
201962340
202506093
...

result:

ok 300 numbers

Test #19:

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

input:

297 297
325934 894115 731417 648065 379449 469115 617857 109051 609229 384652 492 606074 200806 222598 335262 406449 499634 46389 84951 675088 719359 55388 595776 512672 60540 355 826059 982722 604242 638645 102271 143837 285468 819481 366965 274788 324890 321226 977593 508018 250966 732914 520084 8...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 298 numbers

Test #20:

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

input:

296 295
277227 455802 718916 39599 204339 255491 354412 298847 623780 992147 665348 552924 970956 206045 408262 128221 485846 183409 294463 637497 897503 938678 82310 157570 28634 270780 770260 302173 419875 792079 876185 366927 281771 497867 448061 517198 186664 474844 530682 619723 523645 512167 3...

output:

600776484
603331648
601497101
593239343
607729169
605342728
608478604
601084966
605682457
603187126
603002394
599427868
595889868
592986963
594115767
592126242
599184727
604843450
608416009
608494340
607074355
615658165
601353198
606693561
609964330
595717399
594436850
590115637
589702153
601156084
...

result:

ok 296 numbers

Test #21:

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

input:

292 300
748325 396502 654709 495733 428819 818215 304823 650974 34112 720308 43918 836218 398242 742046 168010 597633 218325 710548 942648 624992 9462 902612 94385 545900 792350 52276 882165 67078 76777 275865 997570 728270 202447 489738 480119 965508 371541 5749 663387 207121 670280 157468 388200 5...

output:

924770955
923310883
925495106
927201764
923830741
924279796
924247712
924908794
924309891
924247712
924903324
925221375
927002822
925299597
924903324
924220043
921595063
924908794
925389024
928085590
927970900
922330725
925062460
924214290
922843082
924983638
921680673
925685545
923169795
923551448
...

result:

ok 301 numbers

Test #22:

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

input:

4999 5000
615912 882074 934067 327162 59021 352357 67254 207841 208595 429172 448781 601247 896943 560595 836640 390651 744738 78717 503551 106977 175201 545393 859962 740149 820609 729713 320319 467517 510550 633637 377636 504995 964236 32314 955208 578205 964014 492864 73612 830746 397921 617693 6...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 5001 numbers

Test #23:

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

input:

4990 4993
278417 57614 668216 652861 320183 509539 295777 603032 454196 260568 752864 280596 873924 427787 204545 359260 534407 318875 176613 169071 594799 574779 194348 301661 545573 482422 235733 323062 270634 32922 583619 122913 140975 89625 151508 824644 719486 706609 995155 202598 374305 36105 ...

output:

181331137
166151335
175747282
164378978
184170435
162563546
191762651
174846907
184199436
170792617
162271009
165797782
169543762
193299702
198076706
183403974
192860660
196626738
201697436
162700358
195036785
186959307
183354128
180781959
172271911
183768449
147634697
176660830
180122695
185314460
...

result:

ok 4994 numbers

Test #24:

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

input:

4998 4991
58395 895856 254639 592416 983056 629881 866720 373097 367155 495923 476228 159916 830413 152066 770457 274439 313919 77568 772164 691004 753623 589218 16575 104911 422736 385684 221484 747559 63474 219304 228429 546663 280972 438162 638310 954240 564003 528037 339930 873855 167251 464783 ...

output:

773504435
773504435
773504435
740864153
738159743
820369393
737815144
716695593
813315658
806116266
794715874
743206692
739467762
807423372
754822296
824353433
794143882
824449830
803364289
726457313
736010229
724444570
724813186
812123681
724637680
737560639
777973063
770853201
811067877
724162880
...

result:

ok 4992 numbers

Test #25:

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

input:

4992 4993
794303 498171 272553 399699 159188 690772 532846 43040 527166 700076 732783 60552 507362 228006 472405 535773 563977 559255 212982 928187 820759 54861 29638 905730 458294 507831 491501 459079 801335 802964 174930 214721 454521 468550 642495 822377 803541 170203 10293 367713 57674 704983 49...

output:

485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
485188781
479349850
472156462
502815352
487590116
484635415
...

result:

ok 4994 numbers

Test #26:

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

input:

4992 4998
199061 598714 940177 105350 624522 512648 516355 789958 829641 887169 408961 687871 814533 89300 659553 862858 977762 437805 920555 718267 61828 130170 543070 348778 990267 77902 972936 458479 145029 225933 831548 369254 223546 573912 199739 79251 318183 553738 29065 430499 555108 745743 2...

output:

729129081
724983869
754919175
753921284
754257419
736917297
714614621
746483788
749229178
749545532
727061196
734401659
723008016
743248371
748418589
729203353
735564405
758034670
760381529
754093707
733119646
715826066
737381572
734601602
739859475
715558530
693058434
693632066
685840881
684867696
...

result:

ok 4999 numbers

Test #27:

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

input:

4998 4995
366453 317940 946968 681182 320429 900204 669018 479271 927319 706071 431358 950576 948035 76657 566940 197985 474277 91101 506335 756891 557745 967967 848504 926266 237593 29036 440889 300704 341141 416780 189739 966861 766611 464645 709179 270891 238236 666354 438629 461302 866068 261452...

output:

494697413
492135496
476389254
464884866
460333074
453262789
426322979
451853087
464637318
476963706
465536833
447589298
441562777
450447366
452528356
457334030
467426891
469538141
467898371
472808265
493962755
515887658
516135979
462397427
487781016
497664338
508361162
521742562
522877268
519894293
...

result:

ok 4996 numbers

Test #28:

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

input:

4993 4996
782287 330607 562733 61466 488515 971979 327446 851982 132857 30467 137698 637357 4863 98371 701847 672635 26644 179681 863332 350722 479832 371940 812551 934238 190258 377317 817983 688929 853416 654878 70492 435770 935835 203454 872905 352754 547651 894173 436511 609868 613425 357593 160...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 4997 numbers

Test #29:

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

input:

4999 4994
124665 463833 123858 519561 152418 371390 609198 275590 818826 902279 530017 655147 546658 802051 67505 953952 747397 356057 615014 96343 994334 276339 895690 104881 862875 551756 322437 774879 26037 499773 14852 434885 339529 963319 879748 446602 759313 825346 701576 491459 178820 676023 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 4995 numbers

Test #30:

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

input:

4997 4999
393676 296762 73072 879741 737050 492733 802278 108454 522484 679622 292407 103081 533301 797391 252129 623329 721517 651449 981038 751446 841990 382730 52127 881212 864828 193606 912854 671228 761549 781874 304732 426182 332427 302439 88610 838273 380309 537456 284317 110050 732919 283687...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 5000 numbers

Test #31:

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

input:

4992 4995
383827 617888 845563 784830 274100 915473 872296 604278 976896 860142 887023 235822 854877 171829 849308 404685 305674 675328 387524 985467 498792 228815 96576 43987 472546 128818 599631 591943 390600 724807 156203 132845 792335 231687 778228 907132 274800 315470 65212 330302 547983 730040...

output:

161979955
166859395
157247458
139579803
120094806
98536551
105648872
90500328
95236399
93302399
85904789
70549448
78285155
85520083
83874927
76435430
99248082
83769290
99970782
103926243
102640832
88490172
87698824
103801895
113890023
114702248
104752403
87104672
102123977
101962886
96686435
1084026...

result:

ok 4996 numbers

Test #32:

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

input:

2 4994
925560 565704
2 0 1
1 1
1 1
2 1 1
2 1 1
1 1
2 0 1
2 0 1
2 0 1
2 0 1
2 1 1
2 0 1
2 0 1
2 1 1
2 0 1
1 1
1 1
2 0 1
2 1 1
2 0 1
1 1
2 1 1
2 1 1
1 1
1 1
2 0 1
1 1
2 1 1
1 1
2 0 1
1 1
2 0 1
2 1 1
1 1
2 1 1
2 1 1
1 1
1 1
1 1
1 1
1 1
2 0 1
1 1
1 1
1 1
2 0 1
2 0 1
2 1 1
1 1
2 1 1
1 1
1 1
2 1 1
2 1 1
2...

output:

1491264
1851120
1131408
1851120
1491264
1851120
1131408
1491264
1131408
1491264
1131408
1491264
1851120
1491264
1131408
1491264
1491264
1491264
1131408
1491264
1851120
1131408
1491264
1131408
1851120
1131408
1491264
1491264
1851120
1131408
1491264
1491264
1131408
1491264
1491264
1131408
1491264
1491...

result:

ok 4995 numbers

Test #33:

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

input:

4996 4995
109093 723008 166553 373855 771959 163956 213756 258345 609690 703074 98934 509230 957500 590690 155113 996515 55252 359110 914434 961868 14398 668824 846362 131034 487447 987737 617868 670320 235469 204903 670610 84846 392734 82629 970636 582204 697924 249939 695556 756832 432504 826218 7...

output:

750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
750601699
...

result:

ok 4996 numbers

Test #34:

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

input:

2 4991
829161 782364
1 1
2 1 1
1 1
1 1
2 0 1
1 1
1 1
2 1 1
1 1
2 0 1
2 0 1
2 1 1
1 1
1 1
1 1
2 1 1
1 1
1 1
1 1
2 0 1
2 1 1
1 1
1 1
1 1
1 1
2 0 1
1 1
2 0 1
2 1 1
1 1
1 1
2 0 1
1 1
1 1
1 1
1 1
1 1
2 1 1
2 1 1
1 1
1 1
2 1 1
1 1
2 1 1
2 1 1
1 1
1 1
2 0 1
2 0 1
2 0 1
1 1
2 1 1
1 1
1 1
2 0 1
1 1
1 1
1 1
1...

output:

1611525
1611525
1564728
1658322
1564728
1611525
1611525
1611525
1658322
1564728
1611525
1564728
1611525
1611525
1611525
1611525
1564728
1658322
1564728
1658322
1611525
1564728
1658322
1564728
1658322
1564728
1611525
1611525
1564728
1611525
1611525
1611525
1658322
1564728
1658322
1564728
1658322
1564...

result:

ok 4992 numbers

Test #35:

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

input:

4 5000
980919 707511 702795 761042
1 1
2 0 3
2 2 1
2 2 2
1 1
1 1
1 2
2 0 3
1 3
1 3
2 2 3
2 2 1
2 2 1
2 0 2
1 1
1 3
1 3
1 2
1 2
2 0 3
2 3 3
2 0 3
2 3 2
1 3
1 3
2 3 3
2 3 2
2 2 3
1 1
1 3
2 1 3
2 1 3
1 3
2 1 3
2 2 2
1 2
2 0 3
1 3
2 1 2
2 1 1
1 2
1 1
2 3 1
1 1
1 3
1 3
1 3
1 3
1 1
1 1
2 2 2
2 3 3
2 1 3
1...

output:

3152267
3152267
3210514
2990637
2937106
3367428
2937106
2937106
3156983
3425675
2932390
2990637
2932390
2937106
2883575
3089304
2883575
3645552
3089304
3645552
3703799
3430391
3650268
3703799
2985921
2815896
2874143
2820612
2878859
3147551
2878859
2874143
2932390
3094020
3152267
2874143
3430391
3156...

result:

ok 5001 numbers

Test #36:

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

input:

4998 4992
736833 249616 152582 577870 588118 70703 947505 494081 488036 643850 799011 552031 256322 464009 246793 389032 577047 591574 734747 931062 640735 114128 146046 357415 480124 65731 397328 697813 550289 638064 166827 244701 340278 788687 155745 436958 193418 169731 543 984307 713909 402763 2...

output:

846251477
846251477
846251477
837449529
836986624
820249561
875256861
817353607
820266224
813518451
838572024
826640410
799432255
786351771
775890781
813055027
804040717
850710688
843371825
767414098
907021311
898279914
887131447
876322421
863362667
861410462
861266009
921864054
917935930
889604068
...

result:

ok 4993 numbers

Test #37:

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

input:

4998 4992
707378 315594 689086 378006 280027 890049 636417 757236 804163 410446 72212 823606 746477 657074 713009 923457 539829 591157 162135 274677 245839 747227 204166 590377 90789 270057 275136 689815 558429 404314 544033 207319 195423 92103 401690 375547 783862 397360 62093 288237 601285 243144 ...

output:

456343529
484806753
502899084
399569256
455626926
480720910
437022487
441849102
513764170
532411579
522253991
524056661
621348550
594907952
312020343
356159474
331402012
330384792
343374618
344347059
446508449
426054832
406256776
393167219
612468541
374834475
376923928
421048723
459419490
603822967
...

result:

ok 4993 numbers

Test #38:

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

input:

4991 4991
932532 964662 38364 149546 532119 404464 642457 307946 771822 153668 109869 883704 335702 125505 581904 533639 335267 945928 937002 57981 606149 527903 389101 678952 205256 503888 69934 439654 908143 143521 730082 718156 937873 247783 431826 485436 899054 594423 554727 267479 414151 869282...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 4992 numbers

Test #39:

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

input:

4998 4995
961463 735303 705993 804560 843961 861890 478279 96729 299136 285529 549575 805583 659746 431336 276019 723851 730387 193005 392367 972261 66451 423603 891754 958850 671666 695413 747178 707183 928474 284448 586204 508857 566862 773617 992068 387766 915510 179888 56440 815489 331324 460136...

output:

160411828
161158541
172630612
160610678
163076577
161867018
170910565
153396763
142125957
153534638
152199243
172222424
173105776
178696088
161733061
184782038
183427073
181454226
119414756
145147836
153751256
161917085
151156375
171550862
151988383
152667618
152421827
138319348
150848895
163001090
...

result:

ok 4996 numbers

Test #40:

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

input:

4994 4997
802287 58323 47291 61777 964677 256712 500956 205262 243421 210877 460484 188764 701950 267377 906702 539007 668598 779906 371702 87064 818708 84551 999887 565824 426522 788965 186274 221013 610072 351236 441432 525678 202009 270167 908166 265317 650146 260069 415136 674345 408372 953178 7...

output:

424294817
447064164
430725433
414239060
422306469
420448048
416424354
401466105
409243382
417830409
434151776
409724208
395542187
458041452
436360225
430459719
415085429
437481260
433246855
372009962
376275794
395380646
389347761
420111050
460235862
455376948
437531182
433623590
462398411
461019380
...

result:

ok 4998 numbers

Test #41:

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

input:

4998 4995
995730 647785 312033 510242 827646 370768 256931 521938 509255 813115 67769 490562 659948 659805 976364 969691 607250 944014 676053 743971 811360 69988 256441 464598 569350 794156 770561 723624 129232 39571 855760 32059 742510 381328 551161 581810 496130 776480 643158 336714 246402 558055 ...

output:

119016940
119016940
119016940
119016940
119016940
119016940
119016940
116588190
118295635
110521782
121731304
118352943
112251525
113260649
105387772
126431595
107389832
116227148
115591164
103358246
116846284
110682498
124496120
105646474
112158937
117395003
115980092
111567426
102531707
129972503
...

result:

ok 4996 numbers

Test #42:

score: 0
Accepted
time: 1124ms
memory: 20860kb

input:

199994 199999
657562 638132 347152 341527 324959 214708 286401 609091 519761 680477 543294 409447 738271 429420 411533 897206 371552 974680 176833 106513 449003 894564 297298 273093 916283 760737 857432 178296 452023 724071 574904 229004 307401 249402 233955 450106 462587 767796 523284 154730 625633...

output:

200285340
200285340
200285340
200285340
200285340
200285340
200285340
392520280
7790003
276595739
326649772
977802258
60274020
230280315
343905300
42322064
413070038
78661642
851250980
143743826
51476427
526807592
777353936
211312
723952080
560929035
556316012
585247551
996403813
522922854
543732490...

result:

ok 200000 numbers

Test #43:

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

input:

199993 200000
805209 955258 936409 532192 714619 767165 743551 614196 642043 54961 811494 111896 717274 381349 186124 338410 455029 141475 162435 654402 356454 421817 365223 775505 408267 467746 459145 138737 247678 658979 533755 101201 497005 934076 848519 788833 426682 98953 330098 396099 791350 5...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 200001 numbers

Test #44:

score: 0
Accepted
time: 1095ms
memory: 20856kb

input:

199994 199997
544850 376854 940146 264472 997054 14806 7310 991773 525335 723574 333913 378681 285740 568747 38095 558620 21252 739330 514450 930644 241782 851757 80779 308856 289451 381599 684746 521183 38123 506110 106519 384646 340120 80142 603048 747300 546048 729993 435123 200783 417906 511943 ...

output:

917272033
917272033
917272033
917272033
917272033
917272033
917272033
917272033
917272033
917272033
917272033
917272033
917272033
917272033
917272033
917272033
917272033
917272033
5189554
95986809
128502606
41563230
135735911
97170221
937092581
829803317
823386697
931555692
907355394
921632667
94103...

result:

ok 199998 numbers

Test #45:

score: 0
Accepted
time: 1136ms
memory: 20664kb

input:

199990 199996
278900 483223 180705 491911 126476 560158 126290 332700 703063 648319 693984 997362 343000 875584 149901 898633 737221 412027 546878 398488 36681 954608 229809 265385 76093 261127 524538 509227 933443 591718 793876 968375 691647 664273 134740 28761 45460 142005 878706 74765 910640 1309...

output:

680942164
680942164
680942164
680942164
680942164
680942164
680942164
680942164
681542283
645317714
653953762
721507943
652335283
706032620
681378974
733460672
687830684
673509110
677909490
632609091
641617756
703669240
711437170
705800183
715846804
802014406
666210803
632019753
679807378
541974934
...

result:

ok 199997 numbers

Test #46:

score: 0
Accepted
time: 4208ms
memory: 20608kb

input:

199994 199996
103145 125337 96364 343666 803503 480701 460091 625061 134877 542815 939155 380464 436752 787542 474458 787888 344527 318725 348425 893576 304458 231517 183419 160491 287012 96850 423096 104670 683330 333448 569590 160716 626887 960826 724666 582101 466482 54652 19889 238274 936150 835...

output:

213676451
240034340
343701672
338554908
280052979
227839561
213283052
163491287
141248783
219601951
235160626
779283954
805894065
933570077
958792352
934563311
450558444
500120587
528156218
473350876
417795100
311478262
159356188
168631663
146178164
214234312
204065675
215094720
200816346
231722017
...

result:

ok 199997 numbers

Test #47:

score: 0
Accepted
time: 4091ms
memory: 20536kb

input:

199996 199999
982944 744983 559061 450156 748508 64579 410037 41078 483703 754025 538151 274005 982921 325419 369370 626010 755269 462828 620970 962882 671114 974524 546608 675367 806827 946220 393414 900796 732255 883866 999289 995171 976937 685561 938383 220861 762821 241010 164931 904920 526781 2...

output:

482204069
544615867
458890135
494283724
536092792
534106202
542624961
611644932
685868615
630523738
278554005
223830517
344793537
382164219
362121387
377820474
409316575
410178960
456249268
568339720
658422665
635286636
745505131
762237361
838262186
738824371
639740750
511415902
580201346
604049812
...

result:

ok 200000 numbers

Test #48:

score: 0
Accepted
time: 4163ms
memory: 20496kb

input:

199992 199999
244434 884804 682182 647786 427618 45556 415017 439552 358824 875338 515240 287919 790124 561574 169915 350663 3729 692666 301344 617774 596312 741374 667631 216685 620272 295030 54903 300419 593070 106894 874897 245177 470646 801704 458759 838837 471098 916469 229911 105606 817612 738...

output:

906536520
28204532
106306284
958060365
906368927
727539765
776844281
614814026
770085453
627132496
435736677
303674989
519021699
525909852
487762980
279490961
178821829
979395383
870701846
702359628
839379462
661318975
879705748
809151282
797765764
603264572
532326018
553649230
769779529
98377475
12...

result:

ok 200000 numbers

Test #49:

score: 0
Accepted
time: 4088ms
memory: 20548kb

input:

199998 199997
25590 413346 335568 96231 540037 805598 183753 633079 930906 20368 799996 952203 890369 633191 721319 402595 212437 899733 47162 36654 818792 163869 617154 157751 807944 298373 394125 999830 752807 75169 27460 999880 513624 317313 24238 410281 32883 598946 117347 642483 195627 8433 825...

output:

623483881
536410846
415965694
325276936
71320395
200657668
113200379
326870422
145501056
103710632
296056389
122118497
49662199
192764068
247881629
165112441
189404784
333247968
247384627
252709307
309461612
460276387
439847376
257858914
171649698
330591953
237576761
462690800
575597561
383896201
98...

result:

ok 199998 numbers

Test #50:

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

input:

199997 199995
822575 549682 669036 971837 263284 867844 487660 174515 534712 505051 460604 961522 527842 948609 315257 980347 717320 754913 200852 854511 690339 944402 165591 820612 493658 393685 372084 936529 160743 531148 737942 317650 502047 840045 858233 103241 80702 32520 404696 451041 271814 5...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 199996 numbers

Test #51:

score: 0
Accepted
time: 4438ms
memory: 20860kb

input:

199994 199995
710690 124299 939591 40028 923647 378922 832512 977928 694484 178181 616687 726945 114119 430142 750959 94100 174305 469245 605587 61467 296934 689677 187504 696413 616550 579756 141432 204001 885583 229305 446379 525140 64145 951170 839948 664164 34055 968039 715524 280129 479122 1246...

output:

43904724
80634433
104941753
56473321
30407163
42890967
41152140
83389849
79171345
56736099
112141742
55131261
56510275
50661574
996194563
6919652
940611855
48560386
56618573
81660292
991008376
976323490
926596795
912796502
924209972
928049299
890003192
865410784
877375034
924442073
934855475
9338164...

result:

ok 199996 numbers

Test #52:

score: 0
Accepted
time: 444ms
memory: 3652kb

input:

2 199994
243510 668683
2 1 1
1 1
2 1 1
1 1
2 0 1
1 1
1 1
1 1
1 1
2 0 1
1 1
1 1
1 1
2 0 1
2 0 1
2 0 1
1 1
1 1
1 1
2 1 1
1 1
2 0 1
1 1
1 1
2 0 1
1 1
2 0 1
2 0 1
1 1
2 1 1
2 0 1
2 0 1
2 0 1
1 1
2 1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
2 0 1
2 1 1
2 1 1
2 1 1
1 1
1 1
1 1
2 0 1
2 0 1
1 1
1 1
2 1 1
2 0 1
1 1
2 0...

output:

912193
1337366
487020
912193
912193
1337366
487020
1337366
487020
1337366
912193
912193
912193
912193
1337366
912193
1337366
487020
1337366
487020
912193
912193
1337366
487020
1337366
912193
912193
1337366
912193
912193
487020
912193
487020
912193
912193
1337366
487020
1337366
487020
1337366
487020
...

result:

ok 199995 numbers

Test #53:

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

input:

199998 199994
23521 756163 182437 677024 972635 197501 262840 324364 399207 233045 602084 92989 108820 623781 317386 168856 981398 5220 374211 727108 78530 263039 960548 249050 805650 916547 17785 452694 77598 76466 48810 658436 861079 675174 246460 613962 63428 484759 240316 105314 756436 477174 19...

output:

781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
781187887
...

result:

ok 199995 numbers

Test #54:

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

input:

2 199995
900557 396492
2 0 1
1 1
1 1
2 1 1
2 1 1
2 0 1
1 1
2 1 1
2 1 1
1 1
2 1 1
2 0 1
1 1
2 1 1
2 0 1
2 0 1
1 1
2 1 1
1 1
1 1
2 0 1
1 1
2 0 1
2 0 1
1 1
2 1 1
1 1
2 0 1
1 1
1 1
1 1
1 1
1 1
2 0 1
2 1 1
1 1
1 1
1 1
2 0 1
1 1
1 1
2 0 1
1 1
2 0 1
1 1
1 1
2 0 1
2 1 1
2 0 1
1 1
2 0 1
2 1 1
1 1
2 1 1
2 0 1...

output:

1297049
1801114
792984
1801114
1297049
1801114
1297049
1297049
792984
1297049
1297049
792984
1297049
1297049
1801114
1297049
1801114
792984
1297049
1297049
1297049
1801114
792984
1297049
792984
1801114
1297049
1297049
792984
1801114
792984
1801114
792984
1801114
1297049
792984
1801114
792984
1801114...

result:

ok 199996 numbers

Test #55:

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

input:

3 199994
554138 214913 311788
1 2
2 0 1
2 2 2
2 2 2
1 2
1 2
2 2 1
1 1
1 1
2 1 1
1 1
1 2
2 0 1
2 0 1
1 2
1 2
2 1 1
1 1
1 1
2 1 2
1 2
2 0 2
2 2 1
1 1
1 2
2 2 1
1 1
1 1
2 2 2
2 2 2
2 0 1
1 1
2 1 2
1 1
2 1 1
1 1
2 1 2
1 1
1 2
2 0 1
2 2 2
2 1 1
1 2
2 2 1
2 2 2
2 1 2
2 2 1
2 1 2
1 1
2 1 1
2 2 2
1 1
2 1 1
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 199995 numbers

Test #56:

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

input:

199993 199997
487125 397184 719244 270365 48664 759360 978072 82310 815169 796569 920576 848515 502109 189973 924939 545138 124271 421072 240019 716558 694865 534505 227571 612575 447452 977033 30791 339218 260417 558633 212573 479683 17146 23075 807354 341222 135526 966735 181105 638816 70544 37412...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 199998 numbers

Test #57:

score: 0
Accepted
time: 2699ms
memory: 20852kb

input:

199996 199997
310641 454088 242489 230610 219463 780136 341860 106255 604560 266358 427897 146695 526578 983621 667457 894667 39685 881524 830148 29559 771948 246692 623812 557806 787437 637195 403183 958383 501700 712379 703649 56569 743309 389300 534450 104181 199394 176801 424010 968935 544639 94...

output:

382428689
372906023
334902484
388163691
284117045
324058345
433057041
419551215
424283045
366351949
496605902
470619830
417464164
348462796
305739179
296407837
226853967
144503094
286271033
532503889
301418173
398722475
201743615
371848044
361486620
352385151
297147833
273587407
185805287
192361339
...

result:

ok 199998 numbers

Test #58:

score: 0
Accepted
time: 2683ms
memory: 20852kb

input:

199990 199991
760011 604639 456794 695678 726362 94635 372984 70577 819913 462987 5746 191506 905844 944183 857930 672062 682923 969540 957427 904953 911214 127541 25091 11072 350292 466695 439105 648038 421102 990075 722663 115779 629475 559299 482030 219564 726129 204868 986273 947410 293865 47713...

output:

457710916
536801517
392670900
591455722
370021323
577256446
509831783
373408885
499560370
459128274
345305662
415855757
463950117
482478135
372508946
396282577
260747631
365407065
315224711
150483509
144455287
191777226
496002598
783582687
829499652
16657688
26393787
410120945
489961954
2690233
6418...

result:

ok 199992 numbers

Test #59:

score: 0
Accepted
time: 2656ms
memory: 20700kb

input:

199998 199997
712283 4647 88429 671321 147483 126783 288955 602620 208655 616405 67991 631164 22004 929885 187385 78050 140741 216658 23029 502520 264051 941253 315923 164353 363728 898731 852116 368586 845851 754709 978738 416180 42824 108024 971471 141984 341015 320979 865077 323270 721284 453979 ...

output:

349833856
295939452
404611802
515025212
430277984
469042822
523253725
508095741
575151933
492893739
419883683
411127294
429249028
613236619
675774163
744611656
261883154
371261532
307485252
208032587
550620289
252145230
357993028
499986634
553624575
843667298
830242378
936531699
393803508
359238484
...

result:

ok 199998 numbers

Test #60:

score: 0
Accepted
time: 2701ms
memory: 20852kb

input:

199996 200000
955153 780144 139332 573640 738764 400222 976547 603359 358538 826014 557583 425321 751017 594494 829487 335509 752663 981785 389210 729465 710876 748275 801849 51502 615306 409839 912423 910428 318077 773746 487104 864890 298352 818260 383881 806222 786259 229701 807917 346541 984487 ...

output:

191434727
300505038
284349089
378874916
396992245
573134566
548584200
460329243
248488209
76591691
639388090
114367585
723712184
617999325
714232891
444487995
694306410
742502093
780609995
583207419
970074326
195271478
57326950
136074152
96384395
123810638
395007946
987171939
863037229
716434833
464...

result:

ok 200001 numbers

Test #61:

score: 0
Accepted
time: 1089ms
memory: 20612kb

input:

199992 199993
32618 602691 362208 112846 25216 465612 965940 759822 345519 74599 173691 323405 575557 595876 447245 82518 689618 470073 530851 367477 706400 856761 610708 354043 574893 279990 438303 946182 560085 574995 593485 379168 535166 594897 957884 633344 862774 646487 12446 773317 767960 1630...

output:

808494543
808494543
808494543
808494543
808494543
808494543
541030400
537164905
673920109
852316713
653549176
521232125
96810920
278794973
71082799
332135622
946564827
113445272
404711293
533328392
336991801
380308125
90545547
281954509
473996096
502945891
380221498
128723545
447919980
349097126
354...

result:

ok 199994 numbers