QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#369062#7791. 通道建设 Passage ConstructionNATURAL6100 ✓403ms8480kbC++174.3kb2024-03-27 20:08:442024-03-27 20:08:45

Judging History

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

  • [2024-03-27 20:08:45]
  • 评测
  • 测评结果:100
  • 用时:403ms
  • 内存:8480kb
  • [2024-03-27 20:08:44]
  • 提交

answer

#include <bits/stdc++.h>
#include "passageconstruction.h"
using namespace std;
int n,dep[10010],mdep,dfn[10010],tot,fa[14][10010],siz[20010];
int node_siz,edge_siz,id[10010],nowdep,vis[20010],msiz,eid,eU,eV;
vector<int>S[10010],e[10010],E[10010],lst;
vector< pair<int,int> >ans,se[20010];
inline void adde(int x,int y)
{
	e[x].emplace_back(y);
	fa[0][y]=x;
	for(int i=1;i<14;++i)fa[i][y]=fa[i-1][fa[i-1][y]];
	return ;
}
inline int get_lca(int x,int y)
{
	if(x==y)return x;
	if(dep[x]<dep[y])swap(x,y);
	for(int i=13;~i;--i)while(dep[fa[i][x]]>=dep[y])x=fa[i][x];
	if(x==y)return x;
	for(int i=13;~i;--i)while(fa[i][x]^fa[i][y])x=fa[i][x],y=fa[i][y];
	return fa[0][x];
}
inline void dfs(int rt)//求 dfs 序
{
	dfn[rt]=++tot;
	for(int i:e[rt])dfs(i);
	return ;
}
inline bool cmp(int x,int y){return dfn[x]<dfn[y];}
inline int build(vector<int>S)
{
	sort(S.begin(),S.end(),cmp);
	for(int i=(int)S.size()-1;i;--i)S.emplace_back(get_lca(S[i],S[i-1]));
	sort(S.begin(),S.end(),cmp);S.resize(unique(S.begin(),S.end())-S.begin());
	for(int i=1;i<(int)S.size();++i)E[get_lca(S[i],S[i-1])].emplace_back(S[i]);
	lst=S;
	return S[0];
}
inline int dfss(int rt,int da)// 三度化
{
	if(E[rt].empty())return id[++node_siz]=rt,node_siz;
	if(E[rt].size()==1)
	{
		int U=++node_siz,V=dfss(E[rt][0],rt);
		id[U]=rt;++edge_siz;
		se[U].emplace_back(make_pair(V,edge_siz));
		se[V].emplace_back(make_pair(U,edge_siz));
		return U;
	}
	else
	{
		int V=dfss(E[rt].back(),rt);
		for(int i=E[rt].size()-2;~i;--i)
		{
			int rot=++node_siz,U=dfss(E[rt][i],rt);
			++edge_siz;
			se[rot].emplace_back(make_pair(U,edge_siz));
			se[U].emplace_back(make_pair(rot,edge_siz));
			++edge_siz;
			se[rot].emplace_back(make_pair(V,edge_siz));
			se[V].emplace_back(make_pair(rot,edge_siz));
			V=rot;id[rot]=rt;
		}
		return V;
	}
	return 0;
}
inline int get_id(int rt,int da)
{
	if(dep[id[rt]]==nowdep)return id[rt];
	int an=0;
	for(pair<int,int>i:se[rt])
	{
		if(i.first==da||vis[i.second])continue;
		an|=get_id(i.first,rt);
	}
	return an;
}
inline void findroot(int rt,int da,int SZ)
{
	if(dep[id[rt]]==nowdep)siz[rt]=1;
	else siz[rt]=0;
	for(pair<int,int>i:se[rt])
	{
		if(i.first==da||vis[i.second])continue;
		findroot(i.first,rt,SZ);siz[rt]+=siz[i.first];
		if(msiz>max(siz[i.first],SZ-siz[i.first]))msiz=max(siz[i.first],SZ-siz[i.first]),eU=rt,eV=i.first,eid=i.second;
	}
	return ;
}
inline int dfssss(int rt,int da)// 求 siz
{
	int an=(dep[id[rt]]==nowdep);
	for(pair<int,int>i:se[rt])
	{
		if(i.first==da||vis[i.second])continue;
		an+=dfssss(i.first,rt);
	}
	return an;
}
inline void dfsssss(int rt,int da,vector<int>&S,int rot)// 求点集
{
	if(id[rt]^rot)return S.emplace_back(id[rt]),void();
	for(pair<int,int>i:se[rt])
	{
		if(i.first==da||vis[i.second])continue;
		dfsssss(i.first,rt,S,rot);
	}
	return ;
}
inline void dfz(int rt,int SZ,vector<int>nodeset)
{
	if(!SZ||nodeset.empty())return ;
	if(SZ==1)
	{
		int ID=get_id(rt,0);
		for(int i:nodeset)adde(ID,i);
		return ;
	}
	msiz=SZ+1;
	findroot(rt,0,SZ);
	vector<int>res,B,toU,toV;B.emplace_back(id[eU]);
	dfsssss(eV,eU,B,id[eU]);
	int sizU=dfssss(eU,eV),sizV=dfssss(eV,eU);
	vis[eid]=1;
	if(B.size()==1)res.resize(nodeset.size(),1);
	else res=QueryLCA(nodeset,B,id[eU]);
	for(int i=0;i<(int)nodeset.size();++i)
	{
		if(res[i])toU.emplace_back(nodeset[i]);
		else toV.emplace_back(nodeset[i]);
	}
	int eeU=eU,eeV=eV;
	dfz(eeU,sizU,toU);dfz(eeV,sizV,toV);
	return ;
}
inline void solve(int D)
{
	for(int i:lst)E[i].clear();
	for(int i=1;i<=node_siz;++i)se[i].clear();
	memset(vis,0,(edge_siz+1)<<2);
	node_siz=edge_siz=0;nowdep=D-1;
	int rot=build(S[D-1]);
	rot=dfss(rot,0);
	dfz(rot,node_siz,S[D]);
	tot=0;dfs(1);
	return ;
}
inline int dfsss(int rt)// 求匹配
{
	int son=0;
	for(int i:e[rt])
	{
		int p=dfsss(i);
		if(p)
		{
			if(son)
			{
				ans.emplace_back(make_pair(p,son));
				son=0;
			}
			else son=p;
		}
	}
	if(son)
	{
		ans.emplace_back(make_pair(rt,son));
		son=0;
	}
	else son=rt;
	return son;
}
vector< pair<int,int> >ConstructPassages(int N,const vector< pair<int,int> >&E)
{
	n=N;dep[0]=-1;
	for(int i=2;i<=(n<<1);++i)
	{
		S[dep[i]=GetDistance(1,i)].emplace_back(i);
		mdep=max(mdep,dep[i]);
	}
	S[0].emplace_back(1);dfn[1]=tot=1;
	for(int i=1;i<=mdep;++i)solve(i);
	dfsss(1);
	return ans;
}

詳細信息

Subtask #1:

score: 3
Accepted

Test #1:

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

input:

