QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#369459#7791. 通道建设 Passage Constructionzhouhuanyi100 ✓1493ms8044kbC++143.0kb2024-03-28 10:39:032024-03-28 10:39:03

Judging History

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

  • [2024-03-28 10:39:03]
  • 评测
  • 测评结果:100
  • 用时:1493ms
  • 内存:8044kb
  • [2024-03-28 10:39:03]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<random>
#include"passageconstruction.h"
#define SN 10000
using namespace std;
mt19937 RAND(random_device{}());
const int inf=(int)(1e9);
int n,rt,smz,minn,minn2,dfn[SN+1],sz[SN+1],leng,ps[SN+1],depth[SN+1];
bool used[SN+1],vis[SN+1],vst[SN+1];
vector<int>E[SN+1];
vector<int>ES[SN+1];
vector<int>sp[SN+1];
vector<int>p[SN+1];
vector<int>tans;
vector<pair<int,int> >ans;
void add_edge(int x,int y)
{
	ES[x].push_back(y),ES[y].push_back(x);
	return;
}
void dfs(int x)
{
	for (int i=0;i<E[x].size();++i)
	{
		dfs(E[x][i]);
		if (ps[x]&&ps[E[x][i]]) ans.push_back(make_pair(ps[x],ps[E[x][i]])),ps[x]=0;
		else ps[x]^=ps[E[x][i]];
	}
	if (ps[x]) ans.push_back(make_pair(ps[x],x)),ps[x]=0;
	else ps[x]=x;
	return;
}
void dfs2(int x)
{
	vector<int>st;
	int res=vis[x];
	sz[x]=vis[x],shuffle(E[x].begin(),E[x].end(),RAND);
	for (int i=0;i<E[x].size();++i)
	{
		dfs2(E[x][i]),sz[x]+=sz[E[x][i]],st.push_back(E[x][i]);
		if (sz[x]>1&&(max(sz[x],smz-sz[x])<minn||(max(sz[x],smz-sz[x])==minn&&sz[x]<minn2))) rt=x,minn=max(sz[x],smz-sz[x]),minn2=sz[x],tans=st;
	}
	st.clear();
	for (int i=E[x].size()-1;i>=0;--i)
	{
		st.push_back(E[x][i]),res+=sz[E[x][i]];
		if (res>1&&(max(res,smz-res)<minn||(max(res,smz-res)==minn&&res<minn2))) rt=x,minn=max(res,smz-res),minn2=res,tans=st;
	}
	return;
}
void dfs3(int x)
{
	if (vis[x]) vst[x]=1;
	for (int i=0;i<E[x].size();++i) dfs3(E[x][i]);
	return;
}
void solve(vector<int>A,vector<int>B)
{
	if (B.empty()) return;
	if (A.size()==1)
	{
		for (int i=0;i<B.size();++i) E[A[0]].push_back(B[i]);
		return;
	}
	if (A.size()==2)
	{
		vector<int>v=QueryLCA(B,{A[0],A[1]},A[0]);
		for (int i=0;i<B.size();++i)
		{
			if (v[i]) E[A[0]].push_back(B[i]);
			else E[A[1]].push_back(B[i]);
		}
		return;
	}
	minn=minn2=inf,rt=0,tans.clear();
	for (int i=0;i<A.size();++i) vis[A[i]]=1;
	smz=A.size(),dfs2(1);
	vector<int>v1;
	vector<int>v2;
	vector<int>s1;
	vector<int>s2;
	for (int i=0;i<tans.size();++i) dfs3(tans[i]);
	for (int i=0;i<A.size();++i)
	{
		if (vst[A[i]]) v1.push_back(A[i]);
		else v2.push_back(A[i]);
	}
	for (int i=0;i<A.size();++i) vis[A[i]]=vst[A[i]]=0;
	vector<int>v=QueryLCA(B,v1,rt);
	for (int i=0;i<v.size();++i)
	{
		if (!v[i]) s1.push_back(B[i]);
		else s2.push_back(B[i]);
	}
	solve(v1,s1),solve(v2,s2);
	return;
}
std::vector<std::pair<int,int>>ConstructPassages(int N, const std::vector<std::pair<int,int>>&ES)
{
	n=N;
	int res=0;
	for (int i=1;i<=(n<<1);++i) depth[i]=GetDistance(1,i),res=max(res,depth[i]);
	for (int i=0;i<ES.size();++i)
	{
		if (depth[ES[i].first]+1==depth[ES[i].second]) E[ES[i].first].push_back(ES[i].second),used[ES[i].second]=1;
		if (depth[ES[i].second]+1==depth[ES[i].first]) E[ES[i].second].push_back(ES[i].first),used[ES[i].first]=1;
	}
	for (int i=1;i<=(n<<1);++i)
	{
		sp[depth[i]].push_back(i);
		if (!used[i]) p[depth[i]].push_back(i);
	}
	for (int i=1;i<=res;++i) solve(sp[i-1],p[i]);
	dfs(1);
	return ans;
}

詳細信息

Subtask #1:

score: 3
Accepted

Test #1:

score: 3
Accepted
time: 1ms
memory: 4964kb

input:

1
1872884041
100 100 10000 10000
1
2294931821 2294931820

output:

Succeeded
0 2 0 0
2 1

result:

ok Accepted with 0+2 operations,sum of size(s)=0+0

Test #2:

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

input:

1
1977600624
100 100 10000 10000
5
621522394 621522399
2231003352 2231003338
464307841 464307837
1851407771 1851407768
2780336863 2780336849
314073909 314073902
1173467454 1173467430
4215033871 4215033843
2620057116 2620057098

output:

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

result:

ok Accepted with 4+10 operations,sum of size(s)=9+8

Test #3:

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

input:

1
1314992723
100 100 10000 10000
2
1174248192 1174248188
4206147071 4206147069
2894997654 2894997645

output:

Succeeded
0 4 0 0
4 2
3 1

result:

ok Accepted with 0+4 operations,sum of size(s)=0+0

Test #4:

score: 3
Accepted
time: 1ms
memory: 4892kb

input:

1
1466488642
100 100 10000 10000
3
1959342134 1959342129
3976386946 3976386946
1293201451 1293201449
4016912388 4016912383
46728190 46728181

output:

Succeeded
1 6 1 2
3 2
4 6
5 1

result:

ok Accepted with 1+6 operations,sum of size(s)=1+2

Test #5:

score: 3
Accepted
time: 1ms
memory: 5980kb

input:

1
1733551538
100 100 10000 10000
4
4255320958 4255320951
1233889267 1233889267
2022156010 2022156014
1746602236 1746602223
1796304111 1796304099
154520793 154520786
799267407 799267389

output:

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

result:

ok Accepted with 2+8 operations,sum of size(s)=3+4

Test #6:

score: 3
Accepted
time: 1ms
memory: 5080kb

input:

1
1103590331
100 100 10000 10000
4
3735090189 3735090176
179620503 179620501
1550955883 1550955882
3533004575 3533004552
2159969243 2159969227
2549716219 2549716202
1755562372 1755562356

output:

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

result:

ok Accepted with 1+8 operations,sum of size(s)=2+2

Test #7:

score: 3
Accepted
time: 1ms
memory: 4840kb

input:

1
1007922703
100 100 10000 10000
5
3347355425 3347355424
924935451 924935434
3554593528 3554593525
2830078883 2830078872
3185621515 3185621508
32902500 32902483
1057526055 1057526035
3737430162 3737430144
106424402 106424399

output:

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

result:

ok Accepted with 4+10 operations,sum of size(s)=7+9

Test #8:

score: 3
Accepted
time: 1ms
memory: 5896kb

input:

1
1401446296
100 100 10000 10000
5
4125806477 4125806476
1224445301 1224445291
1474144594 1474144597
2898586557 2898586536
879608888 879608877
3110900945 3110900930
2490037068 2490037051
422424582 422424570
1017432306 1017432295

output:

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

result:

ok Accepted with 4+10 operations,sum of size(s)=8+8

Test #9:

score: 3
Accepted
time: 1ms
memory: 4912kb

input:

1
1756894897
100 100 10000 10000
5
2081532117 2081532115
4275738287 4275738273
632146529 632146534
2424607270 2424607263
2157363450 2157363443
2463928559 2463928550
3381117807 3381117785
4186361975 4186361960
3382018566 3382018532

output:

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

result:

ok Accepted with 3+10 operations,sum of size(s)=5+6

Test #10:

score: 3
Accepted
time: 1ms
memory: 4892kb

input:

1
1465320926
100 100 10000 10000
5
2695813796 2695813789
3049323317 3049323309
231883125 231883119
3073242409 3073242392
1388430756 1388430755
183732731 183732729
1423324287 1423324267
3470698806 3470698795
354321542 354321525

output:

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

result:

ok Accepted with 4+10 operations,sum of size(s)=7+8

Subtask #2:

score: 6
Accepted

Test #11:

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

input:

2
755640766
20000 10000 200000 200000
100
4287951944 4287951892
218593589 218593610
2907028702 2907028595
100123056 100122959
3149201405 3149201229
3454414687 3454414608
1901257489 1901257490
1532337798 1532337686
836222214 836222227
187381584 187381446
1847826999 1847827071
2868544732 2868544653
41...

output:

Succeeded
143 200 484 418
79 65
173 138
6 145
121 53
71 13
57 163
76 20
170 18
70 97
83 175
21 80
35 135
10 183
16 2
127 174
67 41
29 82
27 59
64 122
9 60
28 45
88 58
133 17
107 47
154 106
38 72
73 167
197 12
105 129
98 182
50 49
180 91
44 114
124 150
37 54
62 131
93 90
134 85
25 189
181 115
5 194
1...

result:

ok Accepted with 143+200 operations,sum of size(s)=484+418

Test #12:

score: 6
Accepted
time: 2ms
memory: 4944kb

input:

2
587237803
20000 10000 200000 200000
98
217447661 217447616
2463641363 2463641406
3373538248 3373538212
3950835015 3950834997
2221322822 2221322872
146298284 146298141
531452967 531453049
3941453926 3941454046
3084946195 3084946149
1270490559 1270490368
1019372524 1019372347
2754251578 2754251434
5...

output:

Succeeded
150 196 555 474
72 130
90 192
112 108
44 64
29 117
31 116
26 194
80 163
147 32
4 171
172 110
102 190
83 189
20 188
59 100
76 109
7 79
35 54
105 138
106 185
38 168
114 174
155 164
140 15
21 118
24 134
157 95
69 84
181 177
10 56
57 48
161 104
131 127
71 47
51 22
182 93
85 19
34 87
170 43
146...

result:

ok Accepted with 150+196 operations,sum of size(s)=555+474

Test #13:

score: 6
Accepted
time: 2ms
memory: 4936kb

input:

2
184226984
20000 10000 200000 200000
99
547000384 547000355
872110096 872110116
1289538184 1289538247
3616724666 3616724569
636341527 636341600
2563522202 2563522274
2177548205 2177548137
3089489449 3089489506
3156380759 3156380856
944465184 944465231
823584265 823584499
333051247 333051023
1754238...

output:

