QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#369400#7791. 通道建设 Passage Constructionyyyyxh100 ✓2012ms202884kbC++143.6kb2024-03-28 07:25:422024-03-28 07:25:43

Judging History

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

  • [2024-03-28 07:25:43]
  • 评测
  • 测评结果:100
  • 用时:2012ms
  • 内存:202884kb
  • [2024-03-28 07:25:42]
  • 提交

answer

#include "passageconstruction.h"
#include <queue>
#include <vector>
#include <cassert>
#include <numeric>
#include <algorithm>
#define fi first
#define se second
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
const int N=10003,M=5003;
int n,cnt;
int lc[N],rc[N],fa[N],nd[N];
vi vec[N];
void rebuild(int u,int fs){
	int las=u;
	for(int v:vec[u]){
		if(v==fs) continue;
		rebuild(v,u);
		int p=++cnt;
		nd[p]=u;
		fa[lc[p]=v]=p;
		fa[rc[las]=p]=las;
		las=p;
	}
}
bool del[N];
int sz[N],sn[N];
void dfs(int u){
	sz[u]=1;sn[u]=0;
	if(lc[u]&&!del[lc[u]]){
		dfs(lc[u]);sz[u]+=sz[lc[u]];
		if(sz[lc[u]]>sz[sn[u]]) sn[u]=lc[u];
	}
	if(rc[u]&&!del[rc[u]]){
		dfs(rc[u]);sz[u]+=sz[rc[u]];
		if(sz[rc[u]]>sz[sn[u]]) sn[u]=rc[u];
	}
}
vector<int> lis[N];
void proc(int rt,vi cur){
	if(cur.empty()) return;
	int x=rt;
	dfs(rt);
	while(sz[sn[x]]*2>sz[rt]) x=sn[x];
	del[x]=1;
	if(x<=n){
		vi qvec=vec[x];
		if(qvec.size()==1lu) qvec.emplace_back(x);
		if(!cur.empty()){
			vi RES=QueryLCA(cur,qvec,x),out;
			for(int i=0;i<(int)cur.size();++i)
				if(RES[i]) lis[x].emplace_back(cur[i]);
				else out.emplace_back(cur[i]);
			cur.swap(out);
		}
	}
	if(lc[x]){
		vi onin,out,in;
		if(!cur.empty()){
			vi RES=QueryLCA(cur,{nd[x],lc[x]},nd[x]);
			for(int i=0;i<(int)cur.size();++i)
				if(RES[i]) out.emplace_back(cur[i]);
				else onin.emplace_back(cur[i]);
			cur.swap(out);
		}
		if(del[lc[x]]){
			for(int p:onin) lis[x].emplace_back(p);
		}
		else{
			vi in;
			if(!onin.empty()){
				vi RES=QueryLCA(onin,{nd[x],lc[x]},lc[x]);
				for(int i=0;i<(int)onin.size();++i)
					if(RES[i]) in.emplace_back(onin[i]);
					else lis[x].emplace_back(onin[i]);
			}
			proc(lc[x],in);
		}
	}
	if(rc[x]&&!del[rc[x]]){
		vi chain,in,out;
		for(int i=rc[x];i&&!del[i];i=rc[i])
			chain.emplace_back(lc[i]);
		if(chain.size()==1lu) chain.emplace_back(nd[x]);
		vi RES=QueryLCA(cur,chain,nd[x]);
		for(int i=0;i<(int)cur.size();++i)
			if(RES[i]) out.emplace_back(cur[i]);
			else in.emplace_back(cur[i]);
		cur.swap(out);
		proc(rc[x],in);
	}
	if(x!=rt) proc(rt,cur);
}
int d[M][M],p[M][M],q[M];
int mat[N];
int len;
int dl[N],dr[N];
vpii adj[N];
void dfs(int u,int fa,int *dep){
	for(auto [v,w]:adj[u]){
		if(v==fa) continue;
		dep[v]=dep[u]+w;
		dfs(v,u,dep);
	}
}
vpii ConstructPassages(int _N,const vpii &_E){
	n=_N;
	if(n==1) return {{1,2}};
	for(auto [u,v]:_E){
		vec[u].emplace_back(v);
		vec[v].emplace_back(u);
	}
	vi init;
	for(int i=1;i<=n;++i) nd[i]=i,init.emplace_back(i+n);
	cnt=n;
	rebuild(1,0);
	proc(1,init);
	for(int i=n+1;i<=cnt;++i){
		int len=1;
		int u=nd[i],v=lc[i];
		for(int x:lis[i]){
			dl[x]=GetDistance(u,x);
			dr[x]=GetDistance(v,x);
			if(dl[x]==1||dr[x]==1) len=dl[x]+dr[x];
		}
		adj[v].emplace_back(u,len);
		adj[u].emplace_back(v,len);
	}
	for(int i=1;i<=n;++i)
		for(int x:lis[i]){
			d[x-n][i]=GetDistance(i,x);
			dfs(i,0,d[x-n]);
		}
	for(int i=n+1;i<=cnt;++i){
		int u=nd[i],v=lc[i];
		for(int x:lis[i]){
			d[x-n][u]=dl[x];dfs(u,v,d[x-n]);
			d[x-n][v]=dr[x];dfs(v,u,d[x-n]);
		}
	}
	queue<int> que;
	for(int i=1;i<=n;++i){
		iota(p[i]+1,p[i]+n+1,1);
		sort(p[i]+1,p[i]+n+1,[&](int x,int y){return d[i][x]>d[i][y];});
		q[i]=1;mat[i]=0;que.emplace(i);
	}
	int cnt=0;
	while(!que.empty()){
		int u=que.front();que.pop();
		int v=p[u][q[u]];
		if(!mat[v]||d[u][v]<d[mat[v]][v]||(d[u][v]==d[mat[v]][v]&&u<mat[v])){
			if(mat[v]&&++q[mat[v]]<=n) que.emplace(mat[v]);
			mat[v]=u;
		}
		else if(++q[u]<=n) que.emplace(u);
	}
	vpii res;
	for(int i=1;i<=n;++i) res.emplace_back(mat[i]+n,i);
	return res;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 3
Accepted

Test #1:

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

input:

1
1872884041
100 100 10000 10000
1
2294931821 2294931820

output:

Succeeded
0 0 0 0
1 2

result:

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

Test #2:

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

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

result:

ok Accepted with 12+7 operations,sum of size(s)=25+25

Test #3:

score: 3
Accepted
time: 2ms
memory: 10204kb

input:

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

output:

Succeeded
3 3 5 6
3 1
4 2

result:

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

Test #4:

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

input:

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

output:

Succeeded
5 6 15 10
6 1
4 2
5 3

result:

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

Test #5:

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

input:

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

output:

Succeeded
9 6 14 18
8 1
7 2
6 3
5 4

result:

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

Test #6:

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

input:

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

output:

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

result:

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

Test #7:

score: 3
Accepted
time: 2ms
memory: 10716kb

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

result:

ok Accepted with 6+7 operations,sum of size(s)=15+14

Test #8:

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

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

result:

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

Test #9:

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

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

result:

ok Accepted with 9+7 operations,sum of size(s)=29+19

Test #10:

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

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

result:

ok Accepted with 12+7 operations,sum of size(s)=27+25

Subtask #2:

score: 6
Accepted

Test #11:

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

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
164 130 1099 365
167 1
180 2
188 3
124 4
113 5
112 6
168 7
171 8
121 9
196 10
134 11
131 12
102 13
117 14
120 15
115 16
101 17
177 18
136 19
111 20
186 21
155 22
109 23
173 24
146 25
195 26
132 27
129 28
144 29
127 30
148 31
175 32
108 33
182 34
104 35
199 36
162 37
200 38
158 39
119 40
11...

result:

ok Accepted with 164+130 operations,sum of size(s)=1099+365

Test #12:

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

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
183 131 993 393
184 1
138 2
155 3
140 4
165 5
107 6
160 7
149 8
169 9
164 10
148 11
125 12
104 13
152 14
145 15
187 16
111 17
151 18
180 19
135 20
132 21
134 22
146 23
161 24
162 25
177 26
153 27
196 28
154 29
163 30
137 31
188 32
147 33
121 34
192 35
110 36
127 37
133 38
120 39
173 40
178...

result:

ok Accepted with 183+131 operations,sum of size(s)=993+393

Test #13:

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

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
161 116 1075 360
197 1
135 2
185 3
168 4
147 5
153 6
176 7
100 8
109 9
127 10
188 11
195 12
186 13
139 14
159 15
196 16
101 17
136 18
178 19
134 20
193 21
179 22
130 23
138 24
125 25
115 26
121 27
140 28
110 29
129 30
154 31
165 32
126 33
119 34
152 35
169 36
171 37
156 38
149 39
158 40
19...

result:

ok Accepted with 161+116 operations,sum of size(s)=1075+360

Test #14:

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

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
190 125 1111 416
191 1
116 2
168 3
181 4
189 5
155 6
126 7
121 8
182 9
102 10
103 11
194 12
136 13
115 14
147 15
163 16
178 17
143 18
141 19
125 20
137 21
111 22
117 23
144 24
161 25
166 26
197 27
149 28
162 29
154 30
167 31
123 32
157 33
118 34
142 35
159 36
110 37
180 38
192 39
130 40
16...

result:

ok Accepted with 190+125 operations,sum of size(s)=1111+416

Test #15:

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

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
176 127 1069 385
181 1
131 2
147 3
128 4
198 5
170 6
177 7
191 8
178 9
137 10
185 11
120 12
173 13
121 14
184 15
146 16
124 17
168 18
108 19
109 20
157 21
119 22
166 23
107 24
112 25
104 26
186 27
127 28
190 29
144 30
132 31
163 32
116 33
165 34
154 35
138 36
176 37
150 38
167 39
139 40
14...

result:

ok Accepted with 176+127 operations,sum of size(s)=1069+385

Test #16:

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

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
188 137 1044 405
151 1
168 2
146 3
169 4
111 5
183 6
170 7
181 8
150 9
173 10
107 11
154 12
131 13
188 14
145 15
123 16
195 17
197 18
109 19
196 20
127 21
153 22
141 23
156 24
137 25
134 26
180 27
117 28
144 29
148 30
133 31
199 32
135 33
122 34
125 35
115 36
106 37
112 38
194 39
119 40
13...

result:

ok Accepted with 188+137 operations,sum of size(s)=1044+405

Test #17:

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

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
216 126 1030 466
172 1
179 2
138 3
173 4
144 5
180 6
184 7
175 8
143 9
150 10
187 11
145 12
139 13
98 14
157 15
155 16
166 17
174 18
161 19
123 20
194 21
160 22
191 23
120 24
147 25
108 26
163 27
168 28
107 29
140 30
165 31
104 32
170 33
188 34
127 35
154 36
164 37
99 38
136 39
158 40
169 ...

result:

ok Accepted with 216+126 operations,sum of size(s)=1030+466

Test #18:

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

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
182 122 1005 403
182 1
189 2
186 3
147 4
146 5
153 6
113 7
130 8
167 9
183 10
185 11
148 12
192 13
120 14
194 15
131 16
174 17
184 18
150 19
99 20
143 21
112 22
139 23
134 24
119 25
162 26
193 27
104 28
144 29
118 30
141 31
159 32
164 33
177 34
191 35
179 36
154 37
133 38
195 39
172 40
170...

result:

ok Accepted with 182+122 operations,sum of size(s)=1005+403

Subtask #3:

score: 8
Accepted

Test #19:

score: 8
Accepted
time: 44ms
memory: 36664kb

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
697 1101 19254 1394
1778 1
1298 2
1447 3
1438 4
1228 5
1673 6
1356 7
1764 8
1657 9
1780 10
1739 11
1676 12
1629 13
1065 14
1144 15
1958 16
1218 17
1445 18
1042 19
1045 20
1776 21
1343 22
1631 23
1750 24
1376 25
1810 26
1705 27
1425 28
1746 29
1740 30
1709 31
1300 32
1524 33
1989 34
1577 35...

result:

ok Accepted with 697+1101 operations,sum of size(s)=19254+1394

Test #20:

score: 8
Accepted
time: 51ms
memory: 39328kb

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
660 1998 17948 1320
1715 1
1306 2
1763 3
1412 4
1479 5
1666 6
1192 7
1991 8
1048 9
1722 10
1936 11
1369 12
1760 13
1159 14
1556 15
1566 16
1944 17
1491 18
1662 19
1483 20
1174 21
1832 22
1152 23
1387 24
1755 25
1216 26
1797 27
1507 28
1005 29
1752 30
1136 31
1254 32
1765 33
1298 34
1886 35...

result:

ok Accepted with 660+1998 operations,sum of size(s)=17948+1320

Test #21:

score: 8
Accepted
time: 48ms
memory: 40972kb

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
700 1110 20053 1400
1802 1
1228 2
1838 3
1596 4
1186 5
1536 6
1676 7
1865 8
1497 9
1723 10
1610 11
1938 12
1871 13
1298 14
1362 15
1722 16
1442 17
1785 18
1202 19
1667 20
1982 21
1698 22
1301 23
1052 24
1444 25
1085 26
1989 27
1506 28
1010 29
1742 30
1845 31
1144 32
1531 33
1788 34
1640 35...

result:

ok Accepted with 700+1110 operations,sum of size(s)=20053+1400

Test #22:

score: 8
Accepted
time: 60ms
memory: 39920kb

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
1807 1995 17410 3614
1732 1
1469 2
1694 3
1698 4
1230 5
1117 6
1283 7
1264 8
1616 9
1043 10
1904 11
1039 12
1797 13
1992 14
1593 15
1896 16
1353 17
1802 18
1647 19
1795 20
1678 21
1355 22
1229 23
1924 24
1947 25
1195 26
1284 27
1430 28
1302 29
1494 30
1045 31
1444 32
1256 33
1891 34
1440 3...

result:

ok Accepted with 1807+1995 operations,sum of size(s)=17410+3614

Test #23:

score: 8
Accepted
time: 65ms
memory: 39340kb

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
1807 1998 16794 3614
1382 1
1601 2
1938 3
1751 4
1456 5
1652 6
1064 7
1306 8
1731 9
1169 10
1934 11
1363 12
1787 13
1870 14
1101 15
1086 16
1098 17
1405 18
1591 19
1669 20
1528 21
1457 22
1863 23
1344 24
1687 25
1074 26
1038 27
1804 28
1769 29
1587 30
1471 31
1492 32
1007 33
1152 34
1728 3...

result:

ok Accepted with 1807+1998 operations,sum of size(s)=16794+3614

Test #24:

score: 8
Accepted
time: 52ms
memory: 39288kb

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
706 1998 16164 1412
1656 1
1426 2
1696 3
1829 4
1427 5
1124 6
1566 7
1349 8
1080 9
1860 10
1724 11
1299 12
1703 13
1120 14
1309 15
1331 16
1943 17
1955 18
1216 19
1864 20
1030 21
1045 22
1949 23
1504 24
1279 25
1471 26
1575 27
1358 28
1103 29
1366 30
1194 31
1072 32
1548 33
1823 34
1288 35...

result:

ok Accepted with 706+1998 operations,sum of size(s)=16164+1412

Test #25:

score: 8
Accepted
time: 43ms
memory: 38144kb

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
615 1996 16060 1230
1873 1
1896 2
1219 3
1939 4
1566 5
1372 6
1995 7
1398 8
1769 9
1238 10
1094 11
1326 12
1444 13
1977 14
1615 15
1965 16
1417 17
1811 18
1934 19
1176 20
1731 21
1237 22
1686 23
1230 24
1733 25
1991 26
1826 27
1956 28
1864 29
1904 30
1154 31
1895 32
1261 33
1680 34
1857 35...

result:

ok Accepted with 615+1996 operations,sum of size(s)=16060+1230

Test #26:

score: 8
Accepted
time: 67ms
memory: 38684kb

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
657 1998 19210 1314
1803 1
1887 2
1748 3
1992 4
1885 5
1834 6
1148 7
1546 8
1666 9
1469 10
1377 11
1604 12
1316 13
1324 14
1068 15
1037 16
1875 17
1906 18
1520 19
1877 20
1801 21
1798 22
1020 23
1319 24
1652 25
1132 26
1014 27
1698 28
1318 29
1456 30
1112 31
1964 32
1345 33
1982 34
1764 35...

result:

ok Accepted with 657+1998 operations,sum of size(s)=19210+1314

Test #27:

score: 8
Accepted
time: 60ms
memory: 39104kb

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
669 1998 20641 1338
1444 1
1469 2
1313 3
1506 4
1787 5
1879 6
1971 7
1656 8
1754 9
1287 10
1822 11
1931 12
1918 13
1166 14
1523 15
1927 16
1076 17
1732 18
1288 19
1401 20
1365 21
1757 22
1926 23
1075 24
1229 25
1382 26
1261 27
1106 28
1959 29
1242 30
1825 31
1027 32
1857 33
1791 34
1889 35...

result:

ok Accepted with 669+1998 operations,sum of size(s)=20641+1338

Test #28:

score: 8
Accepted
time: 56ms
memory: 40440kb

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
693 1999 18781 1386
1176 1
1552 2
1393 3
1893 4
1181 5
1525 6
1827 7
1295 8
1284 9
1649 10
1678 11
1630 12
1632 13
1819 14
1035 15
1357 16
1409 17
1098 18
1808 19
1711 20
1037 21
1264 22
1299 23
1960 24
1019 25
1049 26
1591 27
1435 28
1584 29
1119 30
1440 31
1889 32
1645 33
1891 34
1999 35...

result:

ok Accepted with 693+1999 operations,sum of size(s)=18781+1386

Subtask #4:

score: 9
Accepted

Test #29:

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

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
1952 1000 16124 3950
1728 1
1464 2
1969 3
1508 4
1490 5
1493 6
1986 7
1816 8
1533 9
1976 10
1718 11
1292 12
1041 13
1407 14
1753 15
1889 16
1267 17
1429 18
1339 19
1803 20
1455 21
1161 22
1680 23
1725 24
1021 25
1591 26
1185 27
1530 28
1249 29
1268 30
1662 31
1053 32
1531 33
1499 34
1135 3...

result:

ok Accepted with 1952+1000 operations,sum of size(s)=16124+3950

Test #30:

score: 9
Accepted
time: 54ms
memory: 39304kb

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
426 1000 19614 852
1438 1
1447 2
1807 3
1813 4
1635 5
1127 6
1916 7
1387 8
1179 9
1702 10
1196 11
1365 12
1538 13
1491 14
1522 15
1364 16
1055 17
1583 18
1846 19
1394 20
1360 21
1676 22
1615 23
1962 24
1176 25
1840 26
1806 27
1930 28
1663 29
1273 30
1843 31
1269 32
1510 33
1724 34
1887 35
...

result:

ok Accepted with 426+1000 operations,sum of size(s)=19614+852

Test #31:

score: 9
Accepted
time: 34ms
memory: 40648kb

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
1958 998 15791 3961
1677 1
1961 2
1324 3
1471 4
1496 5
1174 6
1986 7
1145 8
1693 9
1981 10
1962 11
1882 12
1261 13
1380 14
1957 15
1161 16
1933 17
1673 18
1912 19
1012 20
1904 21
1078 22
1909 23
1050 24
1135 25
1814 26
1783 27
1952 28
1176 29
1477 30
1956 31
1305 32
1892 33
1725 34
1773 35...

result:

ok Accepted with 1958+998 operations,sum of size(s)=15791+3961

Test #32:

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

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
1941 998 15844 3941
1659 1
1484 2
1248 3
1768 4
1642 5
1046 6
1083 7
1437 8
1885 9
1351 10
1419 11
1106 12
1411 13
1334 14
1667 15
1348 16
1077 17
1252 18
1967 19
1118 20
1278 21
1774 22
1307 23
1453 24
1459 25
1743 26
1641 27
1645 28
1021 29
1833 30
1332 31
1315 32
1112 33
1849 34
1929 35...

result:

ok Accepted with 1941+998 operations,sum of size(s)=15844+3941

Test #33:

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

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
1913 998 15166 3863
1551 1
1745 2
1135 3
1144 4
1785 5
1203 6
1290 7
1479 8
1497 9
1248 10
1511 11
1744 12
1519 13
1619 14
1652 15
1413 16
1793 17
1653 18
1454 19
1051 20
1317 21
1842 22
1277 23
1510 24
1187 25
1848 26
1515 27
1069 28
1613 29
1091 30
1436 31
1500 32
1678 33
1217 34
1594 35...

result:

ok Accepted with 1913+998 operations,sum of size(s)=15166+3863

Test #34:

score: 9
Accepted
time: 37ms
memory: 42052kb

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
2101 1000 18087 4203
1401 1
1045 2
1991 3
1068 4
1024 5
1715 6
1261 7
1337 8
1010 9
1330 10
1534 11
1412 12
1249 13
1845 14
1098 15
1787 16
1566 17
1761 18
1884 19
1579 20
1230 21
1190 22
1957 23
1079 24
1515 25
1661 26
1795 27
1396 28
1855 29
1752 30
1972 31
1309 32
1075 33
1758 34
1252 3...

result:

ok Accepted with 2101+1000 operations,sum of size(s)=18087+4203

Test #35:

score: 9
Accepted
time: 37ms
memory: 42900kb

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
2035 1000 17994 4071
1169 1
1588 2
1005 3
1607 4
1640 5
1055 6
1555 7
1572 8
1802 9
1713 10
1654 11
1829 12
1968 13
1739 14
1929 15
1837 16
1755 17
1394 18
1666 19
1365 20
1609 21
1293 22
1146 23
1777 24
1410 25
1618 26
1969 27
1880 28
1672 29
1057 30
1214 31
1230 32
1999 33
1468 34
1548 3...

result:

ok Accepted with 2035+1000 operations,sum of size(s)=17994+4071

Test #36:

score: 9
Accepted
time: 37ms
memory: 42892kb

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
1977 1000 17957 3954
1288 1
1142 2
1886 3
1304 4
1266 5
1876 6
1305 7
1557 8
1581 9
1222 10
1052 11
1284 12
1389 13
1251 14
1382 15
1123 16
1764 17
1808 18
1979 19
1323 20
1161 21
1020 22
1338 23
1727 24
1942 25
1283 26
1980 27
1446 28
1449 29
1587 30
1805 31
1380 32
1436 33
1939 34
1772 3...

result:

ok Accepted with 1977+1000 operations,sum of size(s)=17957+3954

Test #37:

score: 9
Accepted
time: 59ms
memory: 42896kb

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
2131 1000 16607 4299
1159 1
1759 2
1810 3
1697 4
1310 5
1093 6
1862 7
1775 8
1984 9
1074 10
1436 11
1036 12
1361 13
1853 14
1058 15
1936 16
1174 17
1700 18
1336 19
1950 20
1660 21
1886 22
1990 23
1635 24
1105 25
1969 26
1524 27
1042 28
1744 29
1795 30
1518 31
1794 32
1659 33
1053 34
1333 3...

result:

ok Accepted with 2131+1000 operations,sum of size(s)=16607+4299

Test #38:

score: 9
Accepted
time: 58ms
memory: 41652kb

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
2100 998 17316 4228
1379 1
1727 2
1064 3
1246 4
1072 5
1453 6
1599 7
1876 8
1992 9
1417 10
1145 11
1393 12
1484 13
1508 14
1811 15
1609 16
1502 17
1462 18
1947 19
1485 20
1451 21
1757 22
1613 23
1699 24
1728 25
1463 26
1403 27
1142 28
1414 29
1673 30
1356 31
1046 32
1296 33
1203 34
1094 35...

result:

ok Accepted with 2100+998 operations,sum of size(s)=17316+4228

Subtask #5:

score: 11
Accepted

Test #39:

score: 11
Accepted
time: 35ms
memory: 42876kb

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
1522 1289 13862 3101
1061 1
1005 2
1849 3
1370 4
1807 5
1734 6
1024 7
1648 8
1181 9
1598 10
1431 11
1252 12
1733 13
1627 14
1466 15
1969 16
1351 17
1828 18
1446 19
1687 20
1962 21
1864 22
1770 23
1489 24
1551 25
1821 26
1992 27
1502 28
1908 29
1630 30
1211 31
1427 32
1046 33
1976 34
1811 3...

result:

ok Accepted with 1522+1289 operations,sum of size(s)=13862+3101

Test #40:

score: 11
Accepted
time: 55ms
memory: 41412kb

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
1943 1971 16166 3886
1794 1
1657 2
1186 3
1538 4
1523 5
1614 6
1364 7
1362 8
1286 9
1856 10
1105 11
1688 12
1100 13
1588 14
1157 15
1730 16
1916 17
1310 18
1145 19
1015 20
1131 21
1783 22
1540 23
1401 24
1005 25
1500 26
1164 27
1535 28
1647 29
1423 30
1026 31
1697 32
1990 33
1339 34
1644 3...

result:

ok Accepted with 1943+1971 operations,sum of size(s)=16166+3886

Test #41:

score: 11
Accepted
time: 63ms
memory: 41480kb

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
2097 1181 16530 4231
1559 1
1155 2
1223 3
1133 4
1156 5
1394 6
1615 7
1140 8
1942 9
1939 10
1702 11
1971 12
1228 13
1931 14
1748 15
1670 16
1428 17
1887 18
1882 19
1169 20
1958 21
1450 22
1080 23
1283 24
1360 25
1605 26
1543 27
1170 28
1741 29
1905 30
1999 31
1575 32
1937 33
1081 34
1566 3...

result:

ok Accepted with 2097+1181 operations,sum of size(s)=16530+4231

Test #42:

score: 11
Accepted
time: 42ms
memory: 39716kb

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
1545 1327 14849 3144
1946 1
1035 2
1775 3
1278 4
1935 5
1103 6
1836 7
1762 8
1484 9
1666 10
1022 11
1983 12
1237 13
1447 14
1326 15
1699 16
1847 17
1739 18
1697 19
1469 20
1154 21
1835 22
1849 23
1367 24
1671 25
1177 26
1887 27
1157 28
1385 29
1009 30
1206 31
1319 32
1601 33
1401 34
1732 3...

result:

ok Accepted with 1545+1327 operations,sum of size(s)=14849+3144

Test #43:

score: 11
Accepted
time: 45ms
memory: 39864kb

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
1621 1325 14374 3301
1942 1
1911 2
1552 3
1727 4
1876 5
1559 6
1467 7
1785 8
1502 9
1678 10
1750 11
1554 12
1536 13
1987 14
1000 15
1719 16
1767 17
1708 18
1606 19
1846 20
1525 21
1111 22
1038 23
1377 24
1362 25
1579 26
1367 27
1016 28
1930 29
1751 30
1124 31
1186 32
1895 33
1462 34
1235 3...

result:

ok Accepted with 1621+1325 operations,sum of size(s)=14374+3301

Test #44:

score: 11
Accepted
time: 40ms
memory: 38888kb

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
1460 1337 14489 2953
1505 1
1332 2
1813 3
1138 4
1225 5
1227 6
1511 7
1004 8
1500 9
1075 10
1099 11
1071 12
1129 13
1822 14
1805 15
1963 16
1025 17
1082 18
1611 19
1961 20
1131 21
1888 22
1831 23
1088 24
1096 25
1307 26
1668 27
1623 28
1386 29
1580 30
1302 31
1179 32
1122 33
1764 34
1838 3...

result:

ok Accepted with 1460+1337 operations,sum of size(s)=14489+2953

Test #45:

score: 11
Accepted
time: 52ms
memory: 38020kb

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
602 1088 20151 1204
1917 1
1913 2
1396 3
1429 4
1868 5
1037 6
1555 7
1550 8
1125 9
1864 10
1387 11
1725 12
1159 13
1736 14
1552 15
1730 16
1289 17
1210 18
1147 19
1231 20
1235 21
1117 22
1558 23
1594 24
1473 25
1752 26
1133 27
1416 28
1705 29
1028 30
1110 31
1186 32
1357 33
1204 34
1668 35...

result:

ok Accepted with 602+1088 operations,sum of size(s)=20151+1204

Test #46:

score: 11
Accepted
time: 66ms
memory: 39484kb

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
1844 1996 17465 3688
1554 1
1911 2
1763 3
1637 4
1449 5
1068 6
1283 7
1206 8
1619 9
1884 10
1356 11
1777 12
1444 13
1632 14
1298 15
1089 16
1231 17
1985 18
1154 19
1019 20
1118 21
1873 22
1973 23
1677 24
1500 25
1143 26
1749 27
1744 28
1527 29
1439 30
1222 31
1737 32
1981 33
1188 34
1585 3...

result:

ok Accepted with 1844+1996 operations,sum of size(s)=17465+3688

Test #47:

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

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
607 2000 19775 1214
1008 1
1810 2
1057 3
1305 4
1663 5
1055 6
1422 7
1362 8
1082 9
1235 10
1330 11
1097 12
1289 13
1871 14
1972 15
1376 16
1596 17
1848 18
1085 19
1304 20
1099 21
1950 22
1911 23
1342 24
1188 25
1505 26
1585 27
1721 28
1821 29
1661 30
1798 31
1670 32
1156 33
1903 34
1254 35...

result:

ok Accepted with 607+2000 operations,sum of size(s)=19775+1214

Test #48:

score: 11
Accepted
time: 38ms
memory: 40264kb

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
2496 1999 15644 4993
1272 1
1326 2
1415 3
1030 4
1927 5
1602 6
1542 7
1586 8
1594 9
1972 10
1168 11
1140 12
1476 13
1293 14
1753 15
1044 16
1322 17
1487 18
1294 19
1431 20
1751 21
1583 22
1273 23
1225 24
1837 25
1780 26
1185 27
1664 28
1645 29
1521 30
1154 31
1628 32
1634 33
1102 34
1638 3...

result:

ok Accepted with 2496+1999 operations,sum of size(s)=15644+4993

Test #49:

score: 11
Accepted
time: 40ms
memory: 40196kb

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
2497 1997 15626 4997
1360 1
1220 2
1171 3
1707 4
1963 5
1272 6
1816 7
1540 8
1920 9
1093 10
1441 11
1061 12
1474 13
1213 14
1057 15
1320 16
1285 17
1932 18
1379 19
1802 20
1798 21
1117 22
1036 23
1789 24
1752 25
1781 26
1994 27
1342 28
1552 29
1137 30
1396 31
1118 32
1354 33
1260 34
1247 3...

result:

ok Accepted with 2497+1997 operations,sum of size(s)=15626+4997

Subtask #6:

score: 12
Accepted

Test #50:

score: 12
Accepted
time: 37ms
memory: 41468kb

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
2163 998 15662 4620
1212 1
1552 2
1513 3
1434 4
1831 5
1501 6
1505 7
1036 8
1131 9
1249 10
1751 11
1155 12
1661 13
1028 14
1446 15
1256 16
1824 17
1731 18
1776 19
1819 20
1752 21
1716 22
1410 23
1708 24
1073 25
1911 26
1786 27
1860 28
1471 29
1472 30
1221 31
1667 32
1994 33
1317 34
1356 35...

result:

ok Accepted with 2163+998 operations,sum of size(s)=15662+4620

Test #51:

score: 12
Accepted
time: 37ms
memory: 41844kb

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
2164 999 15554 4701
1506 1
1800 2
1189 3
1876 4
1302 5
1305 6
1975 7
1643 8
1644 9
1799 10
1268 11
1252 12
1703 13
1668 14
1237 15
1083 16
1140 17
1007 18
1277 19
1825 20
1050 21
1322 22
1190 23
1777 24
1045 25
1558 26
1038 27
1647 28
1077 29
1101 30
1755 31
1260 32
1125 33
1161 34
1332 35...

result:

ok Accepted with 2164+999 operations,sum of size(s)=15554+4701

Test #52:

score: 12
Accepted
time: 51ms
memory: 39716kb

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
443 1000 16487 1396
1515 1
1159 2
1988 3
1428 4
1188 5
1183 6
1532 7
1246 8
1686 9
1807 10
1506 11
1018 12
1524 13
1655 14
1043 15
1328 16
1456 17
1027 18
1672 19
1764 20
1347 21
1760 22
1110 23
1155 24
1069 25
1726 26
1640 27
1150 28
1283 29
1352 30
1400 31
1509 32
1677 33
1850 34
1903 35...

result:

ok Accepted with 443+1000 operations,sum of size(s)=16487+1396

Test #53:

score: 12
Accepted
time: 47ms
memory: 37824kb

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
343 999 16723 1160
1663 1
1388 2
1417 3
1716 4
1404 5
1749 6
1451 7
1362 8
1225 9
1882 10
1430 11
1487 12
1868 13
1708 14
1092 15
1325 16
1733 17
1937 18
1541 19
1904 20
1950 21
1199 22
1505 23
1649 24
1096 25
1742 26
1724 27
1620 28
1419 29
1324 30
1771 31
1673 32
1929 33
1340 34
1823 35
...

result:

ok Accepted with 343+999 operations,sum of size(s)=16723+1160

Test #54:

score: 12
Accepted
time: 38ms
memory: 38956kb

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
327 998 16546 1301
1267 1
1506 2
1795 3
1761 4
1497 5
1551 6
1179 7
1013 8
1071 9
1255 10
1822 11
1966 12
1933 13
1648 14
1366 15
1836 16
1528 17
1570 18
1552 19
1635 20
1465 21
1373 22
1073 23
1226 24
1601 25
1066 26
1433 27
1986 28
1699 29
1913 30
1148 31
1386 32
1289 33
1842 34
1504 35
...

result:

ok Accepted with 327+998 operations,sum of size(s)=16546+1301

Test #55:

score: 12
Accepted
time: 48ms
memory: 39188kb

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
230 1000 16430 822
1326 1
1999 2
1059 3
1329 4
1394 5
1346 6
1831 7
1960 8
1018 9
1233 10
1636 11
1878 12
1384 13
1649 14
1255 15
1343 16
1458 17
1818 18
1040 19
1826 20
1637 21
1347 22
1935 23
1847 24
1950 25
1800 26
1882 27
1106 28
1491 29
1930 30
1256 31
1991 32
1613 33
1353 34
1767 35
...

result:

ok Accepted with 230+1000 operations,sum of size(s)=16430+822

Test #56:

score: 12
Accepted
time: 53ms
memory: 39328kb

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
215 998 15719 743
1048 1
1401 2
1944 3
1417 4
1971 5
1090 6
1561 7
1375 8
1454 9
1886 10
1022 11
1196 12
1344 13
1356 14
1709 15
1119 16
1274 17
1583 18
1322 19
1895 20
1312 21
1605 22
1634 23
1060 24
1123 25
1330 26
1946 27
1061 28
1930 29
1648 30
1573 31
1114 32
1777 33
1621 34
1278 35
1...

result:

ok Accepted with 215+998 operations,sum of size(s)=15719+743

Test #57:

score: 12
Accepted
time: 12ms
memory: 41252kb

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
24 999 16983 1143
1658 1
1211 2
1702 3
1298 4
1214 5
1701 6
1106 7
1729 8
1885 9
1268 10
1075 11
1056 12
1000 13
1989 14
1647 15
1642 16
1739 17
1023 18
1019 19
1021 20
1055 21
1761 22
1065 23
1834 24
1130 25
1195 26
1806 27
1877 28
1068 29
1878 30
1889 31
1563 32
1920 33
1565 34
1041 35
1...

result:

ok Accepted with 24+999 operations,sum of size(s)=16983+1143

Test #58:

score: 12
Accepted
time: 10ms
memory: 40516kb

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
26 1000 18000 482
1939 1
1604 2
1220 3
1740 4
1734 5
1182 6
1601 7
1728 8
1597 9
1707 10
1594 11
1135 12
1132 13
1124 14
1691 15
1107 16
1684 17
1090 18
1586 19
1081 20
1057 21
1044 22
1016 23
1035 24
1680 25
1022 26
1019 27
1578 28
1571 29
1988 30
1041 31
1040 32
1566 33
1977 34
1559 35
1...

result:

ok Accepted with 26+1000 operations,sum of size(s)=18000+482

Subtask #7:

score: 14
Accepted

Test #59:

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

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
1679 1231 14883 3693
1984 1
1615 2
1182 3
1964 4
1917 5
1565 6
1454 7
1487 8
1901 9
1208 10
1457 11
1660 12
1284 13
1609 14
1180 15
1140 16
1802 17
1243 18
1669 19
1421 20
1873 21
1203 22
1439 23
1791 24
1868 25
1696 26
1752 27
1330 28
1796 29
1587 30
1246 31
1389 32
1790 33
1857 34
1538 3...

result:

ok Accepted with 1679+1231 operations,sum of size(s)=14883+3693

Test #60:

score: 14
Accepted
time: 30ms
memory: 40580kb

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
326 1521 20335 652
1916 1
1006 2
1169 3
1653 4
1883 5
1838 6
1861 7
1233 8
1737 9
1344 10
1487 11
1361 12
1854 13
1957 14
1888 15
1264 16
1610 17
1756 18
1996 19
1958 20
1644 21
1896 22
1144 23
1396 24
1408 25
1316 26
1518 27
1199 28
1055 29
1736 30
1863 31
1231 32
1195 33
1668 34
1431 35
...

result:

ok Accepted with 326+1521 operations,sum of size(s)=20335+652

Test #61:

score: 14
Accepted
time: 42ms
memory: 40680kb

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
1867 1863 16893 3751
1924 1
1102 2
1644 3
1819 4
1500 5
1951 6
1021 7
1896 8
1958 9
1775 10
1679 11
1812 12
1284 13
1734 14
1404 15
1535 16
1098 17
1654 18
1715 19
1875 20
1773 21
1526 22
1764 23
1582 24
1461 25
1532 26
1509 27
1297 28
1807 29
1790 30
1882 31
1212 32
1858 33
1436 34
1056 3...

result:

ok Accepted with 1867+1863 operations,sum of size(s)=16893+3751

Test #62:

score: 14
Accepted
time: 35ms
memory: 41600kb

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
1695 1286 15347 3717
1557 1
1721 2
1230 3
1404 4
1157 5
1762 6
1761 7
1062 8
1622 9
1501 10
1497 11
1513 12
1580 13
1523 14
1182 15
1110 16
1333 17
1479 18
1105 19
1545 20
1502 21
1256 22
1547 23
1530 24
1507 25
1154 26
1316 27
1084 28
1384 29
1098 30
1693 31
1601 32
1964 33
1028 34
1708 3...

result:

ok Accepted with 1695+1286 operations,sum of size(s)=15347+3717

Test #63:

score: 14
Accepted
time: 48ms
memory: 40836kb

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
1297 1425 16122 3494
1611 1
1040 2
1660 3
1314 4
1231 5
1376 6
1551 7
1266 8
1662 9
1196 10
1839 11
1931 12
1724 13
1326 14
1173 15
1188 16
1348 17
1373 18
1714 19
1872 20
1847 21
1935 22
1864 23
1061 24
1423 25
1708 26
1132 27
1128 28
1485 29
1281 30
1416 31
1694 32
1831 33
1401 34
1555 3...

result:

ok Accepted with 1297+1425 operations,sum of size(s)=16122+3494

Test #64:

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

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
1353 1559 16259 3438
1369 1
1894 2
1689 3
1666 4
1594 5
1315 6
1443 7
1572 8
1411 9
1997 10
1073 11
1172 12
1790 13
1769 14
1730 15
1397 16
1074 17
1090 18
1402 19
1934 20
1437 21
1418 22
1077 23
1885 24
1819 25
1963 26
1595 27
1565 28
1940 29
1125 30
1494 31
1454 32
1314 33
1613 34
1101 3...

result:

ok Accepted with 1353+1559 operations,sum of size(s)=16259+3438

Test #65:

score: 14
Accepted
time: 51ms
memory: 41664kb

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
1302 1531 16925 3384
1131 1
1096 2
1553 3
1281 4
1286 5
1982 6
1459 7
1740 8
1261 9
1376 10
1508 11
1068 12
1657 13
1886 14
1491 15
1392 16
1051 17
1887 18
1888 19
1327 20
1680 21
1962 22
1979 23
1372 24
1277 25
1420 26
1643 27
1323 28
1919 29
1026 30
1671 31
1229 32
1926 33
1460 34
1398 3...

result:

ok Accepted with 1302+1531 operations,sum of size(s)=16925+3384

Test #66:

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

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
25 1998 19980 1220
1946 1
1719 2
1334 3
1338 4
1346 5
1348 6
1351 7
1733 8
1800 9
1399 10
1812 11
1783 12
1325 13
1387 14
1827 15
1965 16
1923 17
1050 18
1288 19
1621 20
1344 21
1382 22
1635 23
1232 24
1082 25
1349 26
1651 27
1255 28
1263 29
1269 30
1755 31
1741 32
1299 33
1314 34
1606 35
...

result:

ok Accepted with 25+1998 operations,sum of size(s)=19980+1220

Test #67:

score: 14
Accepted
time: 18ms
memory: 43100kb

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
27 1998 19980 423
1516 1
1747 2
1236 3
1227 4
1602 5
1599 6
1222 7
1472 8
1272 9
1199 10
1186 11
1181 12
1678 13
1843 14
1825 15
1352 16
1792 17
1403 18
1170 19
1925 20
1166 21
1163 22
1100 23
1418 24
1076 25
1082 26
1764 27
1089 28
1494 29
1092 30
1081 31
1668 32
1441 33
1117 34
1118 35
1...

result:

ok Accepted with 27+1998 operations,sum of size(s)=19980+423

Test #68:

score: 14
Accepted
time: 33ms
memory: 42972kb

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
2495 1997 15599 4990
1200 1
1069 2
1298 3
1297 4
1686 5
1808 6
1592 7
1862 8
1348 9
1547 10
1849 11
1128 12
1221 13
1561 14
1871 15
1516 16
1693 17
1122 18
1243 19
1845 20
1797 21
1813 22
1158 23
1621 24
1005 25
1196 26
1910 27
1525 28
1528 29
1507 30
1544 31
1034 32
1716 33
1919 34
1431 3...

result:

ok Accepted with 2495+1997 operations,sum of size(s)=15599+4990

Test #69:

score: 14
Accepted
time: 46ms
memory: 42356kb

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
2404 1976 14618 4851
1877 1
1646 2
1904 3
1862 4
1781 5
1261 6
1786 7
1707 8
1204 9
1265 10
1730 11
1503 12
1555 13
1418 14
1244 15
1957 16
1468 17
1791 18
1107 19
1803 20
1215 21
1967 22
1150 23
1413 24
1643 25
1991 26
1241 27
1563 28
1752 29
1539 30
1494 31
1839 32
1745 33
1770 34
1828 3...

result:

ok Accepted with 2404+1976 operations,sum of size(s)=14618+4851

Subtask #8:

score: 10
Accepted

Test #70:

score: 10
Accepted
time: 1287ms
memory: 202380kb

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
8720 6354 86147 19189
7871 1
7645 2
9834 3
7462 4
6305 5
9185 6
6263 7
9785 8
9099 9
6445 10
8030 11
9000 12
7822 13
9878 14
9005 15
6567 16
8984 17
9234 18
9698 19
6573 20
5600 21
6767 22
9539 23
9343 24
6506 25
5105 26
5349 27
6059 28
5718 29
6283 30
5047 31
7942 32
7558 33
7095 34
5883 ...

result:

ok Accepted with 8720+6354 operations,sum of size(s)=86147+19189

Test #71:

score: 10
Accepted
time: 2012ms
memory: 202884kb

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
2216 7550 131252 4442
8882 1
9383 2
9228 3
5590 4
8471 5
8711 6
9785 7
6496 8
6436 9
5221 10
6156 11
7246 12
7691 13
5521 14
6139 15
6554 16
7990 17
9909 18
5752 19
8306 20
7722 21
5442 22
5534 23
7833 24
8178 25
7466 26
9446 27
5605 28
6988 29
6522 30
9221 31
7119 32
9088 33
9092 34
9147 ...

result:

ok Accepted with 2216+7550 operations,sum of size(s)=131252+4442

Test #72:

score: 10
Accepted
time: 1588ms
memory: 202364kb

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
9277 9480 106424 18577
5375 1
5294 2
5331 3
9632 4
9786 5
5931 6
6363 7
7330 8
8312 9
9431 10
5527 11
5380 12
8778 13
5170 14
7062 15
9660 16
5962 17
9570 18
8001 19
6157 20
9130 21
8557 22
7774 23
6058 24
7144 25
8020 26
7946 27
7076 28
9285 29
8699 30
8429 31
6262 32
5332 33
6311 34
8647...

result:

ok Accepted with 9277+9480 operations,sum of size(s)=106424+18577

Test #73:

score: 10
Accepted
time: 1246ms
memory: 202456kb

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
8680 6437 90416 19033
5409 1
7671 2
6019 3
8296 4
9655 5
6085 6
9426 7
8204 8
5096 9
7425 10
9961 11
8134 12
8946 13
6415 14
7326 15
6862 16
8611 17
7985 18
5953 19
7294 20
7236 21
9176 22
8413 23
5914 24
6005 25
9199 26
9545 27
6787 28
7190 29
5495 30
9511 31
6751 32
7122 33
7859 34
8395 ...

result:

ok Accepted with 8680+6437 operations,sum of size(s)=90416+19033

Test #74:

score: 10
Accepted
time: 1526ms
memory: 202404kb

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
5882 7027 97290 16573
6210 1
5812 2
9648 3
8371 4
9517 5
9149 6
9518 7
6678 8
6655 9
7926 10
7826 11
7655 12
9740 13
9303 14
7649 15
7313 16
6759 17
6918 18
6431 19
5029 20
8998 21
5076 22
7239 23
8355 24
7018 25
6823 26
7814 27
6814 28
7676 29
9935 30
9022 31
6091 32
9563 33
6821 34
8163 ...

result:

ok Accepted with 5882+7027 operations,sum of size(s)=97290+16573

Test #75:

score: 10
Accepted
time: 1717ms
memory: 202436kb

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
6237 7571 97364 17036
9267 1
6547 2
7308 3
5019 4
6286 5
7825 6
7625 7
9935 8
9005 9
6866 10
7761 11
5820 12
8121 13
7261 14
6821 15
6720 16
6119 17
8396 18
5544 19
5125 20
6335 21
6594 22
9740 23
9256 24
8337 25
7662 26
8077 27
5742 28
6474 29
9830 30
6640 31
5292 32
7821 33
5104 34
5468 ...

result:

ok Accepted with 6237+7571 operations,sum of size(s)=97364+17036

Test #76:

score: 10
Accepted
time: 1734ms
memory: 202368kb

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
5503 7259 95715 16205
6453 1
5987 2
7130 3
5946 4
8139 5
6265 6
7380 7
6958 8
7242 9
8121 10
7888 11
6517 12
9948 13
7935 14
9776 15
9239 16
8542 17
7898 18
8271 19
7772 20
5353 21
5558 22
5150 23
5835 24
7725 25
9755 26
5687 27
6691 28
9922 29
7584 30
5425 31
6814 32
8217 33
5229 34
7071 ...

result:

ok Accepted with 5503+7259 operations,sum of size(s)=95715+16205

Test #77:

score: 10
Accepted
time: 711ms
memory: 202580kb

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
33 9998 109978 3682
5213 1
5174 2
6085 3
5175 4
5187 5
6137 6
9261 7
5211 8
8647 9
6358 10
5226 11
9186 12
6163 13
5231 14
6178 15
6070 16
8933 17
5239 18
6213 19
9834 20
5243 21
6230 22
8925 23
5173 24
6248 25
6257 26
6261 27
5885 28
6739 29
5894 30
5905 31
5911 32
5943 33
8255 34
5319 35...

result:

ok Accepted with 33+9998 operations,sum of size(s)=109978+3682

Test #78:

score: 10
Accepted
time: 760ms
memory: 202588kb

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
31 10000 120000 4504
7061 1
5333 2
5077 3
7075 4
5121 5
5129 6
5131 7
5132 8
5138 9
5147 10
5336 11
5153 12
5165 13
5076 14
5188 15
5206 16
5209 17
5339 18
5249 19
7573 20
5283 21
5353 22
5352 23
6051 24
5363 25
7387 26
5360 27
9819 28
5435 29
9914 30
9922 31
9923 32
9929 33
5423 34
9943 3...

result:

ok Accepted with 31+10000 operations,sum of size(s)=120000+4504

Test #79:

score: 10
Accepted
time: 1566ms
memory: 202528kb

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
12320 9972 97240 24702
8795 1
7687 2
5516 3
8168 4
6711 5
5069 6
6390 7
7411 8
7734 9
7860 10
9765 11
7491 12
8538 13
7036 14
5446 15
6704 16
8961 17
5680 18
7529 19
5848 20
6858 21
6987 22
7309 23
8857 24
6502 25
7150 26
7572 27
9271 28
8790 29
7149 30
6014 31
7674 32
6031 33
9757 34
9768...

result:

ok Accepted with 12320+9972 operations,sum of size(s)=97240+24702

Test #80:

score: 10
Accepted
time: 1660ms
memory: 202476kb

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
12136 9959 92811 24389
7207 1
8685 2
8159 3
7628 4
5060 5
6367 6
7874 7
8137 8
5282 9
5702 10
5407 11
8311 12
8297 13
9706 14
6678 15
7250 16
5525 17
8072 18
5354 19
9511 20
7178 21
5531 22
9578 23
5610 24
6582 25
5462 26
9419 27
9914 28
7158 29
8461 30
6918 31
6636 32
6085 33
6368 34
6029...

result:

ok Accepted with 12136+9959 operations,sum of size(s)=92811+24389

Subtask #9:

score: 27
Accepted

Test #81:

score: 27
Accepted
time: 1214ms
memory: 202396kb

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
8655 6474 89655 18954
7029 1
8311 2
9611 3
8266 4
9205 5
6226 6
5632 7
6439 8
9941 9
5363 10
6232 11
6887 12
6208 13
7996 14
7736 15
5857 16
5663 17
5225 18
7957 19
8856 20
6032 21
6914 22
8824 23
8012 24
6035 25
9044 26
6933 27
7597 28
5216 29
8792 30
8799 31
9869 32
5806 33
5943 34
6085 ...

result:

ok Accepted with 8655+6474 operations,sum of size(s)=89655+18954

Test #82:

score: 27
Accepted
time: 1998ms
memory: 202884kb

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
2426 7627 130921 4871
9794 1
8875 2
8065 3
8732 4
7326 5
7270 6
8500 7
9319 8
9481 9
9886 10
5839 11
8947 12
6300 13
8071 14
8211 15
8331 16
7142 17
5411 18
5511 19
5579 20
5743 21
8269 22
6705 23
7323 24
9591 25
8307 26
5680 27
7050 28
9125 29
7322 30
7319 31
8990 32
6009 33
9736 34
5882 ...

result:

ok Accepted with 2426+7627 operations,sum of size(s)=130921+4871

Test #83:

score: 27
Accepted
time: 1590ms
memory: 202492kb

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
9088 9545 105914 18207
9529 1
7890 2
9208 3
9772 4
7205 5
9734 6
6493 7
7755 8
6267 9
7405 10
7594 11
5953 12
5794 13
9358 14
9570 15
5121 16
7118 17
9297 18
7810 19
7539 20
7936 21
9183 22
5667 23
7248 24
6306 25
9234 26
8567 27
6517 28
5710 29
8585 30
6542 31
9440 32
9252 33
7026 34
8861...

result:

ok Accepted with 9088+9545 operations,sum of size(s)=105914+18207

Test #84:

score: 27
Accepted
time: 1809ms
memory: 202416kb

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
9463 9851 102352 18976
6072 1
6919 2
7053 3
8044 4
6207 5
6293 6
8406 7
7092 8
6064 9
9939 10
5900 11
9243 12
5605 13
8672 14
6699 15
8021 16
8578 17
6397 18
5936 19
5034 20
8644 21
9103 22
8798 23
9453 24
7039 25
5965 26
7616 27
8187 28
5646 29
5239 30
9809 31
8968 32
5809 33
7292 34
8057...

result:

ok Accepted with 9463+9851 operations,sum of size(s)=102352+18976

Test #85:

score: 27
Accepted
time: 1631ms
memory: 202420kb

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
4562 7066 104554 16384
6806 1
6397 2
6149 3
6313 4
6340 5
8927 6
5908 7
9172 8
9112 9
5528 10
6520 11
9937 12
5587 13
8202 14
6557 15
6863 16
6013 17
5211 18
9548 19
6886 20
6075 21
7799 22
7803 23
6712 24
5625 25
5353 26
7993 27
7162 28
8515 29
8766 30
7398 31
6218 32
5677 33
6796 34
8539...

result:

ok Accepted with 4562+7066 operations,sum of size(s)=104554+16384

Test #86:

score: 27
Accepted
time: 1501ms
memory: 202648kb

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
3602 6473 106090 16453
9463 1
9276 2
7140 3
5787 4
6993 5
5100 6
5923 7
6504 8
8133 9
6549 10
9134 11
5515 12
7885 13
8875 14
9321 15
6436 16
5668 17
6305 18
5051 19
8766 20
9620 21
8904 22
8633 23
9222 24
6181 25
6266 26
5201 27
7878 28
9795 29
5473 30
9258 31
5831 32
5886 33
5015 34
7740...

result:

ok Accepted with 3602+6473 operations,sum of size(s)=106090+16453

Test #87:

score: 27
Accepted
time: 1565ms
memory: 202664kb

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
4173 6996 102732 15896
5037 1
6387 2
8353 3
5064 4
6606 5
9524 6
7066 7
7787 8
9088 9
9597 10
9794 11
5260 12
7037 13
6558 14
9432 15
7219 16
9991 17
5134 18
9023 19
5579 20
8784 21
7218 22
6436 23
6501 24
9603 25
6099 26
7089 27
7987 28
5504 29
8355 30
5008 31
7921 32
9118 33
9044 34
7036...

result:

ok Accepted with 4173+6996 operations,sum of size(s)=102732+15896

Test #88:

score: 27
Accepted
time: 1228ms
memory: 202212kb

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
8687 6423 93541 18946
8611 1
5459 2
7644 3
8212 4
6911 5
8232 6
8405 7
5425 8
8750 9
7643 10
7181 11
8389 12
9284 13
9546 14
8708 15
8155 16
6443 17
5324 18
7114 19
6315 20
6382 21
9649 22
9889 23
5794 24
9376 25
7229 26
8227 27
8264 28
8803 29
8834 30
7199 31
5126 32
8988 33
7100 34
6438 ...

result:

ok Accepted with 8687+6423 operations,sum of size(s)=93541+18946

Test #89:

score: 27
Accepted
time: 1542ms
memory: 202440kb

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
6441 7303 95714 17106
5260 1
5608 2
8342 3
5368 4
6812 5
9158 6
6152 7
7623 8
9573 9
7620 10
8042 11
5783 12
7399 13
8862 14
9252 15
6184 16
5107 17
6496 18
9596 19
5140 20
5990 21
9084 22
8226 23
8949 24
6251 25
7866 26
5423 27
9875 28
9007 29
5480 30
9750 31
7654 32
5282 33
8280 34
6655 ...

result:

ok Accepted with 6441+7303 operations,sum of size(s)=95714+17106

Test #90:

score: 27
Accepted
time: 1730ms
memory: 202452kb

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
6288 7576 99873 16795
8598 1
6158 2
5627 3
9669 4
9501 5
8891 6
7607 7
9521 8
9634 9
8268 10
7346 11
9392 12
7952 13
9069 14
5333 15
8219 16
5567 17
6439 18
5152 19
7830 20
8638 21
6950 22
8747 23
7261 24
7081 25
6912 26
9295 27
8324 28
8661 29
7527 30
6567 31
5109 32
6955 33
6598 34
6126 ...

result:

ok Accepted with 6288+7576 operations,sum of size(s)=99873+16795

Test #91:

score: 27
Accepted
time: 1627ms
memory: 202392kb

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
5658 7310 98183 16656
9180 1
6149 2
6685 3
7008 4
7821 5
9515 6
7424 7
5830 8
5529 9
9730 10
8329 11
8602 12
6446 13
8741 14
7426 15
5690 16
5249 17
9305 18
9908 19
9533 20
6514 21
5352 22
6108 23
9412 24
9817 25
6994 26
6795 27
6038 28
9735 29
8964 30
9746 31
5514 32
7111 33
8134 34
9103 ...

result:

ok Accepted with 5658+7310 operations,sum of size(s)=98183+16656

Test #92:

score: 27
Accepted
time: 723ms
memory: 202576kb

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
32 9996 109956 3347
7498 1
8195 2
8198 3
7993 4
9450 5
8201 6
8203 7
8209 8
9468 9
9471 10
6796 11
6797 12
8223 13
8233 14
8010 15
8240 16
9479 17
8259 18
8260 19
8267 20
8268 21
9490 22
8282 23
8283 24
8156 25
8124 26
6570 27
6575 28
9522 29
8641 30
8086 31
8091 32
6665 33
6767 34
8106 35...

result:

ok Accepted with 32+9996 operations,sum of size(s)=109956+3347

Test #93:

score: 27
Accepted
time: 766ms
memory: 202660kb

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
31 10000 120000 4517
9093 1
9347 2
7183 3
9129 4
6421 5
9083 6
5284 7
6660 8
9061 9
9054 10
5621 11
6565 12
9303 13
6465 14
5804 15
9251 16
7728 17
5931 18
5835 19
9202 20
5424 21
9810 22
5710 23
5488 24
6261 25
6035 26
6228 27
6206 28
6299 29
6028 30
8329 31
8295 32
8434 33
6088 34
5034 3...

result:

ok Accepted with 31+10000 operations,sum of size(s)=120000+4517

Test #94:

score: 27
Accepted
time: 1593ms
memory: 202540kb

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
12107 9957 94659 24311
6959 1
7961 2
9162 3
7335 4
9240 5
9389 6
9079 7
8560 8
8355 9
5411 10
8562 11
5752 12
7659 13
7378 14
8986 15
5455 16
8707 17
5453 18
5903 19
9602 20
5796 21
9345 22
9129 23
6604 24
8989 25
6017 26
8242 27
8916 28
5172 29
5374 30
6505 31
7104 32
7747 33
5162 34
6994...

result:

ok Accepted with 12107+9957 operations,sum of size(s)=94659+24311

Test #95:

score: 27
Accepted
time: 1619ms
memory: 202476kb

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
12199 9956 96937 24495
8907 1
9163 2
5438 3
8262 4
5517 5
9799 6
8035 7
5246 8
5449 9
7878 10
8803 11
8432 12
8204 13
8270 14
8724 15
6307 16
5036 17
9456 18
9819 19
6198 20
8259 21
5595 22
6139 23
9013 24
6145 25
8656 26
9250 27
6797 28
5120 29
6696 30
5491 31
6981 32
5250 33
8976 34
6705...

result:

ok Accepted with 12199+9956 operations,sum of size(s)=96937+24495