1
1872884041
100 100 10000 10000
1
2294931821 2294931820

output:

Succeeded
0 1 0 0
1 2

result:

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

Test #2:

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

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
5 9 11 11
7 4
6 2
3 8
5 9
1 10

result:

ok Accepted with 5+9 operations,sum of size(s)=11+11

Test #3:

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

input:

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

output:

Succeeded
0 3 0 0
2 4
1 3

result:

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

Test #4:

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

input:

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

output:

Succeeded
1 5 1 2
2 3
6 4
1 5

result:

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

Test #5:

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

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 7 3 4
2 5
3 7
4 8
1 6

result:

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

Test #6:

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

input:

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

output:

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

result:

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

Test #7:

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

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 9 7 13
3 2
5 8
6 9
7 4
1 10

result:

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

Test #8:

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

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 9 12 11
10 7
5 3
9 8
4 2
1 6

result:

ok Accepted with 4+9 operations,sum of size(s)=12+11

Test #9:

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

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 9 6 6
9 7
5 8
6 10
2 3
1 4

result:

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

Test #10:

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

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 9 6 9
2 6
3 9
10 7
8 4
1 5

result:

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

Subtask #2:

score: 6
Accepted

Test #11:

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

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
160 199 945 366
13 71
20 76
163 57
18 170
2 16
174 127
60 9
45 28
58 88
17 133
82 29
59 27
122 64
47 41
54 37
131 62
90 93
114 44
134 85
150 124
166 158
22 116
119 14
87 142
46 69
99 56
42 15
8 193
19 195
78 61
95 164
77 32
182 98
49 50
91 180
115 181
189 25
194 5
84 51
143 172
160 185
186...

result:

ok Accepted with 160+199 operations,sum of size(s)=945+366

Test #12:

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

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
157 195 998 363
192 90
108 112
64 44
117 29
116 31
147 80
194 26
32 163
171 4
62 18
73 30
187 40
121 81
98 2
169 111
176 145
56 10
48 57
47 71
51 22
127 131
182 93
104 161
19 85
190 102
189 83
100 59
109 76
188 20
79 7
54 35
125 77
75 9
152 158
58 135
183 132
67 142
118 21
134 24
164 155
1...

result:

ok Accepted with 157+195 operations,sum of size(s)=998+363

Test #13:

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

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
143 197 957 350
121 73
17 74
48 180
49 35
116 195
161 148
168 51
92 16
98 26
136 56
21 190
94 43
54 6
152 153
107 112
162 111
125 101
196 193
173 123
149 104
71 81
144 103
169 170
91 65
177 176
108 75
52 110
174 102
70 194
124 120
160 166
159 155
109 105
142 106
189 146
57 158
150 178
167 ...

result:

ok Accepted with 143+197 operations,sum of size(s)=957+350

Test #14:

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

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
150 197 931 363
103 56
102 101
120 161
182 111
134 133
112 117
118 105
140 132
119 109
145 125
30 178
22 194
108 92
77 153
36 6
177 17
196 27
72 59
80 32
5 184
139 137
149 51
162 126
195 3
78 73
15 35
113 26
160 129
60 39
57 53
189 151
82 146
180 148
21 47
71 29
90 8
88 198
116 79
98 34
17...

result:

ok Accepted with 150+197 operations,sum of size(s)=931+363

Test #15:

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

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
155 199 970 368
59 19
186 102
63 193
51 9
184 124
39 58
69 37
79 142
54 42
49 40
76 11
66 34
118 113
168 153
119 181
129 116
147 190
130 173
121 106
200 160
138 144
120 101
136 175
164 140
91 189
137 185
155 22
158 126
187 183
146 115
166 125
198 103
143 105
18 191
117 57
12 35
156 55
46 2...

result:

ok Accepted with 155+199 operations,sum of size(s)=970+368

Test #16:

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

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
161 199 943 371
38 8
105 94
160 134
152 76
52 147
149 132
17 156
82 45
11 200
131 36
91 140
130 117
115 183
100 41
54 18
194 133
158 56
26 168
107 198
159 199
127 145
167 114
182 150
10 195
110 179
120 174
184 124
88 42
68 58
95 137
22 74
29 3
87 196
104 27
62 39
57 176
31 19
154 192
49 64...

result:

ok Accepted with 161+199 operations,sum of size(s)=943+371

Test #17:

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

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 193 834 354
49 62
91 44
123 58
82 159
125 48
153 25
57 184
31 122
176 10
39 30
54 98
135 40
43 72
28 182
75 63
117 29
115 97
142 183
179 85
144 16
73 101
76 148
138 112
189 79
87 77
127 17
18 21
32 99
145 94
36 109
96 9
136 132
46 141
155 100
165 118
193 160
45 174
164 88
163 102
172 1...

result:

ok Accepted with 151+193 operations,sum of size(s)=834+354

Test #18:

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

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
150 195 873 363
44 130
49 24
136 20
10 146
135 102
117 60
147 30
111 76
142 141
148 7
17 97
129 103
11 19
28 25
84 121
50 18
176 87
55 78
4 159
31 2
83 23
64 112
33 5
144 158
77 9
93 16
152 184
12 194
171 63
26 172
186 101
95 92
119 110
75 175
100 157
36 21
190 185
67 14
89 81
39 8
51 6
65...

result:

ok Accepted with 150+195 operations,sum of size(s)=873+363

Subtask #3:

score: 8
Accepted

Test #19:

score: 8
Accepted
time: 14ms
memory: 6804kb

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
544 1999 1087 1088
1366 1855
1773 1563
1969 1275
1368 1313
1107 1409
1643 1727
1134 1837
1844 1600
1677 1114
1610 1937
1122 1588
1630 1298
1829 1755
1561 1178
1852 1357
1347 1394
1751 1054
1806 1887
1164 1266
1868 1579
1824 1609
1613 1276
1697 1078
1272 1866
1009 1554
1477 1223
1462 1214
1...

result:

ok Accepted with 544+1999 operations,sum of size(s)=1087+1088

Test #20:

score: 8
Accepted
time: 16ms
memory: 6080kb

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
56 1997 111 112
346 728
1690 13
468 49
745 103
897 485
86 149
82 913
735 826
408 750
83 41
202 365
124 414
301 1200
283 843
694 77
156 266
789 840
767 1764
878 938
959 618
90 1564
249 20
275 51
396 994
585 1144
732 429
692 85
234 665
739 380
1630 969
449 626
884 132
558 583
1634 660
344 50...

result:

ok Accepted with 56+1997 operations,sum of size(s)=111+112

Test #21:

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

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
704 1995 1407 1408
1749 1325
1332 1702
1225 1114
1397 1984
1307 1723
1658 1737
1813 1495
1838 1051
1067 1316
1696 1922
1946 1402
1363 1355
1208 1886
1539 1247
1505 1072
1624 1700
1436 1499
1268 1498
1326 1759
1857 1659
1920 1293
1242 1651
1311 1523
1687 1751
1347 1336
1021 1810
1147 1366
1...

result:

ok Accepted with 704+1995 operations,sum of size(s)=1407+1408