Succeeded
125 198 498 397
28 134
61 95
25 44
80 172
73 121
74 17
51 168
195 116
180 48
148 161
35 49
56 136
92 16
26 98
190 21
43 94
6 54
193 196
101 125
123 173
104 149
111 162
153 152
112 107
81 71
198 40
177 176
75 108
65 110
170 169
103 144
91 52
102 174
194 70
128 145
45 197
166 160
155 159
124...

result:

ok Accepted with 125+198 operations,sum of size(s)=498+397

Test #14:

score: 6
Accepted
time: 2ms
memory: 4972kb

input:

2
1727138930
20000 10000 200000 200000
99
3247483138 3247483162
4084597375 4084597429
2636905019 2636904971
946660642 946660700
902149328 902149350
2382255766 2382255865
839303047 839303137
1923325547 1923325538
653690681 653690724
4175318562 4175318731
3824454449 3824454478
2650316775 2650316587
58...

output:

Succeeded
131 198 473 408
93 168
141 174
150 46
40 85
197 64
7 69
37 81
45 25
191 76
184 72
32 80
59 5
181 94
48 86
144 121
42 166
65 188
23 38
61 110
147 67
128 127
154 170
106 63
43 13
24 84
52 107
54 91
186 100
14 62
159 28
152 16
2 179
20 169
131 185
171 95
114 172
176 83
143 192
73 78
129 26
11...

result:

ok Accepted with 131+198 operations,sum of size(s)=473+408

Test #15:

score: 6
Accepted
time: 2ms
memory: 5128kb

input:

2
1220143324
20000 10000 200000 200000
100
693596313 693596332
62576744 62576808
1955936424 1955936264
3872655610 3872655531
1013531683 1013531829
2985331208 2985331369
2406362516 2406362582
1657349556 1657349602
1003910904 1003910721
1096398841 1096398795
1778724026 1778723842
713692268 713692342
2...

output:

Succeeded
129 200 515 403
59 186
102 19
52 157
193 63
184 51
124 9
34 83
90 171
190 147
168 181
153 119
116 129
173 130
120 101
175 136
164 113
140 118
160 200
144 121
106 138
44 68
7 154
81 112
38 151
10 100
4 192
94 93
132 163
2 47
24 111
114 99
86 13
8 123
21 108
14 159
174 188
23 170
50 161
20 6...

result:

ok Accepted with 129+200 operations,sum of size(s)=515+403

Test #16:

score: 6
Accepted
time: 1ms
memory: 5920kb

input:

2
442130601
20000 10000 200000 200000
100
3144169521 3144169542
3602466736 3602466791
26223369 26223537
866636824 866636802
1192888944 1192888905
2768179340 2768179316
992350648 992350588
1606144049 1606144118
2825460299 2825460268
2783910130 2783910118
403964521 403964517
445570315 445570360
126026...

output:

Succeeded
140 200 496 429
94 105
126 43
146 111
13 166
134 160
76 152
118 109
131 36
140 91
117 130
147 52
132 149
156 17
45 82
200 11
144 71
46 24
40 55
139 4
28 30
143 141
50 72
191 33
106 129
112 9
70 44
61 169
119 51
14 75
151 15
12 89
179 110
174 120
124 184
182 150
167 195
199 159
198 107
145 ...

result:

ok Accepted with 140+200 operations,sum of size(s)=496+429

Test #17:

score: 6
Accepted
time: 2ms
memory: 4932kb

input:

2
949343282
20000 10000 200000 200000
97
1170242583 1170242801
4247921283 4247921322
1529679099 1529679065
1051858814 1051858774
3893889966 3893889994
3958531511 3958531352
2502650796 2502650862
813064156 813064047
1048780624 1048780414
3993902928 3993902731
803344004 803343802
3547336751 3547336794...

output:

Succeeded
151 194 526 451
3 178
123 58
44 91
62 49
159 82
48 125
153 184
25 57
84 191
162 150
121 158
143 156
19 137
130 69
120 157
114 22
66 5
95 166
2 110
133 70
165 118
160 193
132 136
9 141
96 46
174 155
100 45
102 163
111 172
164 187
88 4
81 56
109 36
17 127
182 28
63 75
85 179
29 117
97 115
18...

result:

ok Accepted with 151+194 operations,sum of size(s)=526+451

Test #18:

score: 6
Accepted
time: 2ms
memory: 5016kb

input:

2
734508634
20000 10000 200000 200000
98
213911368 213911499
2488548419 2488548499
516780967 516780705
3349442602 3349442765
857297035 857297029
1348690665 1348690579
1548954171 1548954133
3605026599 3605026727
182470368 182470292
1455323224 1455323364
2179991017 2179991001
3209649930 3209649949
145...

output:

Succeeded
141 196 496 420
130 44
49 24
195 124
96 82
86 163
126 42
34 107
85 32
43 120
122 189
59 188
69 105
37 114
98 73
74 68
52 40
87 176
78 55
79 116
47 41
106 48
162 94
70 71
164 177
28 121
25 84
61 18
160 138
103 129
7 148
102 135
60 117
30 147
76 111
141 142
97 17
20 136
146 10
19 11
166 132
...

result:

ok Accepted with 141+196 operations,sum of size(s)=496+420

Subtask #3:

score: 8
Accepted

Test #19:

score: 8
Accepted
time: 2ms
memory: 6188kb

input:

3
397960972
100000 4000 200000 200000
1000
3136131587 3136131078
3887641427 3887642253
280951546 280951198
124187343 124186744
3948118891 3948118785
2174920490 2174920140
3041102338 3041103477
489656932 489656480
3093689453 3093690199
3027233105 3027233261
967551350 967551424
215138938 215138436
251...

output:

Succeeded
493 2000 584 986
1740 1003
1560 1938
1246 1780
1573 1476
1826 1535
1031 1618
1661 1100
1527 1892
1660 1591
1354 1792
1594 1117
1097 1519
1919 1341
1846 1160
1853 1548
1863 1016
1445 1241
1481 1207
1371 1103
1646 1779
1329 1435
1162 1515
1342 1464
1756 1040
1383 1416
1724 1301
1061 1382
119...

result:

ok Accepted with 493+2000 operations,sum of size(s)=584+986

Test #20:

score: 8
Accepted
time: 2ms
memory: 5548kb

input:

3
755523510
100000 4000 200000 200000
999
837610461 837610217
209552123 209552158
2202987134 2202987346
3933843218 3933843131
2783546817 2783547323
415275024 415276142
13876082 13876176
448702939 448703028
1294393612 1294394136
3910397405 3910397094
3416630484 3416630700
3215888394 3215888948
124509...

output:

Succeeded
19 1998 20 38
198 827
112 795
703 616
809 427
584 743
818 611
649 805
42 438
1863 330
1562 251
922 322
1460 130
723 928
868 579
606 701
641 761
711 339
60 786
581 237
759 256
502 651
634 368
1878 340
491 118
1638 924
6 411
437 224
529 484
728 346
13 1690
49 468
103 745
485 897
149 86
913 8...

result:

ok Accepted with 19+1998 operations,sum of size(s)=20+38

Test #21:

score: 8
Accepted
time: 2ms
memory: 5400kb

input:

3
2042812129
100000 4000 200000 200000
998
3075748308 3075748844
1569673104 1569672823
3968525693 3968524672
2108387096 2108386924
3356390455 3356391094
3372812724 3372813320
3904961007 3904958854
4029621824 4029621345
4114486509 4114486281
1387138301 1387138067
124292409 124292880
3935517019 393551...

output:

Succeeded
558 1996 645 1116
1947 1484
1581 1267
1561 1375
1992 1379
1868 1655
1545 1678
1945 1279
1478 1065
1965 1553
1953 1368
1682 1835
1823 1176
1376 1063
1411 1073
1284 1816
1912 1362
1165 1483
1815 1640
1177 1703
1534 1230
1185 1338
1742 1322
1957 1936
1528 1594
1693 1210
1764 1852
1071 1979
10...

result:

ok Accepted with 558+1996 operations,sum of size(s)=645+1116

Test #22:

score: 8
Accepted
time: 2ms
memory: 5488kb

input:

3
1597029305
100000 4000 200000 200000
998
2980500284 2980500361
2247716226 2247714887
988714926 988714253
1734063960 1734064121
2359409219 2359409008
411968449 411968499
155449826 155451318
555582797 555582911
45071917 45071590
1460631113 1460629818
3059213925 3059213709
2094519932 2094519250
38721...

output:

Succeeded
205 1996 332 410
1767 345
262 528
580 38
1719 910
1612 226
1391 1016
1557 719
431 130
1537 941
1894 322
1572 1024
1713 1082
1539 697
846 1712
1100 1898
293 1595
1970 1512
119 685
748 1521
282 245
551 419
1301 1688
857 774
488 1177
1854 1558
1950 1579
1136 576
1600 219
760 1643
167 887
1717...

result:

ok Accepted with 205+1996 operations,sum of size(s)=332+410

Test #23:

score: 8
Accepted
time: 2ms
memory: 5468kb

input:

3
1564467111
100000 4000 200000 200000
1000
1236547222 1236547523
2135786902 2135787064
2523622442 2523622714
1532839693 1532838477
818219113 818220033
676117995 676118414
570037547 570036834
514220702 514220842
3399494183 3399495268
2654728241 2654729498
1495037081 1495037412
2062047312 2062048382
...

output:

Succeeded
264 2000 426 528
1367 1276
340 489
1496 602
783 21
1597 1715
994 1344
298 11
1693 1003
1737 643
709 268
552 237
1974 1391
1055 878
852 796
1345 371
209 1289
813 164
1840 1499
1960 1936
357 1188
137 1491
1488 873
279 537
724 151
1950 696
291 521
424 1920
1798 260
1166 711
1429 1638
53 280
1...

result:

ok Accepted with 264+2000 operations,sum of size(s)=426+528

Test #24:

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

input:

3
213138336
100000 4000 200000 200000
999
1130123143 1130122958
687694550 687694095
929485247 929484829
3680984473 3680983776
3074105335 3074104892
1342732123 1342731927
1364720805 1364720672
2077428724 2077428538
28510235 28511166
937776441 937776505
3414480885 3414480666
3148182306 3148181509
3485...

output:

Succeeded
162 1998 180 324
837 581
427 276
84 423
90 646
277 760
687 28
530 444
5 895
21 141
497 458
564 381
237 27
271 465
293 231
808 524
79 104
301 755
596 482
390 998
147 498
351 951
283 580
754 246
60 884
647 412
402 398
817 1356
258 1915
363 645
138 662
967 953
379 324
543 567
492 494
961 556
...

result:

ok Accepted with 162+1998 operations,sum of size(s)=180+324

Test #25:

score: 8
Accepted
time: 2ms
memory: 6280kb

input:

3
924980045
100000 4000 200000 200000
998
1666991999 1666991279
148686690 148685590
324531768 324531788
2043725358 2043725640
1133184972 1133184631
853139746 853139683
1770837584 1770837761
1481554510 1481554714
1372084869 1372084950
1756084441 1756085236
2107756067 2107756010
3377586774 3377586312
...

output:

Succeeded
9 1996 9 18
702 874
78 412
551 608
661 662
1099 473
745 406
1850 447
28 481
746 714
411 511
738 317
949 582
825 1464
890 664
670 407
358 674
445 423
534 808
327 1963
549 360
878 219
851 860
623 665
419 533
1161 141
356 59
244 575
986 232
726 384
127 1373
915 364
806 353
654 463
785 333
75 ...

result:

ok Accepted with 9+1996 operations,sum of size(s)=9+18

Test #26:

score: 8
Accepted
time: 2ms
memory: 5448kb

input:

3
774146483
100000 4000 200000 200000
999
3478842381 3478843345
606332045 606332562
2701123033 2701123563
3216754910 3216755036
1217043418 1217043429
1501603802 1501603474
1778234551 1778234769
1444790432 1444791022
2502984240 2502984288
856947428 856947122
1363006586 1363006323
1995567044 199556642...

output:

Succeeded
623 1998 952 1246
233 436
55 112
711 125
874 394
419 462
171 1792
184 552
271 927
608 160
470 764
397 611
165 705
819 172
978 174
153 633
937 57
128 482
971 508
940 894
1740 34
835 314
720 261
868 801
322 751
816 628
1659 717
325 961
590 51
203 760
623 339
1905 9
120 447
181 375
880 575
86...

result:

ok Accepted with 623+1998 operations,sum of size(s)=952+1246

Test #27:

score: 8
Accepted
time: 2ms
memory: 5528kb

input:

3
82266506
100000 4000 200000 200000
999
3056998601 3056998876
1887811910 1887812134
1616045105 1616045172
1784967209 1784967615
650919784 650918837
4290024152 4290024396
154133667 154133653
754913686 754913998
3014551042 3014550770
3332698384 3332698431
304657473 304657856
1466514044 1466515029
313...

output:

Succeeded
51 1998 55 102
96 486
1192 715
312 589
107 967
316 566
1406 1741
758 276
1743 283
449 762
466 189
72 30
428 376
596 26
868 235
430 208
152 638
612 341
1629 1289
1249 893
698 198
77 574
919 981
147 711
739 491
1910 773
229 1475
1960 584
274 1345
658 369
382 587
313 945
937 957
130 468
645 6...

result:

ok Accepted with 51+1998 operations,sum of size(s)=55+102

Test #28:

score: 8
Accepted
time: 2ms
memory: 5396kb

input:

3
1746021239
100000 4000 200000 200000
1000
3649747382 3649747015
3895797253 3895797184
4001365723 4001365122
564220364 564220085
362710516 362710456
2800243662 2800243024
2073687310 2073687797
145701776 145700951
492159209 492159366
3076148714 3076148148
1548738755 1548739322
3580263095 3580262700
...

output:

Succeeded
159 2000 176 318
707 272
433 532
900 503
486 769
264 508
252 1196
108 696
656 874
924 755
1299 878
307 439
717 17
531 89
392 247
233 987
314 719
79 47
217 660
784 151
713 669
187 615
783 73
941 633
356 908
880 789
722 378
971 26
326 241
352 69
584 683
330 1202
1729 708
447 139
760 435
860 ...

result:

ok Accepted with 159+2000 operations,sum of size(s)=176+318

Subtask #4:

score: 9
Accepted

Test #29:

score: 9
Accepted
time: 53ms
memory: 5304kb

input:

4
1084797752
100000 4000 200000 200000
1000
3456536122 3456534568
249115651 249115791
3576312078 3576312237
1880897416 1880895547
1944688480 1944688327
248846397 248847256
3567405828 3567405196
1084965392 1084965206
1435956247 1435955729
3887033767 3887032464
307260230 307260472
1476733874 147673312...

output:

Succeeded
1474 2000 6770 6395
1087 1988
1436 1911
1946 1397
1598 872
324 715
917 548
1363 1053
1798 1918
973 572
1764 1936
1868 1009
1171 1354
1464 1367
1297 1114
1487 745
412 707
101 123
1714 1634
1569 500
1025 1391
1930 4
1896 1859
1096 1331
1761 672
881 781
1334 496
1970 479
99 197
272 901
1132 1...

result:

ok Accepted with 1474+2000 operations,sum of size(s)=6770+6395

Test #30:

score: 9
Accepted
time: 35ms
memory: 5324kb

input:

4
583125216
100000 4000 200000 200000
1000
1729488108 1729488695
2234303914 2234304325
546617298 546616102
842050918 842051470
1951502077 1951501331
4271815110 4271815116
761587681 761586756
2172224244 2172223957
2934428060 2934428507
1919912734 1919912263
1067575137 1067574604
3411448089 3411447166...

output:

Succeeded
1197 2000 4678 3919
1532 1696
1693 1782
1584 1602
1153 1783
1364 1771
1784 1781
1059 1691
1609 1819
1561 1854
1031 1069
1846 1276
1254 1574
1479 1484
1708 1040
1093 1393
1680 1845
1414 1164
1523 1646
1296 1622
1480 1458
1348 1874
578 847
340 809
800 365
108 687
725 981
590 728
924 343
435 ...

result:

ok Accepted with 1197+2000 operations,sum of size(s)=4678+3919

Test #31:

score: 9
Accepted
time: 53ms
memory: 5496kb

input:

4
1854731567
100000 4000 200000 200000
998
946750857 946749479
898868556 898868101
2271278746 2271277916
1796596168 1796596321
161487283 161486866
1033814116 1033814195
2395521961 2395522326
1468519383 1468519080
2816096970 2816096367
1556209002 1556208501
3292442187 3292440851
1135140030 1135140110...

output:

Succeeded
1478 1996 6891 6372
1663 1659
1119 1543
1745 1479
131 146
1864 298
1146 1847
1510 1802
915 321
1481 1691
1138 1084
1556 1203
1017 878
1116 1145
702 879
350 171
505 380
1397 1902
1222 1213
1506 1007
1472 286
1690 933
1129 1244
1175 1739
641 829
69 124
755 780
1231 251
1932 830
715 238
630 4...

result:

ok Accepted with 1478+1996 operations,sum of size(s)=6891+6372

Test #32:

score: 9
Accepted
time: 53ms
memory: 5304kb

input:

4
2073988041
100000 4000 200000 200000
998
3168161931 3168162584
641363905 641362895
3784715137 3784714618
3548409026 3548409673
2737710699 2737710016
3324804481 3324803425
60841104 60840338
2010919705 2010919496
2362840315 2362840326
369236350 369237998
3600238093 3600237006
75182169 75182747
23418...

output:

Succeeded
1513 1996 7210 6791
1364 152
289 17
1706 49
1453 1016
137 1100
783 63
555 450
402 297
1226 723
1946 1131
1993 111
177 267
1599 1372
1433 242
1216 1994
1060 189
588 473
65 408
640 208
1591 1319
714 206
1277 1325
1794 983
943 306
1518 569
136 55
488 1952
1301 1554
1403 1253
787 844
735 382
7...

result:

ok Accepted with 1513+1996 operations,sum of size(s)=7210+6791

Test #33:

score: 9
Accepted
time: 50ms
memory: 5304kb

input:

4
1770340944
100000 4000 200000 200000
998
619870796 619870703
3121053787 3121054050
4195183636 4195182734
3139119614 3139119172
3634777517 3634777854
3433281440 3433281395
1485638549 1485638667
1231357421 1231357552
1705009906 1705010057
3514693637 3514694012
4265358236 4265358262
964902776 9649023...

output:

Succeeded
1480 1996 6890 6348
186 463
1866 650
1568 1086
1824 577
1728 1720
643 1620
533 593
10 683
1320 1986
5 159
611 1749
1386 1856
1246 1133
437 1852
213 705
1306 1599
957 150
1138 1221
1606 1354
1463 148
985 53
1206 1452
1446 1694
1451 623
1496 1964
562 336
882 55
751 192
505 449
1922 1331
1308...

result:

ok Accepted with 1480+1996 operations,sum of size(s)=6890+6348

Test #34:

score: 9
Accepted
time: 40ms
memory: 5212kb

input:

4
402901589
100000 4000 200000 200000
1000
1228378193 1228378597
1873458243 1873458214
2590411172 2590411391
3596693908 3596693672
442343415 442341879
1371534355 1371535333
1713867379 1713867258
2725534246 2725534433
3960722519 3960721503
1846001052 1846001387
2925453274 2925452776
1709191822 170919...

output:

Succeeded
1235 2000 7603 6042
1930 92
855 165
1761 1919
1177 1284
1046 1701
931 424
807 257
1334 1230
552 318
1029 1746
1262 1049
1406 1069
1990 1366
1841 1102
1101 1840
1622 1434
853 410
475 557
249 604
1457 540
673 105
1574 1347
1731 1844
1511 510
615 248
1251 1224
1944 915
275 481
1264 1343
1780 ...

result:

ok Accepted with 1235+2000 operations,sum of size(s)=7603+6042

Test #35:

score: 9
Accepted
time: 41ms
memory: 5312kb

input:

4
816997292
100000 4000 200000 200000
1000
3528745308 3528745448
2554369604 2554370028
2428697713 2428697760
2283123422 2283123636
2317970372 2317971439
3486243575 3486243354
914803066 914803223
3870938133 3870937913
833775363 833775109
133819724 133819108
4164722879 4164723079
4283955483 4283956051...

output:

Succeeded
1238 2000 7746 6180
1140 461
1796 1814
246 138
79 232
1203 1456
1855 1849
1398 1393
1674 1455
1365 750
490 573
667 95
1428 1579
1209 1384
102 636
1026 1507
1908 428
150 591
65 553
1443 164
1491 78
1109 258
1009 1309
1945 1555
1453 514
319 832
1842 1247
1546 1630
1726 780
749 813
1298 1167
...

result:

ok Accepted with 1238+2000 operations,sum of size(s)=7746+6180

Test #36:

score: 9
Accepted
time: 36ms
memory: 5216kb

input:

4
448483706
100000 4000 200000 200000
1000
3294405857 3294406138
1334269388 1334268750
3218236158 3218236229
1172020015 1172020961
4267095542 4267095785
884218942 884218794
2727697704 2727696787
4040088499 4040088016
3925649252 3925648708
3602778930 3602778977
25062275 25062940
782102904 782103485
4...

output:

Succeeded
1237 2000 7651 6046
1364 1941
1845 637
1990 1683
977 969
119 946
386 202
1880 1639
1384 1298
872 84
1974 1187
1691 1681
307 313
346 69
1289 351
1144 128
1493 501
1582 1627
1206 687
714 11
837 235
1305 1411
1471 597
585 632
1946 1357
1195 1575
1962 1396
1107 398
737 832
1773 1979
1592 1972
...

result:

ok Accepted with 1237+2000 operations,sum of size(s)=7651+6046

Test #37:

score: 9
Accepted
time: 28ms
memory: 5400kb

input:

4
1345753551
100000 4000 200000 200000
1000
2505101245 2505099844
1064732384 1064732096
3514288208 3514289196
4285598713 4285598588
289512304 289512216
961277738 961276571
270988037 270987782
351038556 351038779
2313748299 2313748400
3024327557 3024327268
1007549868 1007549449
3171882049 3171882337
...