Test #22:

score: 8
Accepted
time: 17ms
memory: 6828kb

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
220 1995 439 440
345 1767
528 262
38 580
910 1719
226 1612
1016 1391
719 1557
130 431
941 1537
322 1894
1024 1572
1082 1713
697 1539
1712 846
1898 1100
1595 293
1512 1970
685 119
1521 748
245 282
419 551
1688 1301
774 857
1177 488
1558 1854
1579 1950
576 1136
219 1600
1643 760
887 167
1762...

result:

ok Accepted with 220+1995 operations,sum of size(s)=439+440

Test #23:

score: 8
Accepted
time: 16ms
memory: 6504kb

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
281 1999 561 562
1276 1367
489 340
602 1496
21 783
1715 1597
1344 994
11 298
1003 1693
643 1737
268 709
237 552
1391 1974
878 1055
796 852
371 1345
1289 209
164 813
1499 1840
1936 1960
1188 357
1491 137
873 1488
537 279
151 724
696 1950
521 291
1920 424
260 1798
711 1166
1638 1429
280 53
1...

result:

ok Accepted with 281+1999 operations,sum of size(s)=561+562

Test #24:

score: 8
Accepted
time: 15ms
memory: 6108kb

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

result:

ok Accepted with 420+1997 operations,sum of size(s)=839+840

Test #25:

score: 8
Accepted
time: 15ms
memory: 5756kb

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
22 1995 43 44
874 702
412 78
608 551
662 661
473 1099
406 745
447 1850
481 28
714 746
511 411
317 738
582 949
1464 825
664 890
407 670
674 358
423 445
808 534
1963 327
360 549
219 878
860 851
665 623
533 419
141 1161
59 356
575 244
232 986
384 726
1373 127
364 915
353 806
463 654
333 785
1...

result:

ok Accepted with 22+1995 operations,sum of size(s)=43+44

Test #26:

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

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
741 1997 1481 1482
436 233
112 55
125 711
394 874
462 419
1792 171
552 184
927 271
160 608
764 470
611 397
705 165
172 819
174 978
633 153
57 937
482 128
508 971
894 940
34 1740
314 835
261 720
801 868
751 322
628 816
717 1659
961 325
51 590
760 203
339 623
9 1905
447 120
375 181
575 880
2...

result:

ok Accepted with 741+1997 operations,sum of size(s)=1481+1482

Test #27:

score: 8
Accepted
time: 16ms
memory: 6080kb

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
180 1997 359 360
426 569
954 125
1700 850
692 743
417 195
1125 668
971 962
270 563
421 865
285 655
989 772
467 525
348 317
122 412
59 1665
633 73
62 527
671 709
558 157
156 402
918 910
886 707
799 225
613 410
738 737
115 472
795 321
159 777
263 134
362 963
388 1175
166 985
301 409
193 407
...

result:

ok Accepted with 180+1997 operations,sum of size(s)=359+360

Test #28:

score: 8
Accepted
time: 16ms
memory: 6128kb

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
349 1999 697 698
272 707
532 433
503 900
769 486
508 264
1196 252
696 108
874 656
755 924
878 1299
439 307
17 717
89 531
247 392
987 233
719 314
47 79
660 217
151 784
669 713
615 187
73 783
633 941
908 356
789 880
378 722
26 971
241 326
69 352
683 584
1202 330
708 1729
139 447
435 760
538 ...

result:

ok Accepted with 349+1999 operations,sum of size(s)=697+698

Subtask #4:

score: 9
Accepted

Test #29:

score: 9
Accepted
time: 5ms
memory: 5708kb

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
1751 1999 14468 3502
1936 1764
1009 1868
1354 1171
1367 1464
1114 1297
1487 745
707 412
1363 1053
1918 1798
572 973
123 101
277 795
709 258
104 1530
621 1646
347 964
1981 1458
1538 1739
1819 1130
896 1011
230 508
653 1339
647 539
815 478
775 1493
344 884
962 1110
849 1568
669 71
518 59
422...

result:

ok Accepted with 1751+1999 operations,sum of size(s)=14468+3502

Test #30:

score: 9
Accepted
time: 5ms
memory: 6540kb

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
1893 1999 10339 3786
1696 1532
1782 1693
1602 1584
1783 1153
1771 1364
1781 1784
1691 1059
1819 1609
1854 1561
1069 1031
1276 1846
1574 1254
1484 1479
1040 1708
1393 1093
1845 1680
1164 1414
1646 1523
1622 1296
1458 1480
1874 1348
847 578
809 340
365 800
687 108
981 725
728 590
343 924
72 ...

result:

ok Accepted with 1893+1999 operations,sum of size(s)=10339+3786

Test #31:

score: 9
Accepted
time: 2ms
memory: 6504kb

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
1736 1995 13868 3473
1501 1091
1634 1311
1749 1329
984 718
1745 1479
146 131
298 1864
1847 1146
1802 1510
321 915
1013 1032
430 1561
747 40
1730 1617
55 1148
560 1036
681 90
692 589
1709 1751
998 1371
72 1614
1653 1816
1086 1757
402 49
1443 1687
1679 1968
464 1189
330 266
697 1462
1901 123...

result:

ok Accepted with 1736+1995 operations,sum of size(s)=13868+3473

Test #32:

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

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
1746 1995 15645 3492
17 289
561 1728
1626 1762
1099 1444
1944 1883
864 1575
1935 1789
239 114
1185 1718
342 1804
1166 1654
1532 1757
915 1223
849 1529
1670 1965
1466 1587
1391 1888
468 419
1194 1422
991 1617
698 988
657 574
376 404
89 11
1599 1372
242 1433
1994 1216
189 1060
473 588
408 65...

result:

ok Accepted with 1746+1995 operations,sum of size(s)=15645+3492

Test #33:

score: 9
Accepted
time: 5ms
memory: 6528kb

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
1720 1995 14821 3442
13 212
1598 1950
218 552
1986 1320
1086 1568
577 1824
1728 1720
1620 643
593 533
650 1866
683 10
159 5
1133 1246
1852 437
1856 1386
705 213
1964 1496
1354 1606
1221 1138
148 1463
1599 1306
150 957
53 985
1452 1206
1694 1446
623 1451
562 336
55 882
1749 611
192 751
449 ...

result:

ok Accepted with 1720+1995 operations,sum of size(s)=14821+3442

Test #34:

score: 9
Accepted
time: 2ms
memory: 6540kb

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
1709 1999 16299 3419
92 1930
1919 1761
1284 1177
1701 1046
931 424
855 165
807 257
1334 1230
552 318
1840 1101
1622 1434
1406 1069
1746 1029
1262 1049
1990 1366
1841 1102
853 410
557 475
604 249
1571 1184
23 1893
382 280
1875 1826
1704 1090
1484 1858
1820 1303
477 1895
646 119
1784 1708
18...

result:

ok Accepted with 1709+1999 operations,sum of size(s)=16299+3419

Test #35:

score: 9
Accepted
time: 5ms
memory: 6572kb

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
1713 1999 16199 3427
1814 1796
246 138
1753 1245
1464 1409
1931 1262
292 1191
609 225
170 1790
348 1356
554 635
1733 1147
1322 1420
1355 1902
1962 1389
1887 1285
935 199
1650 1553
1581 1168
1379 1481
1661 1319
335 1739
820 1120
421 212
80 715
1535 1402
986 1468
260 615
614 1442
541 115
224...

result:

ok Accepted with 1713+1999 operations,sum of size(s)=16199+3427

Test #36:

score: 9
Accepted
time: 4ms
memory: 6488kb

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
1706 1999 16370 3414
946 119
1941 1364
637 1845
1683 1990
977 969
386 202
1258 1008
1727 1583
1817 1797
1949 1155
926 830
95 1960
790 1529
491 341
1271 1420
554 240
1601 1113
696 540
998 826
955 2
1902 1306
529 503
1801 1243
1826 1688
440 1192
922 1668
894 530
1719 1017
805 294
1513 1999
9...

result:

ok Accepted with 1706+1999 operations,sum of size(s)=16370+3414

Test #37:

score: 9
Accepted
time: 7ms
memory: 5840kb

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
1248 1999 3203 2496
629 1515
128 1659
146 1079
148 861
357 1734
438 1465
1720 1236
1357 1375
950 609
1880 1806
1210 250
1144 1749
1514 759
1699 198
1417 351
1291 1431
445 665
1434 1820
1222 1837
1519 531
939 794
1597 1044
1414 59
314 508
1800 1910
404 1617
365 26
769 1277
920 539
1234 1703...

result:

ok Accepted with 1248+1999 operations,sum of size(s)=3203+2496

Test #38:

score: 9
Accepted
time: 3ms
memory: 5644kb

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
1290 1995 3396 2582
1444 1064
1368 1820
502 1996
1398 1795
29 1481
1661 1136
1563 1474
1586 1571
582 1760
1153 1113
661 855
561 1193
624 999
299 1098
254 464
1625 1049
1898 1736
771 792
285 346
1888 1047
207 444
291 382
568 424
1291 215
1085 1572
721 492
691 1521
925 816
891 91
784 1017
18...

result:

ok Accepted with 1290+1995 operations,sum of size(s)=3396+2582

Subtask #5:

score: 11
Accepted

Test #39:

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

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
1750 1995 15102 3500
1603 463
656 296
971 1774
1699 986
1965 864
825 1946
1526 627
1403 1953
1003 1056
238 786
1605 1100
1610 902
1303 1277
1758 1470
1840 1620
764 1378
1401 566
529 717
716 213
1043 1745
993 792
696 369
1586 511
1353 15
914 672
948 4
1058 843
122 732
1142 1225
1219 947
593...

result:

ok Accepted with 1750+1995 operations,sum of size(s)=15102+3500

Test #40:

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

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
1855 1997 10165 3710
740 312
747 472
720 538
1056 34
90 1735
282 331
1775 1605
301 102
1024 31
414 322
1371 708
859 62
104 1063
1535 1662
1974 1238
1340 1513
488 346
341 1798
1184 1724
1674 1828
1069 907
568 1681
1767 1606
1514 285
1508 1269
274 70
1309 1474
1221 298
367 1088
103 1699
409 ...

result:

ok Accepted with 1855+1997 operations,sum of size(s)=10165+3710

Test #41:

score: 11
Accepted
time: 3ms
memory: 6028kb

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
1353 1999 3717 2706
1898 1387
432 1362
1697 98
1719 1779
203 1073
1274 1646
1359 666
1959 1914
1351 1328
220 1812
1307 1695
410 1875
1198 1058
660 664
265 544
768 1358
1651 1809
1587 1574
105 39
814 1290
108 1747
1320 1834
833 1319
1244 492
1980 313
510 323
613 769
629 289
527 1879
577 826...

result:

ok Accepted with 1353+1999 operations,sum of size(s)=3717+2706

Test #42:

score: 11
Accepted
time: 5ms
memory: 5752kb

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
1733 1997 15029 3467
1958 1062
1649 1189
792 1976
130 560
1223 1297
975 501
706 1305
632 1151
1619 739
189 1205
705 590
382 218
1079 844
1099 763
1604 78
996 968
1899 492
821 1067
1117 1640
1383 1493
1596 1342
1966 1761
1988 1464
1797 1700
1201 1817
891 1780
1198 1772
1534 1692
1910 1764
1...

result:

ok Accepted with 1733+1997 operations,sum of size(s)=15029+3467

Test #43:

score: 11
Accepted
time: 5ms
memory: 5836kb

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
1737 1997 14520 3474
167 1270
1947 402
1421 857
681 1862
1820 1631
620 914
1442 1816
1028 1174
155 171
1440 785
1173 11
126 1196
395 1135
1842 1247
958 875
1069 763
1961 1215
532 440
793 789
758 311
1690 1493
659 665
1224 64
1258 1387
842 287
455 416
1640 24
1630 173
912 378
1605 429
179 3...

result:

ok Accepted with 1737+1997 operations,sum of size(s)=14520+3474

Test #44:

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

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
1740 1999 14724 3481
935 33
1998 818
498 162
844 373
689 680
972 481
1013 1653
587 451
1367 292
551 531
922 275
867 35
669 1415
393 889
762 1862
1229 1001
1166 1391
1248 1272
729 722
177 446
870 224
995 1565
773 389
1507 348
845 1057
112 406
456 327
672 1086
576 174
372 477
948 89
800 1289...

result:

ok Accepted with 1740+1999 operations,sum of size(s)=14724+3481

Test #45:

score: 11
Accepted
time: 13ms
memory: 6580kb

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
737 1999 1473 1474
1095 1574
1281 1512
1140 1214
1248 1889
1695 1398
1976 1680
1564 1346
1874 1867
1712 1429
1578 1317
1623 1632
1501 1276
1032 1463
1903 1179
1542 1156
1866 1684
1122 1906
1831 1348
1663 1390
1561 1322
1777 1028
1170 1174
1981 1892
1059 1094
1407 1702
1188 1745
1533 1557
1...

result:

ok Accepted with 737+1999 operations,sum of size(s)=1473+1474

Test #46:

score: 11
Accepted
time: 15ms
memory: 6504kb

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
938 1997 1875 1876
254 1119
894 1348
115 140
1312 382
1018 1968
1662 1197
1153 1523
1773 1223
1100 407
1185 896
587 1752
1353 231
156 1281
130 1621
1292 333
1990 1593
1898 256
1565 688
1564 1286
86 1913
409 1317
1933 142
1884 512
1098 1649
749 742
437 1665
1924 288
997 422
1421 945
1605 14...

result:

ok Accepted with 938+1997 operations,sum of size(s)=1875+1876

Test #47:

score: 11
Accepted
time: 16ms
memory: 6532kb

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
17 1999 33 34
15 826
1642 722
588 700
383 170
63 827
480 622
87 245
392 894
893 777
354 1295
682 364
729 365
471 519
1905 780
586 528
306 806
937 246
872 410
264 96
548 183
786 376
317 229
415 19
982 860
116 986
808 598
745 418
862 212
201 214
854 581
497 730
393 422
483 458
571 635
204 16...