output:

Succeeded
1033 2000 1631 2087
1408 1065
1183 510
1077 1809
1778 1308
1220 1706
1320 1566
1951 1890
1685 1139
1035 1380
1614 1218
1638 390
1955 1743
1924 1500
1868 1188
1810 1088
1590 1850
1511 1349
1407 1338
1300 1302
1195 1309
1887 181
1116 1242
1571 145
1752 1716
1539 1243
1223 1364
1023 1090
1526...

result:

ok Accepted with 1033+2000 operations,sum of size(s)=1631+2087

Test #38:

score: 9
Accepted
time: 28ms
memory: 5296kb

input:

4
163480472
100000 4000 200000 200000
998
2002085756 2002085748
2640607139 2640605823
836452341 836452238
179712028 179712352
1546416317 1546416341
3648734029 3648733547
4142213872 4142214412
711606286 711606592
1732581221 1732580465
2405962256 2405961750
1644716795 1644717277
589785362 589783494
12...

output:

Succeeded
1117 1996 1807 2273
1091 1535
1067 1171
1970 1530
1769 1856
1664 1215
1814 1183
1326 1292
1739 1577
1984 1377
1715 572
1030 56
1696 1495
1142 1176
1282 1407
1157 1431
1948 1765
1824 189
1930 1791
1651 1687
1056 1194
1125 1764
1729 1910
1018 1369
1158 1443
1062 1833
1190 1003
1855 1995
1429...

result:

ok Accepted with 1117+1996 operations,sum of size(s)=1807+2273

Subtask #5:

score: 11
Accepted

Test #39:

score: 11
Accepted
time: 51ms
memory: 5276kb

input:

5
1720909858
50000 4000 200000 100000
998
195378529 195378218
2138942224 2138942028
2421726252 2421725316
2614111628 2614111784
3778296551 3778295886
3346314089 3346313971
701234060 701233448
279201944 279202119
69826850 69826766
2173156660 2173157126
2982274003 2982273048
2306106121 2306107345
2808...

output:

Succeeded
1535 1996 8139 6625
494 1362
1961 851
597 1017
478 1000
742 805
1708 472
1826 804
797 1115
906 1975
741 1248
1659 1830
1974 1030
185 390
1229 1434
438 308
1245 1861
165 1520
1113 1720
126 173
1740 1964
1094 1199
383 198
897 58
202 1701
81 1562
925 7
747 707
125 1748
231 1314
781 767
808 36...

result:

ok Accepted with 1535+1996 operations,sum of size(s)=8139+6625

Test #40:

score: 11
Accepted
time: 44ms
memory: 5324kb

input:

5
1942257410
50000 4000 200000 100000
999
164109252 164108690
821766476 821766590
800182177 800180581
3645999838 3646000976
4086503876 4086505410
2171679381 2171678745
2952329225 2952330453
1354218636 1354219071
1174819694 1174820521
2253012620 2253012650
1329779110 1329779087
2814346065 2814346500
...

output:

Succeeded
1790 1998 6449 5107
312 740
472 747
538 720
34 1056
1735 90
331 282
1605 1775
102 301
31 1024
322 414
708 1371
62 859
1063 104
1662 1535
612 1316
1154 1598
431 1162
143 952
1952 1366
150 558
156 1281
1865 1326
1915 1581
1770 1984
328 440
1691 1477
1185 1486
504 465
1739 360
714 1687
392 91...

result:

ok Accepted with 1790+1998 operations,sum of size(s)=6449+5107

Test #41:

score: 11
Accepted
time: 24ms
memory: 5376kb

input:

5
161065852
50000 4000 200000 100000
1000
2966551129 2966552287
2856618787 2856618848
3795294524 3795295808
2757765097 2757764165
676105640 676105847
570204851 570205160
511088706 511090077
3497329264 3497329269
3725322378 3725322886
527017111 527016211
4071607765 4071607337
2817593784 2817593642
15...

output:

Succeeded
1250 2000 2204 2563
1387 1898
1353 1284
879 1215
508 1312
1944 1694
1522 1923
1396 1254
1211 1751
1179 1531
1221 1093
691 1180
1437 1544
1877 1936
481 1257
1251 1714
1666 1521
1592 1051
1530 1486
1343 1825
364 216
1804 1797
1943 1184
957 1488
1985 1208
1766 907
902 1699
1280 1899
1075 1536...

result:

ok Accepted with 1250+2000 operations,sum of size(s)=2204+2563

Test #42:

score: 11
Accepted
time: 53ms
memory: 5212kb

input:

5
777230405
50000 4000 200000 100000
999
3830467265 3830466694
1849159126 1849158949
2825053043 2825052212
2761591040 2761591070
939276197 939275664
3367167096 3367167288
3727731406 3727730932
406701926 406701618
530187802 530186715
3962995171 3962996546
1787609584 1787609620
993000803 993000542
158...

output:

Succeeded
1568 1998 8169 6821
576 1755
1532 1705
1646 1468
1072 1255
275 1287
1846 378
846 1838
1385 233
601 1848
10 455
1513 683
664 928
411 1336
357 580
1310 1232
1998 1956
212 359
1701 219
335 1625
1539 1773
1733 259
532 1564
1951 1476
1384 83
1488 545
1265 1174
500 433
17 1562
635 1849
1614 439
...

result:

ok Accepted with 1568+1998 operations,sum of size(s)=8169+6821

Test #43:

score: 11
Accepted
time: 53ms
memory: 5280kb

input:

5
97972513
50000 4000 200000 100000
999
654921388 654921281
3336987454 3336987177
439399097 439398662
1551555981 1551555288
3555879532 3555880729
2903638861 2903639277
257794283 257794433
3826111358 3826111966
1708274143 1708274017
3746235685 3746236123
907908447 907908765
4116365217 4116364822
1582...

output:

Succeeded
1567 1998 8085 6565
1270 167
1816 1442
1174 1028
171 155
1148 1074
1547 1042
1190 1583
1318 618
918 1824
487 1793
1065 63
1692 1087
757 417
1927 1379
1848 946
261 125
1447 1942
460 1029
412 80
1220 1062
321 631
1672 188
452 370
1022 1651
792 968
1955 1545
1645 1406
456 1248
58 675
1973 426...

result:

ok Accepted with 1567+1998 operations,sum of size(s)=8085+6565

Test #44:

score: 11
Accepted
time: 49ms
memory: 5476kb

input:

5
397162223
50000 4000 200000 100000
1000
2103775764 2103775539
3507938589 3507938863
4080657108 4080657210
2492592687 2492593001
111756474 111755329
3545417212 3545415789
3115563885 3115563458
2404092040 2404092248
1717324095 1717323827
2910355772 2910355898
40550063 40549395
1332934233 1332933830
...

output:

Succeeded
1542 2000 7968 6433
1998 818
498 162
844 373
680 689
1591 802
703 1064
449 634
305 181
778 1906
936 974
146 811
1153 301
322 1386
741 97
1911 518
893 958
1862 762
1001 1229
1391 1166
1272 1248
722 729
348 1507
446 177
224 870
1565 995
389 773
1057 845
1735 24
149 491
203 980
260 497
328 13...

result:

ok Accepted with 1542+2000 operations,sum of size(s)=7968+6433

Test #45:

score: 11
Accepted
time: 2ms
memory: 6316kb

input:

5
1695502059
50000 4000 200000 100000
1000
700852541 700853138
286392703 286393228
862046288 862047179
1594299681 1594299408
3210366802 3210366961
1413959809 1413960445
3698437765 3698437869
1377184122 1377184197
281217513 281217619
145372596 145373148
502398350 502398463
2741843047 2741843594
34564...

output:

Succeeded
537 2000 621 1074
1551 1171
1879 1323
1027 1452
1185 1414
1513 1943
1794 1775
1356 1799
1703 1803
1476 1228
1041 1327
1853 1674
1366 1595
1809 1326
1539 1899
1549 1436
1813 1328
1723 1147
1747 1206
1804 1043
1375 1756
1462 1096
1573 1529
1754 1307
1428 1415
1504 1969
1710 1220
1240 1212
11...

result:

ok Accepted with 537+2000 operations,sum of size(s)=621+1074

Test #46:

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

input:

5
1256148136
50000 4000 200000 100000
999
2016310630 2016310917
2107471344 2107470258
3472709132 3472709188
289824693 289824187
968116627 968117102
254957789 254959335
3918543752 3918543310
3679196968 3679195694
2994473794 2994473552
4244660702 4244660526
1565613257 1565613765
4153244320 4153244472
...

output:

Succeeded
883 1998 1406 1766
1083 91
1061 1097
770 36
1756 727
263 1594
1413 1941
790 1335
1014 1585
754 299
518 1988
1712 611
726 1017
1508 1330
372 987
1141 903
586 1885
1071 1533
1823 23
1672 111
334 967
1305 693
1476 936
1446 1750
612 1293
167 864
1130 759
856 465
1324 1110
1644 1603
69 1657
159...

result:

ok Accepted with 883+1998 operations,sum of size(s)=1406+1766

Test #47:

score: 11
Accepted
time: 2ms
memory: 5548kb

input:

5
174080677
50000 4000 200000 100000
1000
3686639308 3686638800
2896535064 2896534994
942582287 942582342
1036404485 1036404700
2240524876 2240525002
885623407 885623800
2908065975 2908066813
132144926 132144327
4212166510 4212165968
2576925241 2576925211
2854923688 2854924082
4019207120 4019206802
...

output:

Succeeded
5 2000 6 10
826 15
722 1642
700 588
170 383
827 63
622 480
245 87
894 392
777 893
1295 354
364 682
365 729
519 471
780 1905
528 586
806 306
246 937
410 872
96 264
183 548
376 786
229 317
19 415
860 982
986 116
598 808
418 745
212 862
214 201
581 854
730 497
422 393
458 483
635 571
1699 204...

result:

ok Accepted with 5+2000 operations,sum of size(s)=6+10

Test #48:

score: 11
Accepted
time: 27ms
memory: 5392kb

input:

5
1245824305
50000 4000 200000 100000
1000
3667004853 3667004169
2287697139 2287696730
2209822990 2209823892
4121239467 4121237803
1095196087 1095194911
1774546551 1774545134
1362722072 1362721338
1986032138 1986033160
3134483043 3134484458
3770232965 3770233774
4150800332 4150798469
444018341 44401...

output:

Succeeded
1489 2000 13189 5993
677 1987
789 1562
486 1499
328 1043
173 1217
536 1358
831 1594
102 1574
146 1067
95 1528
461 1621
927 1387
439 1638
489 1353
147 1516
55 1460
264 1273
220 1514
31 1889
309 1230
684 1941
863 1339
16 1675
558 1769
904 1352
158 1804
237 1254
308 1383
853 1946
573 1756
654...

result:

ok Accepted with 1489+2000 operations,sum of size(s)=13189+5993

Test #49:

score: 11
Accepted
time: 26ms
memory: 5308kb

input:

5
1416201142
50000 4000 200000 100000
999
2694326229 2694325190
3006267026 3006266271
3590771525 3590772511
382357401 382355920
3477874958 3477875914
653232151 653234151
4226125318 4226123972
2278771395 2278772384
2110222591 2110223909
3320640593 3320639898
2013976833 2013977782
2032673776 203267476...

output:

Succeeded
1487 1998 13289 6008
452 1695
831 1399
288 1070
216 1398
730 1137
56 1007
573 1331
267 1677
986 1612
408 1199
379 1700
727 1966
256 1050
918 1494
243 1342
430 1433
51 1276
104 1884
953 1785
125 1536
713 1760
604 1992
500 1507
748 1367
677 1871
302 1712
669 1330
446 1351
839 1384
808 1894
4...

result:

ok Accepted with 1487+1998 operations,sum of size(s)=13289+6008

Subtask #6:

score: 12
Accepted

Test #50:

score: 12
Accepted
time: 63ms
memory: 5276kb

input:

6
889180297
25000 4000 200000 100000
998
3680334935 3680334330
2957217208 2957215867
3096097757 3096097331
2843029536 2843030717
2270437916 2270437982
1841161075 1841160444
3671823118 3671823208
2166904224 2166903071
2760262295 2760263328
880472976 880472564
3147819342 3147820514
3366602035 33666019...

output:

Succeeded
1525 1996 7173 6979
1863 1562
344 1833
1321 162
524 722
816 1246
1276 908
887 653
1970 1035
100 1152
416 1925
698 366
783 618
1638 557
1047 1680
861 919
1032 1973
353 277
1184 135
1222 1385
1688 1256
415 1003
1589 428
378 597
145 282
199 409
1496 1600
1858 1921
1902 1947
1949 904
1588 87
2...

result:

ok Accepted with 1525+1996 operations,sum of size(s)=7173+6979

Test #51:

score: 12
Accepted
time: 58ms
memory: 5244kb

input:

6
1393953829
25000 4000 200000 100000
999
945306191 945306676
862749063 862750710
1587703663 1587703760
2321904837 2321905131
3322741249 3322741330
128629140 128628755
4061072808 4061073316
3009230812 3009229891
3626184675 3626183179
3701144497 3701145089
1334455826 1334454368
3195102134 3195101407
...

output:

Succeeded
1502 1998 7323 7045
1884 79
1669 633
1110 1173
662 95
1662 1764
1894 1630
1463 86
602 873
1682 1794
1743 1587
1796 64
172 930
692 905
53 553
1528 611
841 998
627 610
1047 1275
179 1164
990 503
1405 66
1928 289
1565 1053
1799 1714
1191 508
227 82
556 267
617 651
1539 1992
836 1226
1823 319
...

result:

ok Accepted with 1502+1998 operations,sum of size(s)=7323+7045

Test #52:

score: 12
Accepted
time: 29ms
memory: 5508kb

input:

6
2137907583
25000 4000 200000 100000
1000
99249012 99249101
3089074242 3089075163
3142929261 3142928885
3509452069 3509452074
4100326210 4100325388
2027856240 2027856707
1667832698 1667832002
239393593 239393607
3323558397 3323558267
87270863 87271227
2749644672 2749644377
3753692402 3753692989
671...

output:

Succeeded
931 2000 4755 3685
902 591
202 413
1896 1107
1312 1290
1057 1333
1037 1422
1519 1502
1698 1177
432 553
26 428
360 423
635 140
549 630
190 405
441 48
424 87
910 86
690 258
476 388
378 831
1017 1346
1326 1718
1318 569
778 696
1924 1838
1857 1669
1597 1435
1974 1169
1934 1272
1706 1375
1360 1...

result:

ok Accepted with 931+2000 operations,sum of size(s)=4755+3685

Test #53:

score: 12
Accepted
time: 23ms
memory: 5300kb

input:

6
620581501
25000 4000 200000 100000
999
2430495051 2430494760
2342044260 2342044349
4168624383 4168624716
4153034330 4153033041
113541062 113539588
3734354027 3734355235
204355212 204355044
2304848470 2304848423
2783072361 2783073753
431065913 431066151
800004122 800004842
3667276533 3667275783
229...

output:

Succeeded
805 1998 3954 3023
964 443
519 635
756 250
354 425
3 722
106 156
986 825
886 438
980 982
80 907
285 341
188 433
219 978
40 871
809 274
1414 1419
1071 1554
1934 1170
1670 1368
1782 1870
1889 1929
1440 1006
1667 1415
748 266
26 63
406 501
298 229
688 236
1050 1621
1346 1661
1077 1272
1040 15...

result:

ok Accepted with 805+1998 operations,sum of size(s)=3954+3023

Test #54:

score: 12
Accepted
time: 24ms
memory: 5316kb

input:

6
1540179210
25000 4000 200000 100000
998
908025469 908025772
4110515646 4110516139
1434161137 1434160239
4210047633 4210047681
2756906765 2756906979
773613891 773613906
3984390566 3984390788
1117864605 1117864853
379534092 379533510
3317517762 3317518164
1919343058 1919344136
1048781877 1048782644
...

output:

Succeeded
912 1996 4350 3670
1358 1295
1762 1306
1465 1551
1173 1065
1156 1680
1742 1496
1717 1259
1038 1745
1425 1124
1129 1217
1369 1414
1544 1083
1936 1413
1209 1733
1455 1478
1653 1572
1920 1972
1432 1528
1061 1509
1299 1041
1683 1433
1268 1773
1471 1626
1182 1902
1814 1190
1459 1605
1084 1957
1...

result:

ok Accepted with 912+1996 operations,sum of size(s)=4350+3670

Test #55:

score: 12
Accepted
time: 16ms
memory: 5340kb

input:

6
218843024
25000 4000 200000 100000
1000
4003665165 4003664581
989541263 989541162
1710766055 1710765338
3659822362 3659822800
2654208269 2654208393
1491873748 1491873450
1160537498 1160536441
3762298781 3762298020
3903551469 3903551390
4248337091 4248336400
1517118005 1517118186
399918797 39991852...

output:

Succeeded
613 2000 4139 2460
1196 1685
1729 1526
1604 1441
1337 1728
1018 1662
1845 1014
1130 1665
1113 1505
1589 1424
1431 1291
1999 1045
1263 1967
1417 1473
1328 1862
1307 1725
1148 1741
1483 1081
1070 1680
1854 1074
1226 1656
1260 1783
1439 1075
1192 1170
1027 1511
1455 1507
1712 1320
1357 1224
1...

result:

ok Accepted with 613+2000 operations,sum of size(s)=4139+2460

Test #56:

score: 12
Accepted
time: 18ms
memory: 5348kb

input:

6
846170590
25000 4000 200000 100000
998
1218684893 1218683879
1552665572 1552664853
3443478269 3443477570
1790763876 1790763016
1025362073 1025360149
2654707482 2654705839
1494316579 1494316380
2068116991 2068116277
331974024 331973737
1788075132 1788074334
953158534 953158009
586401169 586400597
2...

output:

Succeeded
688 1996 4111 2530
1180 1232
1412 1749
1329 1090
1335 1034
1372 1854
1625 1031
1954 1713
1324 1989
1315 856
1904 1202
1454 1277
160 510
947 1856
849 833
1598 783
1681 1178
1686 889
1340 504
450 1378
177 135
1611 1725
1541 1898
1015 1368
1990 1420
996 1936
754 622
745 83
297 602
697 451
161...

result:

ok Accepted with 688+1996 operations,sum of size(s)=4111+2530

Test #57:

score: 12
Accepted
time: 21ms
memory: 5244kb

input:

6
681304959
25000 4000 200000 100000
999
2726760615 2726761129
4070002268 4070002314
2698967410 2698967313
3149535258 3149536218
3426049564 3426049397
1255425746 1255425945
273472210 273471617
432940843 432940957
539629098 539628555
625817515 625817025
2355613233 2355613594
10360141 10360443
3239718...

output:

Succeeded
820 1998 6681 3427
635 218
266 454
651 331
408 975
761 96
252 214
794 138
626 820
123 366
960 505
53 519
771 204
106 773
245 695
665 444
78 681
372 940
124 650
603 277
989 693
458 528
904 411
962 115
74 809
169 945
85 475
400 126
909 296
886 862
968 939
31 365
552 583
812 109
397 963
154 4...

result:

ok Accepted with 820+1998 operations,sum of size(s)=6681+3427

Test #58:

score: 12
Accepted
time: 21ms
memory: 5288kb

input:

6
1240372772
25000 4000 200000 100000
1000
1759289079 1759288926
1933352834 1933352077
347838835 347839028
2202749992 2202750871
3939036060 3939035178
3009870817 3009869983
3748040393 3748040424
864310002 864310105
1129152802 1129153119
718780908 718780600
1884330497 1884330296
2050569859 2050569350...

output:

Succeeded
817 2000 6492 3331
845 671
483 828
323 81
639 876
205 655
908 924
772 770
955 174
984 305
310 347
796 612
532 278
256 326
426 297
67 939
791 823
953 818
795 314
54 93
142 947
327 439
554 216
106 998
705 931
635 519
853 977
125 881
557 836
974 114
365 586
512 191
817 38
381 64
151 431
139 9...

result:

ok Accepted with 817+2000 operations,sum of size(s)=6492+3331

Subtask #7:

score: 14
Accepted

Test #59:

score: 14
Accepted
time: 56ms
memory: 5312kb

input:

7
1561772597
25000 4000 200000 100000
1000
834919143 834919090
162625904 162627303
1067517190 1067517712
3410644901 3410644677
2728503196 2728502622
4133685425 4133685598
976760503 976760426
2101358026 2101358499
3583017242 3583017016
1743218912 1743220527
2609984627 2609985177
3915259025 3915259188...

output:

Succeeded
1488 2000 8024 6915
939 263
1642 1057
1947 1886
1185 1220
1172 1264
1163 1076
1609 1216
1137 1496
1674 1232
1299 1630
1676 982
1352 928
1012 1158
1325 1049
40 725
1313 1546
1449 89
1788 560
799 535
1405 313
421 236
1063 1477
1453 1267
1116 1918
1099 1210
1146 1623
1827 1429
1870 1679
1414 ...

result:

ok Accepted with 1488+2000 operations,sum of size(s)=8024+6915

Test #60:

score: 14
Accepted
time: 2ms
memory: 6196kb

input:

7
1336630764
25000 4000 200000 100000
999
3754204676 3754204263
661669146 661669691
3383866850 3383866634
4286058306 4286058462
275363558 275362939
490879941 490879205
3048247936 3048247911
60895431 60895902
2012261918 2012261908
2305570243 2305570248
2756619485 2756618373
766927763 766927449
261527...

output:

Succeeded
50 1998 52 100
1585 1793
1885 1955
1113 1716
1922 1910
1817 1796
1062 1426
1886 1442
1204 1633
1034 1469
1198 1780
1003 1709
1692 1238
1758 1066
1202 1774
1443 1842
1367 1507
1404 1935
1101 1221
1912 1726
1170 1455
1251 1126
1928 1265
1215 1117
1331 1225
1657 1419
1448 1566
1631 1897
1407 ...

result:

ok Accepted with 50+1998 operations,sum of size(s)=52+100