result:

ok Accepted with 17+1999 operations,sum of size(s)=33+34

Test #48:

score: 11
Accepted
time: 4ms
memory: 6512kb

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
1488 1999 13061 2984
1067 146
1574 102
1528 95
1387 927
1621 461
1638 439
1353 489
1043 328
1217 173
1358 536
1562 789
1987 677
1499 486
1594 831
1516 147
1154 23
1864 479
1686 476
1400 447
1886 50
1809 38
1009 445
1207 438
1373 675
1413 141
1025 652
1783 259
1695 814
1304 185
1522 125
121...

result:

ok Accepted with 1488+1999 operations,sum of size(s)=13061+2984

Test #49:

score: 11
Accepted
time: 4ms
memory: 5760kb

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
1485 1997 13109 2980
1137 730
1398 216
1007 56
1399 831
1695 452
1070 288
1331 573
1700 379
1966 727
1050 256
1612 986
1677 267
1199 408
1494 918
1342 243
1330 669
1712 302
1351 446
1367 748
1507 500
1871 677
1384 839
1536 125
1785 953
1760 713
1276 51
1433 430
1884 104
1992 604
1894 808
1...

result:

ok Accepted with 1485+1997 operations,sum of size(s)=13109+2980

Subtask #6:

score: 12
Accepted

Test #50:

score: 12
Accepted
time: 5ms
memory: 6020kb

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
1646 1995 15584 3888
277 353
557 1638
783 618
1680 1047
919 861
1184 1032
135 1973
1604 1041
294 766
1035 1970
1152 100
1925 416
366 176
1739 1020
1580 1590
468 1322
552 456
61 1105
872 1552
1405 1072
37 15
779 81
57 1845
1587 1064
1585 1791
659 1901
1927 1502
240 1602
26 75
1615 1364
400 ...

result:

ok Accepted with 1646+1995 operations,sum of size(s)=15584+3888

Test #51:

score: 12
Accepted
time: 2ms
memory: 6576kb

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
1627 1997 16125 3856
403 217
795 1215
475 962
1838 1614
1781 1498
1780 1711
354 89
698 1705
507 1317
1850 1560
972 1758
47 111
1604 1697
260 1059
1542 298
883 29
373 1691
1703 1280
736 664
1381 1584
1786 1035
952 102
802 199
981 1332
203 1585
319 1823
500 856
79 1884
633 1669
455 1192
1177...

result:

ok Accepted with 1627+1997 operations,sum of size(s)=16125+3856

Test #52:

score: 12
Accepted
time: 5ms
memory: 5732kb

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
1190 1999 10352 3497
104 34
156 146
227 168
267 250
310 299
468 387
1055 1034
1117 1082
1186 1134
1215 1206
1178 1069
1248 1197
1313 1299
1350 1322
1454 1376
1625 1611
1754 1731
1893 1794
1237 1980
1288 1221
1418 1401
1474 1436
1542 1485
1573 1563
1608 1578
1670 1643
1705 1696
1724 1721
17...

result:

ok Accepted with 1190+1999 operations,sum of size(s)=10352+3497

Test #53:

score: 12
Accepted
time: 5ms
memory: 5980kb

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
1092 1997 9032 3437
18 3
109 44
156 106
1054 1612
1629 1019
1772 1101
1320 1496
1888 1861
1556 1237
1024 1140
1886 1686
1308 1919
1402 1257
1485 1302
1666 1880
1949 1291
1965 1181
857 395
168 164
174 695
240 185
268 250
301 273
361 354
718 427
651 595
798 655
621 543
244 570
490 127
604 71...

result:

ok Accepted with 1092+1997 operations,sum of size(s)=9032+3437

Test #54:

score: 12
Accepted
time: 5ms
memory: 6024kb

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
1098 1995 10284 3564
703 656
219 619
677 62
220 131
272 250
379 292
401 400
551 421
37 10
86 54
112 92
1117 1055
1239 1202
1424 1352
1284 1904
1647 1483
1001 1855
1908 1926
1464 1385
1549 1691
1596 1682
1466 1477
1158 1832
1510 1043
1718 1588
1799 1772
1927 1818
1987 1933
1789 1882
1639 16...

result:

ok Accepted with 1098+1995 operations,sum of size(s)=10284+3564

Test #55:

score: 12
Accepted
time: 4ms
memory: 6696kb

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
956 1999 8319 3307
730 396
132 685
480 250
695 762
558 927
940 339
218 85
598 110
522 270
46 942
840 917
677 841
391 899
371 629
425 50
461 980
805 329
446 113
675 128
320 989
662 123
610 682
516 918
963 933
532 32
337 709
137 670
165 964
207 138
706 549
851 419
577 360
122 7
322 210
556 5...

result:

ok Accepted with 956+1999 operations,sum of size(s)=8319+3307

Test #56:

score: 12
Accepted
time: 4ms
memory: 6448kb

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
973 1995 7710 3143
333 82
529 338
557 548
83 745
602 297
451 697
851 161
621 47
372 703
814 252
590 638
427 280
12 997
984 922
664 821
754 622
733 960
544 541
406 331
277 894
480 299
787 320
970 90
382 221
575 835
952 457
53 491
140 135
160 144
177 176
26 8
45 43
133 88
162 138
402 883
194...

result:

ok Accepted with 973+1995 operations,sum of size(s)=7710+3143

Test #57:

score: 12
Accepted
time: 4ms
memory: 6480kb

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
869 1997 13710 2888
8 6
17 15
27 22
34 32
39 38
41 40
49 43
53 51
61 57
70 66
87 83
92 89
96 95
116 106
122 117
131 123
138 136
150 146
164 156
174 170
189 188
193 190
199 194
202 201
204 203
215 214
218 216
228 224
244 242
16 3
29 18
62 36
79 71
110 98
118 112
121 120
153 125
167 165
175 ...

result:

ok Accepted with 869+1997 operations,sum of size(s)=13710+2888

Test #58:

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

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
867 1999 11547 3949
12 3
14 13
18 16
21 20
24 22
27 26
34 30
38 37
44 39
49 45
54 53
60 56
64 63
69 67
72 70
75 73
81 76
83 82
86 85
91 88
94 93
97 95
102 99
105 103
108 106
110 109
112 111
114 113
118 115
126 125
132 129
135 133
137 136
142 139
147 143
152 151
158 154
163 160
165 164
167 ...

result:

ok Accepted with 867+1999 operations,sum of size(s)=11547+3949

Subtask #7:

score: 14
Accepted

Test #59:

score: 14
Accepted
time: 5ms
memory: 6628kb

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
1629 1999 15479 3861
263 939
1546 1313
89 1449
313 1405
535 799
1788 560
421 236
1158 1012
1325 1049
928 40
982 1676
725 1352
393 1483
752 1338
62 673
1256 840
95 480
1073 380
1120 534
232 54
105 1846
777 539
475 885
57 446
440 97
96 650
1773 1468
1261 1088
732 34
1926 883
851 261
1213 452...