Test #61:

score: 14
Accepted
time: 39ms
memory: 5280kb

input:

7
1779405874
25000 4000 200000 100000
1000
4131992564 4131991606
1062232027 1062231506
3582875319 3582875068
1679869647 1679869620
3772280193 3772280538
4214125072 4214124839
2659083848 2659083347
1373877441 1373877158
1844973250 1844972076
3526061965 3526060499
2547082343 2547083157
1838200915 1838...

output:

Succeeded
1796 2000 6248 5062
378 84
1366 999
1934 1325
813 768
1988 670
1616 867
1022 1568
401 1958
815 1968
1444 854
706 1654
1388 1796
1782 415
1942 36
1070 1279
1646 1594
1581 1261
1009 1508
877 372
1771 1746
64 1722
457 1206
1249 1183
1065 1599
485 1778
1397 60
679 1283
1759 1933
610 551
694 27...

result:

ok Accepted with 1796+2000 operations,sum of size(s)=6248+5062

Test #62:

score: 14
Accepted
time: 57ms
memory: 5504kb

input:

7
1570401939
25000 4000 200000 100000
998
3148646883 3148647333
3472091054 3472090123
278894780 278894651
57610944 57610331
1860420864 1860420782
2989090556 2989090327
4158835568 4158834777
196113056 196114393
2109982628 2109981735
3313427840 3313427593
1791526870 1791526564
871045252 871046635
1321...

output:

Succeeded
1483 1996 8829 7192
1114 1678
690 654
1295 1695
1661 668
1169 1858
660 239
482 339
1951 81
1146 909
1133 86
122 416
1454 1464
1710 842
1903 108
1640 143
1799 1263
66 1060
36 800
943 1171
1822 637
1559 720
1786 806
823 216
1440 487
905 50
1736 1173
1341 1957
1637 1668
302 247
23 866
1345 12...

result:

ok Accepted with 1483+1996 operations,sum of size(s)=8829+7192

Test #63:

score: 14
Accepted
time: 20ms
memory: 5320kb

input:

7
1450625915
25000 4000 200000 100000
1000
1109002343 1109003135
22686111 22686391
708137842 708137834
1827926645 1827926257
4068418853 4068418436
3173412806 3173411005
435305565 435304885
663912650 663913396
3575081618 3575082276
2005743663 2005744468
2259422734 2259422527
1400805550 1400806829
101...

output:

Succeeded
1160 2000 5547 4498
893 566
917 372
1668 1174
1698 172
1444 1524
296 1458
102 233
678 229
1094 992
1773 1154
1345 1555
1350 1972
571 440
197 774
1959 1601
1673 1812
551 886
1379 1832
1720 359
1844 140
1370 573
511 173
471 906
346 1647
155 80
1597 1968
674 710
88 335
1236 396
251 389
373 26...

result:

ok Accepted with 1160+2000 operations,sum of size(s)=5547+4498

Test #64:

score: 14
Accepted
time: 19ms
memory: 5560kb

input:

7
135746746
25000 4000 200000 100000
999
3854621486 3854622490
1569079030 1569077610
3987490504 3987489881
1484524078 1484524939
1470817867 1470817629
2723442111 2723441053
3895536593 3895535810
4009379127 4009379481
830706098 830707463
32509494 32508360
1070489719 1070490536
3334764196 3334762664
5...

output:

Succeeded
1163 1998 4271 3587
1452 297
2 905
132 393
675 653
589 310
466 667
1177 1097
1776 1422
1423 994
497 213
124 127
1791 212
1431 1096
1914 711
478 767
1406 268
100 880
147 598
1833 641
516 358
1234 1809
1172 1224
1679 927
1480 720
1574 1802
295 1591
1321 1705
69 199
1565 1893
1218 1892
1296 1...

result:

ok Accepted with 1163+1998 operations,sum of size(s)=4271+3587

Test #65:

score: 14
Accepted
time: 17ms
memory: 5236kb

input:

7
2111844098
25000 4000 200000 100000
999
131730287 131729491
4234622692 4234621839
1894854842 1894855171
1857632532 1857633676
3106353509 3106353801
2640063239 2640064499
921644037 921643352
3957407885 3957409750
2539548444 2539548384
2096058913 2096059646
3789843675 3789842850
3719590991 371959020...

output:

Succeeded
1073 1998 3955 3378
652 1544
277 197
444 670
1465 624
1637 67
759 371
1143 1243
88 1698
1977 374
578 1956
401 1286
117 1279
1008 1631
750 1884
563 378
1160 510
1507 902
1966 1954
276 1094
335 1297
231 218
1972 1505
1555 1704
806 568
1254 1099
1588 1801
1978 720
647 1750
1506 127
215 1627
1...

result:

ok Accepted with 1073+1998 operations,sum of size(s)=3955+3378

Test #66:

score: 14
Accepted
time: 20ms
memory: 5332kb

input:

7
641335315
25000 4000 200000 100000
999
122084504 122085088
4017276980 4017277724
19577205 19577638
609865507 609864840
2949642502 2949642300
1449572439 1449573269
2586554784 2586554671
3749879720 3749879330
805233097 805233176
3505563718 3505564210
3463027822 3463028639
56206486 56206377
174519616...

output:

Succeeded
808 1998 6606 3368
343 273
92 238
200 422
172 518
157 64
835 727
180 315
777 621
663 825
813 962
571 685
812 303
424 923
332 247
366 15
826 56
669 500
749 68
16 361
633 653
893 440
702 367
326 19
289 135
755 331
103 465
887 907
651 698
866 237
454 688
524 650
160 694
390 527
117 741
284 82...

result:

ok Accepted with 808+1998 operations,sum of size(s)=6606+3368

Test #67:

score: 14
Accepted
time: 21ms
memory: 6132kb

input:

7
1902724585
25000 4000 200000 100000
999
2412323026 2412323115
1989891554 1989891443
2773765341 2773765514
265447302 265447090
4117457062 4117457651
1482561312 1482560953
1406096926 1406097254
705631463 705631517
1803953538 1803953889
458839460 458839350
1879258721 1879258324
1880425144 1880424987
...

output:

Succeeded
836 1998 6646 3461
115 715
159 495
197 371
406 548
310 898
843 151
932 307
785 529
519 200
422 953
621 814
217 37
686 530
842 591
356 654
205 807
675 487
925 754
375 866
841 538
182 338
265 464
59 542
694 260
729 747
905 839
267 172
63 978
212 884
329 702
121 827
806 853
163 214
459 283
92...

result:

ok Accepted with 836+1998 operations,sum of size(s)=6646+3461

Test #68:

score: 14
Accepted
time: 26ms
memory: 5308kb

input:

7
1304909866
25000 4000 200000 100000
999
1295903888 1295903022
3932878443 3932876957
2811484715 2811485941
1438514539 1438514070
3806386020 3806385111
3192192194 3192192414
1991099750 1991098370
2746660665 2746658904
3585441978 3585443592
1667685273 1667682831
263427952 263426365
4181260055 4181258...

output:

Succeeded
1480 1998 13085 5802
159 1587
227 1943
154 1593
652 1716
314 1723
25 1497
36 1165
446 1156
169 1535
756 1817
697 1477
717 1305
540 1845
600 1608
947 1669
356 1280
927 1395
282 1494
217 1260
417 1251
786 1815
844 1524
876 1906
7 1607
126 1340
911 1616
828 1209
194 1658
112 1233
65 1843
76 1...

result:

ok Accepted with 1480+1998 operations,sum of size(s)=13085+5802

Test #69:

score: 14
Accepted
time: 32ms
memory: 5340kb

input:

7
1317463763
25000 4000 200000 100000
998
2526685232 2526686705
1167751659 1167752904
4129542793 4129542553
845923368 845923839
2137792880 2137793312
2457480648 2457479423
3722627917 3722628322
1641737839 1641737029
1524460390 1524460841
24205870 24206552
796248162 796249277
3238897910 3238899020
37...

output:

Succeeded
1564 1996 12670 6316
1618 181
777 1801
1177 633
379 1104
435 1273
522 1613
354 1830
762 1119
1492 746
1068 992
872 1993
36 1851
877 1807
211 1566
299 1954
1412 989
1344 580
822 1611
873 1047
436 1557
44 883
953 1217
1722 21
1987 251
1283 1906
734 1781
803 1569
521 1823
558 1006
456 653
362...

result:

ok Accepted with 1564+1996 operations,sum of size(s)=12670+6316

Subtask #8:

score: 10
Accepted

Test #70:

score: 10
Accepted
time: 1493ms
memory: 6708kb

input:

8
1311447458
50000 100000 500000 200000
4999
173190562 173182163
1078196947 1078197142
1215565665 1215571165
1186082670 1186081354
2422459084 2422459806
2626070241 2626074599
207492448 207494582
2266700305 2266695214
1679673055 1679672568
3879988278 3879982030
254940475 254941572
3919251618 39192495...

output:

Succeeded
7566 9998 56257 46963
6570 9316
2416 7626
2570 712
6245 4292
1028 7727
438 584
7029 3047
3916 7057
4472 1371
2586 5388
8 5576
7874 7045
2362 1640
8031 4643
2441 5338
490 2881
4430 4513
544 501
319 602
5239 8480
9278 1943
7956 2582
2214 5068
2392 1846
3124 274
1443 8636
8867 4357
1474 8651
...

result:

ok Accepted with 7566+9998 operations,sum of size(s)=56257+46963

Test #71:

score: 10
Accepted
time: 8ms
memory: 8044kb

input:

8
146283890
50000 100000 500000 200000
4998
2993119013 2993115357
4268970052 4268971874
808002542 808006552
892885669 892881200
2460117409 2460115710
3324732245 3324732140
54868859 54854998
1804229854 1804227421
450513797 450514478
1104546934 1104547705
2070884692 2070873353
379400982 379401581
3321...

output:

Succeeded
245 9996 258 490
2714 436
3593 754
902 1454
3375 534
3616 3175
2916 2540
2710 1567
2037 4807
2278 4573
137 1261
1312 4212
3963 356
5926 2680
4080 3867
4227 2692
2762 3958
1892 4839
4601 4806
1991 3101
3686 1668
3167 3126
2880 1676
4687 2283
3698 274
2209 2583
1564 68
636 4136
2319 2515
223...

result:

ok Accepted with 245+9996 operations,sum of size(s)=258+490

Test #72:

score: 10
Accepted
time: 939ms
memory: 7036kb

input:

8
359304486
50000 100000 500000 200000
4999
1094705883 1094709685
1722131883 1722132595
2997024384 2997026636
3860480932 3860484415
628475092 628485245
2336751135 2336748598
3814389699 3814390104
2291095406 2291091625
2583462746 2583462819
2798317408 2798309538
2146225602 2146229179
2197058314 21970...

output:

Succeeded
9106 9998 32402 25682
9194 2882
5377 2818
8549 7476
3922 9339
1715 6139
7293 1734
6050 2405
7782 8089
4438 5248
6868 9711
3164 6677
489 685
5981 10
3499 4378
6492 1140
3421 6749
7851 1520
6435 3072
5987 6503
3918 1861
1349 6619
4780 8266
479 6966
9369 8237
5902 4988
6194 9846
436 1681
100 ...

result:

ok Accepted with 9106+9998 operations,sum of size(s)=32402+25682

Test #73:

score: 10
Accepted
time: 1470ms
memory: 6748kb

input:

8
274726151
50000 100000 500000 200000
4999
3419263031 3419258906
2999444481 2999444350
3939520462 3939526440
2959958627 2959955437
3179200434 3179194481
314093006 314083104
1172908290 1172911855
4164171409 4164165636
4266437323 4266441231
938450767 938450959
3402967524 3402968757
2430673118 2430680...

output:

Succeeded
7613 9998 57023 47135
1588 5999
4425 7498
6495 8801
6513 4054
2597 6757
5593 2912
7310 9846
121 2489
454 5570
4768 1301
6906 842
8270 6593
1298 8583
4624 1970
5506 2791
2747 1063
4139 729
3266 4354
6005 4539
682 467
7612 9389
4699 2423
1794 4327
8251 6689
475 986
1085 2003
4979 5970
3852 5...

result:

ok Accepted with 7613+9998 operations,sum of size(s)=57023+47135

Test #74:

score: 10
Accepted
time: 498ms
memory: 6852kb

input:

8
36542142
50000 100000 500000 200000
4998
1882767946 1882768363
2002146634 2002148253
2634053693 2634052789
1026701278 1026688769
2616046340 2616047360
3871226190 3871226271
826813115 826802828
407974325 407972617
308792051 308793619
1589844798 1589845765
2250581592 2250578704
1119903193 1119902668...

output:

Succeeded
5529 9996 37249 26615
3025 9192
8492 2701
1295 9520
6351 4376
182 9390
9456 3596
5430 6529
7205 7820
8227 1292
9286 1040
305 7107
9443 9324
8018 6606
475 4909
881 2769
4776 5659
8205 5922
1154 1722
6587 4938
7848 2328
6870 7126
2911 7159
2883 8540
8706 3319
8581 9515
2995 6695
6506 9794
45...

result:

ok Accepted with 5529+9996 operations,sum of size(s)=37249+26615

Test #75:

score: 10
Accepted
time: 523ms
memory: 6884kb

input:

8
1487850256
50000 100000 500000 200000
4998
1811651536 1811650670
345905379 345902625
2279108766 2279111434
2091518940 2091524010
3909207465 3909209873
3388023095 3388020461
4146491221 4146487463
335162845 335161804
1825736789 1825741802
4134879931 4134887877
954293244 954286743
619524094 619526641...

output:

Succeeded
5941 9996 35904 25321
7451 2077
5398 4332
710 9190
5950 3411
8940 1604
5412 651
37 6225
4542 5724
286 4193
5071 896
5782 4569
9802 7245
6509 5971
6744 2426
8197 3276
1857 656
1681 359
5258 7215
3033 3350
28 9357
3303 5872
3710 280
2741 1955
2866 4973
8012 4781
5255 6815
2948 4721
7884 3058...

result:

ok Accepted with 5941+9996 operations,sum of size(s)=35904+25321

Test #76:

score: 10
Accepted
time: 438ms
memory: 6936kb

input:

8
1221498280
50000 100000 500000 200000
4998
2995611046 2995612152
3821228370 3821223946
2603755886 2603749274
4253723935 4253721827
1284666231 1284667975
3724747876 3724742578
511189298 511194763
3517774027 3517770230
3839257128 3839260219
2120621563 2120626674
2987809269 2987806806
4029661482 4029...

output:

Succeeded
5048 9996 31204 22153
9518 1961
9042 9245
7337 4476
8693 3186
3111 2194
2164 2734
9639 227
6208 7491
5326 580
2968 8084
6956 4353
5868 3990
1102 4220
5969 6903
1677 8915
4179 2051
6909 6441
4722 5239
2502 1302
6663 6293
7939 9688
1288 8454
2331 9901
238 5385
18 4363
9020 181
7993 6248
3276...

result:

ok Accepted with 5048+9996 operations,sum of size(s)=31204+22153

Test #77:

score: 10
Accepted
time: 462ms
memory: 6704kb

input:

8
587527602
50000 100000 500000 200000
4999
3568373793 3568376644
1120949625 1120946940
415496958 415496926
12393946 12392788
386545771 386532889
4139741816 4139743781
561101154 561098999
256455977 256456345
3867681645 3867688124
934936599 934942934
3224959264 3224945918
3353558087 3353557351
100232...

output:

Succeeded
4196 9998 43750 22143
2722 699
4339 2940
309 2872
4385 1852
4477 92
1128 2686
71 2320
893 1193
1455 4187
4035 4794
1915 3364
4077 117
4790 4457
2982 1249
725 1579
4819 3616
980 1471
4288 1107
3176 4039
3287 2549
2209 334
2136 1649
1670 3526
2129 3
661 742
1117 3837
3231 4603
3225 2995
2680...

result:

ok Accepted with 4196+9998 operations,sum of size(s)=43750+22143

Test #78:

score: 10
Accepted
time: 447ms
memory: 6996kb

input:

8
1394126129
50000 100000 500000 200000
5000
3535160872 3535160998
2231302465 2231289478
456729403 456731555
2086709903 2086708267
4035270421 4035268777
3771632269 3771645711
4192491848 4192489822
3316315203 3316302642
1887846361 1887831530
1613070769 1613085466
1693599113 1693601030
4198542233 4198...

output:

Succeeded
4154 10000 41254 20667
3961 1407
1302 2103
587 1397
1474 2369
1114 4575
3806 128
2273 4117
1530 4432
3686 4531
1699 1042
4228 4838
4015 1020
4844 3648
2581 4291
464 3018
2093 1329
2988 4425
391 3335
1358 3383
3677 4106
137 3497
4946 1131
1073 1604
3017 2698
115 2381
4356 4647
4523 1471
188...

result:

ok Accepted with 4154+10000 operations,sum of size(s)=41254+20667

Test #79:

score: 10
Accepted
time: 661ms
memory: 6880kb

input:

8
798061011
50000 100000 500000 200000
4998
909931267 909922860
4047965918 4047969477
3648796296 3648794907
4128167602 4128163056
937507996 937506719
3406709348 3406716060
2859206410 2859204776
3876175763 3876164150
104431102 104422384
3251853137 3251856828
4215276376 4215282690
2479989695 247999056...

output:

Succeeded
7648 9996 87536 41733
1670 6126
2204 6067
1795 6217
247 6316
1839 8776
4403 8527
347 8132
345 6069
2195 7437
1799 7056
3566 6525
1144 5883
2682 7338
867 8774
2380 9176
7918 1153
5952 733
8262 2901
4915 9614
302 6625
1498 6207
3891 8053
4233 9590
2762 5040
3988 7545
421 7170
1638 6737
934 8...

result:

ok Accepted with 7648+9996 operations,sum of size(s)=87536+41733

Test #80:

score: 10
Accepted
time: 696ms
memory: 6892kb

input:

8
656855851
50000 100000 500000 200000
4999
505382265 505388755
3711069187 3711071188
2063994872 2063998683
467498120 467489115
1612163573 1612159860
1652695836 1652701825
854925443 854917595
1815956515 1815955989
3950893219 3950889646
2218879655 2218869478
207692325 207699864
2160331192 2160333277
...

output:

Succeeded
7762 9998 86455 42340
4013 9230
3471 5975
3554 9890
648 5284
264 7249
4491 9156
480 7754
1177 9573
1871 7924
2980 9222
11 4514
2150 8623
6271 2042
8473 2051
9269 1767
2243 8466
3016 5314
3293 8513
2834 7310
1048 6120
2530 9667
2345 8097
1262 8124
169 5026
8660 3795
1718 9569
4080 7138
3314...

result:

ok Accepted with 7762+9998 operations,sum of size(s)=86455+42340

Subtask #9:

score: 27
Accepted

Test #81:

score: 27
Accepted
time: 1421ms
memory: 6988kb

input:

9
574951428
15000 10000 200000 50000
5000
1781472251 1781466624
803445324 803444785
3544280892 3544283003
3151400420 3151403948
3250864128 3250871501
4189507543 4189510374
3483519516 3483520446
1003612935 1003617460
1101934749 1101931586
1948046579 1948042301
4151407804 4151401951
424123439 42412196...

output:

Succeeded
7585 10000 54918 45250
3757 9454
2756 2108
7965 8439
371 3684
3337 9824
3913 2664
9620 699
2876 7255
5633 7667
5778 4091
3298 6775
3863 53
1437 8038
2868 4551
3041 8063
8654 1489
6179 9298
3229 8126
2428 2920
1801 4675
608 1137
8424 4634
6567 2512
7962 6912
6066 4680
2587 1332
4708 6949
49...

result:

ok Accepted with 7585+10000 operations,sum of size(s)=54918+45250

Test #82:

score: 27
Accepted
time: 32ms
memory: 7672kb

input:

9
1015784000
15000 10000 200000 50000
4999
1230515063 1230515477
1648235686 1648236525
635002652 635000809
2658028480 2658040457
1408253592 1408238543
769202478 769200158
2523685577 2523682650
1538862073 1538856433
749934974 749934304
3127382239 3127383977
4154342134 4154335434
73346199 73343176
240...

output:

Succeeded
2225 9998 2463 4450
4585 5430
2666 2301
9190 8137
7812 5119
9489 8282
7106 5657
7010 7999
8623 7972
6119 7776
6023 8023
9818 7473
9327 9433
6075 9604
7244 7170
5820 8933
7956 8317
5202 9314
9453 7218
8059 5651
9338 5942
9733 6382
7679 7868
8931 9250
6157 9865
8396 8619
6492 9177
5283 8734
...

result:

ok Accepted with 2225+9998 operations,sum of size(s)=2463+4450

Test #83:

score: 27
Accepted
time: 973ms
memory: 6968kb

input:

9
55817321
15000 10000 200000 50000
5000
1304134662 1304137877
4197466605 4197473870
3162827674 3162830057
741742835 741739475
2858391371 2858385511
3780001353 3779989619
3359702465 3359688510
3231387076 3231389835
3542793473 3542789123
3066772403 3066766651
1875041823 1875040807
2534345455 25343430...

output:

Succeeded
9073 10000 31727 25351
324 2981
5744 8638
7812 8287
9326 8402
3729 1661
6499 8049
384 9536
3636 7854
8761 4673
9603 4542
3370 9513
231 7286
1203 1726
2335 2500
1178 6756
455 5522
4014 5423
701 2481
4751 8836
9322 3876
6174 299
7438 1794
3396 1101
5070 929
9105 5435
6550 1275
662 417
3533 8...

result:

ok Accepted with 9073+10000 operations,sum of size(s)=31727+25351

Test #84:

score: 27
Accepted
time: 1050ms
memory: 6900kb

input:

9
166393219
15000 10000 200000 50000
5000
2387124620 2387130367
1192773320 1192773098
2763055432 2763061802
849111984 849112355
1635031749 1635029798
1336542382 1336548437
3125990946 3125991620
4042871186 4042867438
4013879184 4013872960
149886626 149896462
354019436 354022814
3062987676 3062987592
...