result:

ok Accepted with 1629+1999 operations,sum of size(s)=15479+3861

Test #60:

score: 14
Accepted
time: 15ms
memory: 6576kb

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
412 1997 823 824
1793 1585
1955 1885
1716 1113
1910 1922
1796 1817
1426 1062
1442 1886
1633 1204
1469 1034
1780 1198
1709 1003
1238 1692
1066 1758
1774 1202
1842 1443
1507 1367
1935 1404
1221 1101
1726 1912
1455 1170
1126 1251
1265 1928
1117 1215
1225 1331
1419 1657
1566 1448
1897 1631
183...

result:

ok Accepted with 412+1997 operations,sum of size(s)=823+824

Test #61:

score: 14
Accepted
time: 5ms
memory: 6500kb

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
1871 1999 9779 3745
84 378
999 1366
1325 1934
768 813
670 1988
1300 1951
1704 1345
810 1688
490 1956
889 1250
470 1306
422 1412
1805 1336
1228 1310
1349 792
1229 849
1270 1652
701 1259
271 1677
1611 1309
1965 998
1913 1424
208 259
1524 284
1339 970
1021 1905
1480 1299
387 785
845 3
727 189...

result:

ok Accepted with 1871+1999 operations,sum of size(s)=9779+3745

Test #62:

score: 14
Accepted
time: 5ms
memory: 5744kb

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
1643 1995 16631 3902
334 60
1299 644
193 1310
359 1886
1955 230
1706 353
1934 756
1797 733
1098 221
1395 920
1443 1782
1868 1155
140 1927
726 1174
761 194
1053 1872
1585 703
762 803
1620 350
179 464
180 1433
886 28
1163 532
657 1548
1534 598
576 117
162 1681
580 267
1827 585
939 907
189 11...

result:

ok Accepted with 1643+1995 operations,sum of size(s)=16631+3902

Test #63:

score: 14
Accepted
time: 5ms
memory: 6792kb

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
1321 1999 10449 4631
18 684
27 5
767 97
62 1997
1233 231
1090 418
99 83
256 1006
525 1388
726 96
1024 735
1151 1133
1602 1452
135 102
172 169
178 175
409 1947
1677 638
107 43
112 865
531 349
962 801
1000 414
1731 1116
1768 1755
229 217
266 233
302 296
314 313
140 88
346 173
440 359
511 471...

result:

ok Accepted with 1321+1999 operations,sum of size(s)=10449+4631

Test #64:

score: 14
Accepted
time: 5ms
memory: 6512kb

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
1324 1997 7599 3832
98 2
184 132
191 600
310 589
373 1288
393 297
461 451
474 466
531 511
634 33
640 632
653 650
675 667
704 684
1458 863
870 1612
1448 1149
1008 1472
1146 550
628 1837
1155 1180
1138 1927
891 770
548 601
691 1640
148 556
1738 742
525 180
725 384
1156 877
674 1593
1647 1886...

result:

ok Accepted with 1324+1997 operations,sum of size(s)=7599+3832

Test #65:

score: 14
Accepted
time: 4ms
memory: 6496kb

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
1163 1997 7092 3480
32 15
239 224
292 258
369 313
493 477
541 511
621 551
825 649
59 56
71 66
155 85
185 184
196 190
359 238
410 382
433 432
582 544
607 606
627 618
686 630
807 787
843 812
282 305
1773 1162
1835 412
722 1040
654 918
876 585
1851 657
470 1869
93 844
708 22
48 1769
1200 30
1...

result:

ok Accepted with 1163+1997 operations,sum of size(s)=7092+3480

Test #66:

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

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
856 1997 13076 2849
11 8
16 15
19 18
22 21
43 35
51 50
56 52
64 57
73 68
82 75
90 86
103 92
113 110
117 115
121 118
135 132
137 136
157 156
162 160
171 170
176 172
188 180
192 190
199 198
203 200
220 214
223 221
238 237
258 247
267 262
278 273
283 282
289 284
293 291
301 296
311 303
315 31...

result:

ok Accepted with 856+1997 operations,sum of size(s)=13076+2849

Test #67:

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

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
869 1997 11447 3989
4 3
10 7
12 11
21 19
23 22
26 25
30 28
35 34
39 37
46 45
48 47
52 49
54 53
59 55
62 61
67 63
70 69
73 71
75 74
79 76
83 82
85 84
91 86
98 93
107 106
110 108
114 112
119 115
122 121
127 123
129 128
132 130
134 133
138 136
144 141
150 148
153 151
157 156
162 159
165 163
1...

result:

ok Accepted with 869+1997 operations,sum of size(s)=11447+3989

Test #68:

score: 14
Accepted
time: 4ms
memory: 5728kb

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
1479 1997 13051 2958
1716 652
1723 314
1497 25
1587 159
1943 227
1593 154
1165 36
1156 446
1535 169
1817 756
1305 717
1477 697
1845 540
1608 600
1260 217
1494 282
1251 417
1280 356
1669 947
1395 927
1815 786
1524 844
1164 96
1960 954
1605 193
1071 229
1947 92
1881 689
1029 471
1096 586
130...

result:

ok Accepted with 1479+1997 operations,sum of size(s)=13051+2958

Test #69:

score: 14
Accepted
time: 4ms
memory: 6488kb

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
1631 1995 13442 3287
1150 955
181 1618
1801 777
633 1177
1119 762
1830 354
746 1492
1104 379
1273 435
1613 522
992 1068
1639 271
1928 923
1437 377
1152 783
1637 367
1489 938
1518 91
653 456
1569 803
1823 521
1006 558
831 362
1383 439
553 1159
906 1092
1228 1058
1207 919
1277 880
1278 448
1...

result:

ok Accepted with 1631+1995 operations,sum of size(s)=13442+3287

Subtask #8:

score: 10
Accepted

Test #70:

score: 10
Accepted
time: 23ms
memory: 8148kb

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
8301 9997 105262 19675
1028 438
4292 6245
584 7727
712 2570
6570 2416
7626 9316
2873 1091
547 1644
1371 4472
6048 7904
1430 113
7604 4435
5762 3135
9450 8733
9746 7369
4742 792
7429 4810
9965 4740
7988 4126
1594 5083
1598 1566
1846 2392
3124 274
8636 1443
4357 8867
8651 1474
2214 175
501 5...

result:

ok Accepted with 8301+9997 operations,sum of size(s)=105262+19675

Test #71:

score: 10
Accepted
time: 403ms
memory: 8480kb

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
1274 9995 2414 2550
3665 6419
3382 1113
966 496
501 1989
8953 7157
6260 8167
9201 7561
5841 9398
6967 6725
5097 9583
9915 8986
5827 7098
9970 8640
5771 7250
6176 8481
9821 6729
9456 6287
8972 9502
7089 5714
6892 7650
6335 5993
6905 9353
9960 6931
5766 9934
6591 6482
9861 5702
6950 6518
984...

result:

ok Accepted with 1274+9995 operations,sum of size(s)=2414+2550

Test #72:

score: 10
Accepted
time: 33ms
memory: 7804kb

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
9497 9997 51201 18995
3025 5126
1256 1134
4622 8326
1935 4485
5724 1823
4995 3329
1187 8165
768 4192
5844 8768
1819 7005
1535 5513
3929 3285
3593 2386
4355 2077
7653 8579
7405 4430
7500 5928
7305 8072
3569 3135
1460 9887
1273 8651
5984 1783
8202 1314
2674 8487
1220 7438
4892 5236
4947 3385...

result:

ok Accepted with 9497+9997 operations,sum of size(s)=51201+18995

Test #73:

score: 10
Accepted
time: 20ms
memory: 7804kb

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
8341 9997 105256 19568
5999 1588
7498 4425
5172 5071
3307 9020
6854 9254
5572 2548
576 6732
8669 8441
9065 555
9097 2744
8976 3267
7052 234
5095 9139
1576 777
2529 8214
1459 3374
2907 1681
1426 3281
3351 730
2719 4901
386 2052
2363 40
4730 2968
5716 4594
5408 4833
9753 4021
1786 9905
8968 ...

result:

ok Accepted with 8341+9997 operations,sum of size(s)=105256+19568

Test #74:

score: 10
Accepted
time: 19ms
memory: 7628kb

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
6027 9995 68982 20692
9192 3025
2701 8492
9520 1295
4376 6351
9390 182
3596 9456
6529 5430
7820 7205
1292 8227
1040 9286
7107 305
9324 9443
6606 8018
790 649
2420 4590
3350 1259
4345 3533
4609 4518
7191 6288
401 69
2977 2834
4019 5671
6879 1123
5251 3231
2114 4802
4798 2624
7348 7142
5993 ...

result:

ok Accepted with 6027+9995 operations,sum of size(s)=68982+20692

Test #75:

score: 10
Accepted
time: 29ms
memory: 7868kb

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
6253 9995 63370 19390
8613 2515
5193 1765
2216 2538
6110 5120
1396 5092
5509 9509
3225 3010
504 1592
8204 5234
2357 4034
2449 3068
7163 2183
9171 2451
8958 9324
1329 8804
8386 3939
6405 2129
4444 6413
4659 2496
1480 1547
8088 7117
9286 8129
7148 5924
5498 3553
7509 6447
4956 5452
8149 4381...

result:

ok Accepted with 6253+9995 operations,sum of size(s)=63370+19390

Test #76:

score: 10
Accepted
time: 31ms
memory: 7692kb

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
5564 9995 57999 20068
4847 6540
6983 3423
5001 7308
6419 6949
7977 5603
8292 8733
5925 4591
8166 691
6573 571
3162 9967
1305 5292
7609 1922
8766 6154
6625 2079
8863 683
2397 8814
126 3200
148 78
548 371
653 552
1037 844
1873 1854
1898 1891
2683 1995
2829 7465
186 132
460 189
583 523
1200 1...

result:

ok Accepted with 5564+9995 operations,sum of size(s)=57999+20068

Test #77:

score: 10
Accepted
time: 16ms
memory: 7940kb

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
4225 9997 74872 19762
6 3
15 13
19 16
25 22
27 26
30 28
32 31
36 33
38 37
43 41
46 44
48 47
51 49
54 52
56 55
58 57
64 62
71 65
73 72
75 74
81 76
85 83
89 86
92 90
96 94
103 102
108 104
110 109
113 111
115 114
119 117
125 124
127 126
131 130
139 132
145 140
150 148
156 154
159 157
163 161
...

result:

ok Accepted with 4225+9997 operations,sum of size(s)=74872+19762

Test #78:

score: 10
Accepted
time: 14ms
memory: 7928kb

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
4215 9999 91410 13229
26 20
49 41
89 72
110 93
124 115
128 126
134 133
146 137
156 152
169 163
187 171
226 192
237 234
240 238
256 247
271 268
284 274
312 301
330 327
343 340
367 356
383 380
386 384
391 390
405 397
429 409
464 442
476 475
498 495
508 505
533 511
554 543
573 560
580 574
588...

result:

ok Accepted with 4215+9999 operations,sum of size(s)=91410+13229

Test #79:

score: 10
Accepted
time: 11ms
memory: 7720kb

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
7793 9995 90763 15615
6067 2204
6126 1670
6217 1795
6069 345
8132 347
7437 2195
6316 247
8776 1839
8527 4403
7056 1799
8774 867
9176 2380
1153 7918
5883 1144
6525 3566
7338 2682
733 5952
2901 8262
6737 1638
7170 421
8730 934
7566 354
7853 613
9989 456
5432 655
8053 3891
9590 4233
5040 2762...

result:

ok Accepted with 7793+9995 operations,sum of size(s)=90763+15615

Test #80:

score: 10
Accepted
time: 16ms
memory: 7616kb

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
8006 9997 92349 16064
5026 169
8124 1262
8660 3795
7138 4080
9569 1718
9425 3314
2408 5500
5314 3016
8466 2243
8513 3293
6120 1048
7310 2834
9667 2530
8097 2345
9499 6334
6574 3377
5284 648
7249 264
9156 4491
5975 3471
9230 4013
9890 3554
7754 480
4514 11
8623 2150
2042 6271
7924 1871
9573...

result:

ok Accepted with 8006+9997 operations,sum of size(s)=92349+16064

Subtask #9:

score: 27
Accepted

Test #81:

score: 27
Accepted
time: 24ms
memory: 7876kb

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
8353 9999 102834 19726
4914 1671
9211 5978
8841 3457
4036 2006
9362 7513
3765 1180
9259 9212
133 2367
1264 1127
2380 1300
4494 8006
8505 9364
4767 3416
4699 2736
5538 6041
6644 9132
8519 3109
1183 319
1775 528
4838 1653
9230 1483
1043 7471
7936 9933
8760 4961
2452 4427
3580 669
7727 3593
3...

result:

ok Accepted with 8353+9999 operations,sum of size(s)=102834+19726

Test #82:

score: 27
Accepted
time: 336ms
memory: 8400kb

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
3722 9997 7441 7444
1391 1098
2729 3881
932 2969
2301 2666
8137 9190
5119 7812
8282 9489
5657 7106
7999 7010
7972 8623
7776 6119
8023 6023
7473 9818
9433 9327
9604 6075
7170 7244
8933 5820
8317 7956
9314 5202
7218 9453
5651 8059
5942 9338
6382 9733
7868 7679
9250 8931
9865 6157
8619 8396
9...

result:

ok Accepted with 3722+9997 operations,sum of size(s)=7441+7444

Test #83:

score: 27
Accepted
time: 33ms
memory: 7888kb

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
9451 9999 50952 18905
6747 9669
9644 998
912 9855
7139 4567
5379 9814
4302 2736
6221 5615
7593 74
7064 4901
8969 5681
3328 1644
34 9596
326 3986
1766 9143
8449 6107
9169 1780
5788 6194
8537 3716
3683 8913
487 3260
2765 8561
8669 1170
5037 4060
1373 1257
3889 9204
6779 774
4776 4945
8983 93...