output:

Succeeded
9358 10000 43057 32667
2313 9092
3647 1760
287 9635
2273 4731
4313 4268
672 7287
5305 7128
7511 5596
3335 3692
757 2233
4028 3872
4526 8017
697 5571
3623 8802
5719 3285
2904 6339
2134 9278
8005 2340
9500 9296
6452 2621
7068 8329
9507 3778
4725 3378
5432 3731
6171 1662
691 1613
2795 1925
15...

result:

ok Accepted with 9358+10000 operations,sum of size(s)=43057+32667

Test #85:

score: 27
Accepted
time: 217ms
memory: 7056kb

input:

9
2023272264
15000 10000 200000 50000
4999
2666862814 2666858610
1075110989 1075112993
1120588648 1120591355
462044663 462038416
1789207962 1789200130
1044379505 1044378584
4181242805 4181236060
3740541105 3740536540
7426000 7423251
240646227 240645680
3295646628 3295657806
1238719994 1238717232
193...

output:

Succeeded
3159 9998 21171 17439
3411 5161
9568 939
3598 5252
9403 4220
6472 5835
9761 3004
4478 7214
3733 3279
4350 2596
8696 6615
6122 1380
8092 1484
7534 9547
4112 7083
3669 3063
6598 9657
1488 6066
6802 9360
4423 7844
576 801
8350 5211
6387 2913
5869 4670
859 9871
2622 7923
2569 7380
5629 1737
70...

result:

ok Accepted with 3159+9998 operations,sum of size(s)=21171+17439

Test #86:

score: 27
Accepted
time: 168ms
memory: 6892kb

input:

9
1001789557
15000 10000 200000 50000
4999
2993900768 2993911387
4242927042 4242918648
1614558285 1614557906
1742595076 1742601302
2633784494 2633782949
58049529 58063585
1839417549 1839422075
3641885886 3641888995
4222704415 4222712528
2367129381 2367134322
801863126 801860103
3597714353 3597717099...

output:

Succeeded
2893 9998 20688 18902
584 7751
9781 8547
1913 7434
5332 358
4762 359
1028 3840
1244 4846
1990 4118
2323 5452
4951 2173
9162 4196
2440 7167
7140 2579
9971 1649
8168 874
8788 8268
9439 3163
333 8543
7785 636
1331 9224
932 4817
3585 8676
6890 6773
504 7967
44 8421
4358 7566
3495 4466
4513 725...

result:

ok Accepted with 2893+9998 operations,sum of size(s)=20688+18902

Test #87:

score: 27
Accepted
time: 217ms
memory: 6884kb

input:

9
157768064
15000 10000 200000 50000
5000
204641424 204643667
2330684444 2330678743
3612500362 3612500228
1025583801 1025581548
2577252381 2577258890
2861460971 2861463883
4223297569 4223295680
2356891898 2356892082
51639631 51640704
1628181782 1628184093
1087309069 1087308835
1500980657 1500981495
...

output:

Succeeded
3350 10000 25440 18548
2517 8345
4452 3519
9426 8079
6856 7291
3539 1491
3850 6469
6965 9662
6554 7431
693 2794
1444 6893
5156 9249
6627 8082
3257 9222
8002 418
2980 6992
8096 1682
9121 9461
667 3354
5588 3837
3197 396
3879 5610
8682 375
687 3880
1358 2533
3922 8506
4675 5651
8895 98
2084 ...

result:

ok Accepted with 3350+10000 operations,sum of size(s)=25440+18548

Test #88:

score: 27
Accepted
time: 1464ms
memory: 6808kb

input:

9
1910293975
15000 10000 200000 50000
4998
289267748 289275041
917858779 917848068
3774441477 3774431277
4281286892 4281290209
450881121 450874816
1097210834 1097204019
1841904834 1841900810
3560440391 3560441328
1399494562 1399493396
1040535764 1040544860
4266745616 4266747425
877486823 877493892
3...

output:

Succeeded
7636 9996 56178 46847
5556 127
7847 9407
7750 9792
9138 4438
4259 2298
2627 4201
3663 6454
2959 4354
944 3578
7678 9731
1272 5892
7163 5193
4442 4658
29 5617
2889 5446
4692 2094
9760 4395
9934 9565
1089 7826
4528 4215
8905 4086
6586 7421
8185 9427
9211 6554
3165 2783
337 4846
863 5591
7905...

result:

ok Accepted with 7636+9996 operations,sum of size(s)=56178+46847

Test #89:

score: 27
Accepted
time: 604ms
memory: 6772kb

input:

9
1476673980
15000 10000 200000 50000
4999
387974521 387973579
4090605526 4090609432
2305798928 2305786545
2755224288 2755219131
590807156 590807358
1167115818 1167121758
4152334467 4152334979
412444727 412439395
171000664 171001218
1280685725 1280677572
3324105669 3324108253
35221841 35222123
10981...

output:

Succeeded
6151 9998 36753 26710
1182 4767
6232 4633
9139 4339
1957 7506
9175 7125
6160 4561
8560 9712
9011 6892
8952 8208
6549 2311
9564 3821
4238 3140
7295 635
6803 4433
3069 8949
1204 3281
9678 920
7354 9370
8486 379
5973 5198
3286 7600
7202 2679
6159 9226
9587 9733
2547 9573
1018 5838
9341 159
11...

result:

ok Accepted with 6151+9998 operations,sum of size(s)=36753+26710

Test #90:

score: 27
Accepted
time: 478ms
memory: 7084kb

input:

9
1290433813
15000 10000 200000 50000
4999
1479888307 1479891394
1589882388 1589877104
2251585022 2251581967
1090204205 1090203067
1606578815 1606575870
2804677664 2804675931
1108827585 1108828115
16271055 16274494
535723581 535713922
3804488080 3804481840
3120837039 3120834633
4202384962 4202386665...

output:

Succeeded
5588 9998 30327 21633
7120 3800
5911 9469
5385 7947
1416 4872
301 6561
6724 2772
8269 4207
724 284
3213 288
1703 8912
140 4899
3062 1619
9694 9024
5639 9931
1447 4221
5005 9629
1096 6093
1382 8815
682 2285
9676 2316
4477 56
3149 419
6078 5138
1328 1248
7375 3767
4114 9800
4085 840
8400 463...

result:

ok Accepted with 5588+9998 operations,sum of size(s)=30327+21633

Test #91:

score: 27
Accepted
time: 447ms
memory: 7124kb

input:

9
18492853
15000 10000 200000 50000
5000
3666252811 3666249178
2329759832 2329770906
3517440155 3517433545
3854207928 3854206022
1387919291 1387920350
92486749 92482246
3042030069 3042033096
527999494 528005339
4036989518 4036991482
3817762306 3817759620
2463154564 2463160508
3355628429 3355630454
3...

output:

Succeeded
5196 10000 28596 20780
5122 1443
3696 9014
2514 9498
9623 5867
9989 3688
3211 2146
533 5016
5504 587
4356 6837
8840 9829
1708 4320
1843 8683
8871 4304
3559 9507
4819 8069
4779 6057
642 2453
42 1300
7621 6540
2117 7793
7419 5818
2020 4376
2032 9889
5830 3853
4448 7573
851 9552
3093 7497
160...

result:

ok Accepted with 5196+10000 operations,sum of size(s)=28596+20780

Test #92:

score: 27
Accepted
time: 471ms
memory: 6928kb

input:

9
1308257742
15000 10000 200000 50000
4998
381070829 381068229
3231736638 3231742571
3564816540 3564818117
1534880820 1534878996
885304089 885297721
2902010232 2902003866
871072211 871078795
1322721005 1322719399
2493768993 2493768974
14560875 14556154
453293899 453292378
2079160779 2079161603
10489...

output:

Succeeded
4162 9996 44669 22877
1695 4423
3650 94
2020 3950
4519 759
1199 2162
695 175
3976 5
1165 1556
3257 628
106 1634
2265 2706
3184 3289
961 947
1203 2014
2024 3996
1427 4888
4067 1559
3686 4384
3045 3692
1463 982
1397 749
3783 4246
3437 3262
4106 4226
4021 343
3983 2729
2279 980
526 622
1604 1...

result:

ok Accepted with 4162+9996 operations,sum of size(s)=44669+22877

Test #93:

score: 27
Accepted
time: 472ms
memory: 7008kb

input:

9
652929959
15000 10000 200000 50000
5000
3847044414 3847043757
1285945202 1285943482
3636482240 3636483345
3221986728 3221984915
3250269937 3250266824
4130003768 4130001192
859846378 859841806
1528689337 1528691651
949713237 949714931
736092342 736092036
1349545195 1349549994
1579408136 1579407469
...

output:

Succeeded
4226 10000 44315 22363
4732 3512
2385 2852
1187 4491
236 3669
1808 2239
2865 3824
266 4968
3793 1411
1216 2186
3093 2331
4522 4699
114 4091
1465 2261
3576 4092
1842 4349
463 1477
1495 507
1148 4309
1135 2850
4380 4339
1793 3987
4473 1652
3367 355
1480 4372
1801 626
3999 3265
4106 1064
2197...

result:

ok Accepted with 4226+10000 operations,sum of size(s)=44315+22363

Test #94:

score: 27
Accepted
time: 707ms
memory: 6856kb

input:

9
1409095588
15000 10000 200000 50000
4999
2945476315 2945474205
1573210229 1573213827
3850914021 3850917784
1423218803 1423213630
3465224232 3465227635
536020865 536030466
3782418736 3782419950
3487214117 3487217625
884504075 884505793
2736159505 2736154116
3239596796 3239604934
3807432148 38074355...

output:

Succeeded
7768 9998 85433 42495
1969 5358
891 5844
435 6646
320 6003
2635 6096
2756 8273
2596 6124
2269 7306
763 9348
213 6360
8776 1522
4545 9985
2167 6325
2525 6996
5949 1115
951 6774
245 7599
2017 8892
3372 8331
3746 8584
4644 5886
4840 5436
7883 3618
989 7840
4066 7574
2514 5610
1918 9952
2720 6...

result:

ok Accepted with 7768+9998 operations,sum of size(s)=85433+42495

Test #95:

score: 27
Accepted
time: 702ms
memory: 6836kb

input:

9
642285867
15000 10000 200000 50000
5000
1271535928 1271529857
851118377 851123039
1707021255 1707032052
3532556861 3532570332
2212001695 2211998387
4163719159 4163726444
4252859744 4252854313
1384229157 1384230193
45363269 45364808
1415840536 1415844188
3628024026 3628031329
3742090293 3742096965
...

output:

Succeeded
7758 10000 86356 42906
404 9255
3592 6760
4099 5721
192 6573
969 2406
4002 7920
7045 3011
6361 1080
2893 7070
2828 2411
7363 3019
3570 6068
4678 5702
3232 9939
9160 4749
8653 7456
1030 8432
3244 9854
3785 9906
1044 7427
2966 8595
3099 9188
2028 5894
2267 5188
2574 6914
4937 7030
360 7344
2...

result:

ok Accepted with 7758+10000 operations,sum of size(s)=86356+42906