result:

ok Accepted with 9451+9999 operations,sum of size(s)=50952+18905

Test #84:

score: 27
Accepted
time: 33ms
memory: 7704kb

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
9740 9999 60303 19488
459 17
4816 9569
2181 2035
2857 8046
7138 5268
9830 9542
6198 6693
6210 4468
3079 411
9589 5353
7014 9986
3141 9572
473 6527
6707 1437
5885 8682
8364 8845
2073 1424
2261 3219
7129 6239
7020 4698
8982 7895
135 7292
4644 9636
1078 6270
4972 7456
472 260
2627 3379
105 35...

result:

ok Accepted with 9740+9999 operations,sum of size(s)=60303+19488

Test #85:

score: 27
Accepted
time: 68ms
memory: 8036kb

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
3474 9997 40615 18490
40 28
171 119
278 276
336 305
437 384
657 576
834 3107
843 801
939 930
971 1352
976 968
1174 1173
1271 1242
1297 1289
1386 1380
1488 1484
1522 1495
1629 1567
1770 1740
1843 1791
1903 1895
2021 2015
2104 2103
2165 2154
2223 2216
2249 2235
2302 2277
2472 2396
2581 2560
...

result:

ok Accepted with 3474+9997 operations,sum of size(s)=40615+18490

Test #86:

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

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
3377 9997 43482 22531
333 44
359 358
584 504
874 636
1028 932
1331 1244
1471 1455
1913 1649
2173 4951
2323 1990
29 6
39 34
43 41
58 55
6028 423
72 66
78 75
100 97
104 103
120 114
140 129
162 155
183 182
230 187
248 242
265 258
283 276
310 293
321 312
344 342
381 362
398 384
415 408
448 433...

result:

ok Accepted with 3377+9997 operations,sum of size(s)=43482+22531

Test #87:

score: 27
Accepted
time: 48ms
memory: 7876kb

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
3642 9999 51625 19976
98 13
291 215
331 303
360 351
396 375
418 415
600 456
607 37
149 66
310 177
883 762
1318 948
1759 1396
2079 2017
2191 2122
2425 2403
2483 2482
2598 2592
2965 2887
3172 3120
3438 3329
3961 3869
4234 4038
4318 4285
4950 4567
5016 4981
5340 5182
5678 5510
5765 5745
5792 ...

result:

ok Accepted with 3642+9999 operations,sum of size(s)=51625+19976

Test #88:

score: 27
Accepted
time: 24ms
memory: 7780kb

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
8311 9995 103658 19618
3496 3097
2690 378
8196 5156
7715 4909
7648 755
1380 1309
4131 1069
127 5556
9138 7847
9792 7750
4438 9407
2298 4259
4201 2627
1925 1882
6290 9778
2891 9795
5511 9444
9175 2843
254 4985
2070 2062
9629 5247
3170 5133
6667 3955
2940 7703
7407 9582
304 9852
1111 13
2822...

result:

ok Accepted with 8311+9995 operations,sum of size(s)=103658+19618

Test #89:

score: 27
Accepted
time: 26ms
memory: 7720kb

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
6690 9997 66111 20537
126 2
254 170
690 395
822 716
842 829
978 856
1186 1048
1479 1340
1707 1679
1742 1723
2274 2035
2552 2516
2648 2635
2804 2755
2993 2853
3030 3806
3291 3270
3343 3308
3575 3518
3913 3691
4229 4059
4309 4399
4710 4678
4854 4832
5134 4968
5270 5155
5284 5274
5581 5344
57...

result:

ok Accepted with 6690+9997 operations,sum of size(s)=66111+20537

Test #90:

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

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
5904 9997 51594 17977
3997 4652
488 240
851 491
2645 1876
3264 2796
407 4294
3244 1640
3561 8902
4115 3335
5072 4290
5206 5140
5874 5605
7251 6793
483 9589
855 244
232 110
9931 5639
4221 1447
9629 5005
6093 1096
8815 1382
2285 682
2316 9676
56 4477
419 3149
5138 6078
63 50
249 197
840 452
...

result:

ok Accepted with 5904+9997 operations,sum of size(s)=51594+17977

Test #91:

score: 27
Accepted
time: 25ms
memory: 7836kb

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
5583 9999 54020 19398
1443 5122
9014 3696
9498 2514
5867 9623
3688 9989
295 292
916 796
1032 938
1579 1328
1838 1634
250 214
411 319
589 561
738 639
836 790
1030 1020
1113 1104
8147 9921
7284 8261
9026 3924
6704 6192
3043 9762
9499 164
6397 6030
4136 1666
5860 1936
6503 8197
9592 7492
122 ...

result:

ok Accepted with 5583+9999 operations,sum of size(s)=54020+19398

Test #92:

score: 27
Accepted
time: 13ms
memory: 8048kb

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
4216 9995 89513 14347
9 5
17 10
29 22
42 36
51 46
56 55
62 57
72 63
81 77
86 84
94 87
101 95
106 102
115 114
124 123
126 125
128 127
131 129
136 134
139 138
142 141
155 153
175 167
183 181
197 193
202 201
204 203
209 208
213 212
227 225
230 229
233 231
238 237
243 239
254 253
260 255
263 2...

result:

ok Accepted with 4216+9995 operations,sum of size(s)=89513+14347

Test #93:

score: 27
Accepted
time: 16ms
memory: 8080kb

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
4248 9999 95006 12742
42 22
83 64
100 90
114 101
124 122
198 156
226 220
245 236
247 246
274 266
304 296
314 306
325 323
333 330
355 342
380 369
400 393
461 404
507 463
523 520
566 537
614 572
624 623
628 626
663 634
737 709
827 803
838 836
880 841
893 881
911 898
953 952
974 969
1011 977
...

result:

ok Accepted with 4248+9999 operations,sum of size(s)=95006+12742

Test #94:

score: 27
Accepted
time: 20ms
memory: 7748kb

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
8026 9997 91327 16109
5358 1969
8331 3372
8584 3746
5886 4644
6774 951
7599 245
8892 2017
5436 4840
6360 213
9348 763
1522 8776
6325 2167
9985 4545
6996 2525
1115 5949
3618 7883
4369 2151
9980 4767
4343 9438
8963 3751
9758 4874
8364 1782
1799 7708
7121 3089
9192 2793
4999 3635
7808 426
780...

result:

ok Accepted with 8026+9997 operations,sum of size(s)=91327+16109

Test #95:

score: 27
Accepted
time: 18ms
memory: 7872kb

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
7999 9999 91366 16047
8595 2966
9188 3099
5894 2028
9854 3244
9906 3785
7427 1044
5188 2267
6914 2574
7030 4937
7344 360
5584 1649
6910 2244
7491 3538
6052 2256
5523 2229
7070 2893
2411 2828
3019 7363
5702 4678
6068 3570
9939 3232
4749 9160
2406 969
7920 4002
3011 7045
5721 4099
6760 3592
...

result:

ok Accepted with 7999+9999 operations,sum of size(s)=91366+16047