QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#649888#3023. Winter FestivallichenghanAC ✓116ms38324kbC++144.2kb2024-10-18 11:22:442024-10-18 11:22:47

Judging History

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

  • [2024-10-18 11:22:47]
  • 评测
  • 测评结果:AC
  • 用时:116ms
  • 内存:38324kb
  • [2024-10-18 11:22:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
inline constexpr void chkmin(int& x,const int& y){ if(y<x) x=y; }
const int N=2e5+10;
const int trs[3][7]={{0,2,2,0,5,5,0},{0,3,0,3,6,0,6},{0,4,5,6,0,0,0}};
int n,m;
vector<int> g[N];
int dfn[N],low[N],dfcnt;
vector<int> g2[N]; int nc;
int stk[N],top;
void tarjan(int u,int fa){
	dfn[u]=low[u]=++dfcnt;
	stk[++top]=u;
	for(int v:g[u]) if(v!=fa){
		if(!dfn[v]){
			tarjan(v,u);
			if(low[v]==-1) {
				low[u]=-1;
				return;
			}
			if(low[v]<dfn[u]){
				if(low[u]!=dfn[u]){
					low[u]=-1;
					return;
				}else{
					low[u]=low[v];
				}
			}
			if(low[v]==dfn[u]){
				// make ring
				int ring=++nc;
				g2[ring].clear();
				g2[u].push_back(ring);
				while(stk[top]!=v){
					int w=stk[top--];
					g2[ring].push_back(w);
				}
				top--;
				g2[ring].push_back(v);
			}else if(low[v]>dfn[u]){
				// make tree edge
				g2[u].push_back(v);
				while(stk[top]!=v) top--; top--;
			}
		}else if(dfn[v]<dfn[u]){
			if(low[u]!=dfn[u]){
				low[u]=-1;
				return;
			}else{
				low[u]=dfn[v];
			}
		}
	}
}
struct DP{
	int a[7];
	DP(){ memset(a,0x3f,sizeof(a)); }
	inline constexpr int& operator[](const int &x){ return a[x]; }
	inline constexpr const int& operator[](const int &x) const { return a[x]; }
	inline void clear(){ memset(a,0x3f,sizeof(a)); }
	inline friend DP operator+(DP ls,const DP& rs){ for(int i=1;i<=6;i++) chkmin(ls[i],rs[i]); return ls; }
	void print(){ for(int i=1;i<=6;i++) if(a[i]>1e9) printf("x "); else printf("%d ",a[i]); }
};
DP merge(const DP& u,const DP& v,int w){
	auto T=trs[w];
	DP nu;
	for(int s=1;s<=6;s++) {
		int ns=T[s];
		if(ns) for(int t=1;t<=6;t++) if(T[t]) chkmin(nu[ns],u[s]+v[t]+w);
	}
	return nu;
}
DP trans(const DP& u,int w){
	auto T=trs[w];
	DP nu;
	for(int i=1;i<=6;i++) if(T[i]) {
		chkmin(nu[T[i]],u[i]+w);
	}
	return nu;
}
DP dtrans(const DP& u,int w){
	auto T=trs[w];
	DP nu;
	for(int i=1;i<=6;i++) if(T[i]) {
		chkmin(nu[T[i]],u[i]);
	}
	return nu;
}
DP f[N];
void dfs(int u,int fa){
//	printf("dfs %d %d\n",u,fa);
	f[u][1]=0;
	for(int v:g2[u]) if(v!=fa){
		if(v<=n){
			dfs(v,u);
			f[u]=merge(f[u],f[v],0)+merge(f[u],f[v],1)+merge(f[u],f[v],2);
		}else{
//			printf("ring %d\n",v);
			vector<int>& V=g2[v];
			for(int w:V) dfs(w,v);
			DP _[2][3][2];
			auto F=_[0],G=_[1];
			F[0][0]=trans(f[V[0]],0);
			F[1][1]=trans(f[V[0]],1);
			F[2][0]=trans(f[V[0]],2);
//			for(int s:{0,1,2}) for(int c:{0,1}) {
//				printf("F[%d][%d]: ",s,c);
//				F[s][c].print(); puts("");
//			}
//			puts("");
			for(int i=1;i<V.size();i++){
				swap(F,G);
				memset(F,0x3f,sizeof(_[0]));
				for(int s:{0,1,2}) for(int c:{0,1}) for(int w:{0,1,2}){
					F[s][c^(w&1)]=F[s][c^(w&1)]+merge(f[V[i]],G[s][c],w);
				}
//				for(int s:{0,1,2}) for(int c:{0,1}) {
//					printf("F[%d][%d]: ",s,c);
//					F[s][c].print(); puts("");
//				}
//				puts("");
//				printf("F[0]: "); F[0].print(); puts("");
//				printf("F[1]: "); F[1].print(); puts("");
			}
			f[u]=
			merge(dtrans(f[u],0),F[0][1],0)+
			merge(dtrans(f[u],1),F[1][1],0)+
			merge(dtrans(f[u],2),F[2][1],0)+
			merge(dtrans(f[u],0),F[0][0],1)+
			merge(dtrans(f[u],1),F[1][0],1)+
			merge(dtrans(f[u],2),F[2][0],1)+
			merge(dtrans(f[u],0),F[0][1],2)+
			merge(dtrans(f[u],1),F[1][1],2)+
			merge(dtrans(f[u],2),F[2][1],2);
		}
	}
//	printf("f[%d]: ",u); f[u].print(); puts("");
}
void solve(){
	cin>>n>>m;
	memset(f,0x3f,sizeof(f));
	for(int i=1;i<=n;i++){
		g[i].clear(); g2[i].clear();
		f[i].clear(); dfn[i]=0;
	}
	nc=n;
	for(int i=1;i<=m;i++){
		int u,v;
		cin>>u>>v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int ans=0;
	for(int i=1;i<=n;i++) if(!dfn[i]) {
		top=0;
		tarjan(i,i);
		if(low[i]==-1){
			cout<<"-1\n";
//			cout<<("fhediwsahfewq\n");
			return;
		}
		dfs(i,i);
		int cur=min({f[i][6],f[i][1],f[i][2],f[i][3],f[i][4],f[i][5]});
		if(cur>=1e9) {
			cout<<"-1\n";
			return;
		}
		ans+=cur;
	}
	cout<<ans<<endl;
}
int main(){
//	ios::sync_with_stdio(false);
//	#ifndef LCH
//		freopen("tempest.in","r",stdin);
//		freopen("tempest.out","w",stdout);
//	#endif
//	int tc; cin>>tc;
//	while(tc--) {
//		solve();
////		cout<<"================"<<endl;
//	}
	solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 20776kb

input:

5 8
1 4
4 5
1 5
1 2
1 3
2 3
3 5
2 5

output:

-1

result:

ok 1 number(s): "-1"

Test #2:

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

input:

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

output:

5

result:

ok 1 number(s): "5"

Test #3:

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

input:

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

output:

5

result:

ok 1 number(s): "5"

Test #4:

score: 0
Accepted
time: 115ms
memory: 29744kb

input:

98914 99115
18941 69716
35399 56104
35350 54401
51089 76996
12917 67251
28170 98088
23222 92663
6070 13376
79958 94219
41337 96773
43117 59471
2667 89823
31689 53275
31872 77444
29364 80907
42941 76590
22462 76988
23270 71845
16696 22121
2697 32372
25300 53759
43409 86432
744 57013
47426 87500
23453...

output:

1010

result:

ok 1 number(s): "1010"

Test #5:

score: 0
Accepted
time: 110ms
memory: 38192kb

input:

100000 100000
70374 83632
22315 72042
86312 94299
29671 57391
41483 61747
6443 10446
64390 86953
61691 96696
14802 95425
60057 78083
16116 75711
12605 52853
1557 67740
45352 84246
21510 29707
33822 55984
6557 75155
64617 96033
59618 98657
29789 55485
68409 73045
7498 79289
67116 77059
9967 28532
457...

output:

5

result:

ok 1 number(s): "5"

Test #6:

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

input:

3 2
1 2
1 3

output:

0

result:

ok 1 number(s): "0"

Test #7:

score: 0
Accepted
time: 4ms
memory: 20768kb

input:

3 3
1 3
2 3
1 2

output:

3

result:

ok 1 number(s): "3"

Test #8:

score: 0
Accepted
time: 4ms
memory: 20892kb

input:

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

output:

6

result:

ok 1 number(s): "6"

Test #9:

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

input:

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

output:

7

result:

ok 1 number(s): "7"

Test #10:

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

input:

2 1
1 2

output:

0

result:

ok 1 number(s): "0"

Test #11:

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

input:

100000 1
49466 73650

output:

0

result:

ok 1 number(s): "0"

Test #12:

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

input:

13 15
3 6
2 11
7 11
4 10
8 13
5 9
3 13
1 8
9 12
6 7
1 9
5 12
1 4
2 9
1 10

output:

11

result:

ok 1 number(s): "11"

Test #13:

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

input:

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

output:

8

result:

ok 1 number(s): "8"

Test #14:

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

input:

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

output:

11

result:

ok 1 number(s): "11"

Test #15:

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

input:

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

output:

5

result:

ok 1 number(s): "5"

Test #16:

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

input:

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

output:

10

result:

ok 1 number(s): "10"

Test #17:

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

input:

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

output:

-1

result:

ok 1 number(s): "-1"

Test #18:

score: 0
Accepted
time: 116ms
memory: 38324kb

input:

99999 99999
77212 83392
12002 12568
39773 53816
16498 46768
74296 88869
17682 32658
56234 85723
5240 56421
11172 76019
42040 94184
74920 90323
23116 78059
27281 65224
14505 92565
48511 82745
22310 87191
59043 91586
8032 34214
26234 52635
10631 82852
36743 69069
32581 53971
21264 44293
13731 90662
79...

output:

5

result:

ok 1 number(s): "5"

Test #19:

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

input:

15 21
5 8
4 6
8 9
8 11
3 8
6 11
1 10
4 15
2 3
12 13
8 10
4 13
2 8
4 12
6 14
4 14
6 8
1 8
5 9
4 7
7 15

output:

21

result:

ok 1 number(s): "21"

Test #20:

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

input:

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

output:

31

result:

ok 1 number(s): "31"

Test #21:

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

input:

37 43
15 33
17 31
21 37
12 37
16 28
1 7
3 20
13 14
30 34
15 22
2 23
11 23
31 36
5 29
12 33
25 26
4 34
20 29
6 30
32 36
7 19
22 23
11 27
21 26
3 35
23 24
13 30
13 36
8 36
18 19
10 14
8 18
5 20
20 30
28 30
4 10
17 27
2 32
24 25
9 16
30 35
6 9
1 13

output:

33

result:

ok 1 number(s): "33"

Test #22:

score: 0
Accepted
time: 108ms
memory: 34948kb

input:

77796 99998
5286 73026
53371 67735
15388 77407
5197 40286
27407 49853
42516 59612
47756 47814
70447 76757
38535 58841
13118 32183
18840 29793
36335 55570
33572 73384
17372 33619
7869 14069
10339 30606
3118 7971
73929 77228
47550 69859
2050 47913
5427 77327
17329 43882
51703 69045
10152 61539
4804 42...

output:

101719

result:

ok 1 number(s): "101719"

Test #23:

score: 0
Accepted
time: 116ms
memory: 29092kb

input:

96125 99970
29862 40825
42266 65500
29871 68997
24950 33259
67255 85841
4395 46118
57480 65089
15607 29986
57011 69210
50116 69978
55881 79062
10806 68386
6930 15699
35072 67710
2063 92919
12390 24199
18941 59526
839 69067
8227 14657
19727 19977
27154 91137
39365 43012
38360 49227
70066 78617
77417 ...

output:

19158

result:

ok 1 number(s): "19158"

Test #24:

score: 0
Accepted
time: 101ms
memory: 28252kb

input:

93131 93149
60292 82086
19152 60939
33833 82566
9324 46947
29505 85685
42678 87021
20673 70709
28620 66298
2259 74137
41876 85953
21587 76249
50960 86353
36554 75540
66233 88117
7042 40150
43662 61963
18446 51586
6266 62670
5799 73506
15431 17700
1481 70252
18736 65846
39608 91994
19508 81920
75005 ...

output:

95

result:

ok 1 number(s): "95"

Test #25:

score: 0
Accepted
time: 65ms
memory: 25728kb

input:

100000 99999
32001 98446
85553 95218
93977 96989
33612 35931
19217 75233
20761 38161
26710 34898
39391 83354
3961 9893
16954 65868
48340 50333
29694 86048
48278 74935
43748 57900
1398 10416
35876 60338
51015 91862
64991 66774
63986 71818
7928 56360
23991 62141
38173 80786
20435 95289
76637 78924
180...

output:

0

result:

ok 1 number(s): "0"

Test #26:

score: 0
Accepted
time: 65ms
memory: 25784kb

input:

99999 99999
68651 80571
12839 61483
6124 17594
33526 87499
46444 96488
15992 73157
30999 92293
67860 74304
13672 77943
28923 63348
31346 86799
27672 95183
6244 62160
23980 39608
46807 92702
19261 39413
33187 76134
15095 80667
24357 59915
31075 94892
5969 26919
40567 57754
15030 25758
59726 95587
917...

output:

488

result:

ok 1 number(s): "488"

Test #27:

score: 0
Accepted
time: 62ms
memory: 25644kb

input:

99999 99999
7328 63739
11222 55311
12835 37272
50997 55591
54501 64557
19140 30769
91418 93435
47934 72019
23747 82695
41 36616
8594 21124
18300 21483
39755 56595
31806 49105
60404 60698
63187 68099
46263 80103
76671 96070
54910 62179
29159 52444
61150 88614
54312 83027
16947 21562
16199 45250
30039...

output:

5

result:

ok 1 number(s): "5"

Test #28:

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

input:

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

output:

25

result:

ok 1 number(s): "25"

Test #29:

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

input:

44 50
7 10
18 38
1 14
23 36
9 27
31 43
3 9
41 43
17 18
24 25
12 36
29 33
1 3
19 25
30 32
21 26
10 30
16 17
13 21
7 16
14 33
23 44
28 35
18 37
8 22
31 41
4 42
4 15
5 39
8 42
6 36
27 39
3 22
22 24
17 32
6 37
27 34
11 40
2 12
9 29
5 34
2 38
23 35
13 28
26 41
15 19
11 44
20 26
3 10
20 40

output:

34

result:

ok 1 number(s): "34"

Test #30:

score: 0
Accepted
time: 101ms
memory: 24544kb

input:

89653 89997
38674 43353
18131 29363
38972 43897
50433 85750
42818 55201
12696 53651
33078 33321
18996 38694
27781 35816
82016 84805
7076 45700
25515 81647
21329 23726
7387 70785
7849 70639
36142 42586
35552 48284
26123 80076
22573 43943
50600 61436
30672 32109
38073 64172
10812 23641
37762 73904
188...

output:

1725

result:

ok 1 number(s): "1725"

Test #31:

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

input:

89965 93346
81178 85119
21740 24963
62934 63694
18190 46869
2451 17921
17364 31350
22317 89701
4864 40486
59478 76173
51427 65159
26821 56245
29323 77662
7265 12300
11700 14977
34271 75739
47200 83263
22688 38937
28882 87945
19799 79424
20481 59751
56483 61064
50668 64641
52726 85765
14527 64735
328...

output:

16979

result:

ok 1 number(s): "16979"

Test #32:

score: 0
Accepted
time: 97ms
memory: 24868kb

input:

84996 98107
36420 42165
69262 84287
6446 47835
60590 72110
25081 42694
74965 84735
26729 48912
30142 57748
75915 77995
12997 64172
53492 75024
7842 47405
55878 64300
30187 77646
20554 84364
2889 15795
24962 72138
20218 58396
27704 33521
43042 62647
1091 29122
33985 70248
3426 3946
10627 56715
80022 ...

output:

66866

result:

ok 1 number(s): "66866"

Test #33:

score: 0
Accepted
time: 88ms
memory: 26568kb

input:

83030 83045
15395 30013
17650 24281
16791 28296
603 37194
30683 49429
58974 78286
8009 74862
972 51533
6347 81896
32201 54141
42657 82816
19161 49723
41294 60474
11742 45745
6804 70569
15097 40875
41391 79292
22129 28649
42196 50093
5808 38001
30077 75344
60323 76599
31006 50585
35577 81874
49892 78...

output:

80

result:

ok 1 number(s): "80"

Test #34:

score: 0
Accepted
time: 111ms
memory: 25144kb

input:

99596 99681
16631 49696
8895 67078
35204 78992
34012 45292
6572 60077
43455 76684
16431 44808
21755 58301
47095 87065
34732 48151
62494 66296
61741 84800
5857 17703
62491 79196
41403 53521
80602 90636
20470 76794
42957 67575
8451 41197
29488 94493
18585 55181
16266 99519
67127 80994
73312 86995
3443...

output:

18611

result:

ok 1 number(s): "18611"

Test #35:

score: 0
Accepted
time: 105ms
memory: 24296kb

input:

99938 93422
14551 80152
37207 89038
49995 59468
74716 95777
26850 64300
8379 35258
76635 81402
71062 89202
17189 17608
2138 83400
1595 88980
60015 72024
29063 39889
43297 87721
19577 25763
54181 77974
42382 96819
588 73038
77100 79239
45 46813
4024 28843
38450 95452
83751 96757
4281 56167
4367 82410...

output:

17513

result:

ok 1 number(s): "17513"

Test #36:

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

input:

90428 89916
59333 64008
21753 34044
25648 87546
17848 73493
64444 66616
26678 57537
69254 69813
29805 70188
47342 60128
28565 70352
34286 51432
10397 13033
40186 42367
22718 75505
44542 45199
32726 84255
11389 76119
12633 28828
54855 83235
16297 86414
72383 73762
39428 64342
6864 38707
3116 76976
10...

output:

16981

result:

ok 1 number(s): "16981"

Test #37:

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

input:

89979 92985
50696 53941
44678 80324
23350 61252
72434 81061
54656 68487
55639 72233
21470 69661
60860 63716
31005 85792
7150 26979
8188 13316
1283 67615
52317 87013
10034 53376
49766 49794
27332 52205
9012 79957
26947 63022
15392 61370
22631 58343
829 70813
53011 61463
65888 80143
6010 49106
18322 6...

output:

16726

result:

ok 1 number(s): "16726"

Test #38:

score: 0
Accepted
time: 109ms
memory: 24628kb

input:

99987 96655
4257 38596
13706 24746
10417 93342
22128 28214
46247 46295
65494 71690
67552 94371
21148 96098
46497 50044
25310 96749
6909 14080
8931 84842
15926 78607
66522 67988
22874 54363
38013 78039
45244 64408
44799 77652
1230 61663
68829 79947
25967 65048
63636 88759
24918 30784
44809 98314
4503...

output:

17636

result:

ok 1 number(s): "17636"

Test #39:

score: 0
Accepted
time: 105ms
memory: 24576kb

input:

94498 97532
62136 90843
51726 63389
18358 73251
33898 76896
14980 31101
51680 53877
18387 84422
15006 30850
25685 63585
53398 60100
41091 64022
68632 82289
5930 7282
9652 39717
17150 22934
64355 94031
7798 37508
39129 85277
66836 68327
50825 71550
9605 72401
16549 21450
11657 72737
959 80730
2175 78...

output:

17735

result:

ok 1 number(s): "17735"

Test #40:

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

input:

38 44
7 25
32 33
9 27
25 37
1 28
26 33
7 35
10 12
11 31
18 19
21 37
24 30
35 38
8 11
12 21
4 16
28 34
15 23
1 9
20 27
16 19
6 12
3 7
12 30
4 17
12 29
3 23
24 29
15 38
6 7
5 16
16 26
5 31
13 36
9 12
34 36
2 14
10 22
9 18
2 20
12 22
12 17
8 32
13 14

output:

35

result:

ok 1 number(s): "35"

Test #41:

score: 0
Accepted
time: 111ms
memory: 25008kb

input:

99165 99565
32192 69411
83519 87336
2087 15611
35039 74033
20535 75863
5099 24961
29284 48105
30776 57857
1757 82571
40948 57940
42920 88028
804 93579
5757 45172
56846 58664
4167 75852
74349 91995
10639 72354
51528 76731
4060 85525
7155 12033
29005 89256
29731 90543
13260 13846
54616 91399
4070 4307...

output:

2007

result:

ok 1 number(s): "2007"

Test #42:

score: 0
Accepted
time: 113ms
memory: 24652kb

input:

96241 99977
59607 68753
30495 37216
33418 79647
2127 87245
89097 92944
10687 93064
20542 32404
9053 88424
5417 41775
25833 82548
7298 64738
8922 24381
11432 71209
18327 30860
27528 33179
36120 49623
45331 46364
22775 92246
34999 43975
5197 14108
75483 80578
49789 61907
4979 61415
48000 72795
33174 6...

output:

18689

result:

ok 1 number(s): "18689"

Test #43:

score: 0
Accepted
time: 102ms
memory: 24588kb

input:

84668 99990
27317 53622
25700 32168
26212 37724
33549 48546
33664 47221
56019 77374
34687 39964
16225 70912
13022 24902
42982 43138
8325 59600
76659 82969
10149 78518
34694 68975
24079 26734
39741 59311
14108 74761
51441 62065
26544 57341
41790 46506
42147 73865
76074 82622
14836 48804
46374 72756
2...

output:

77343

result:

ok 1 number(s): "77343"

Test #44:

score: 0
Accepted
time: 102ms
memory: 26296kb

input:

93644 93659
37231 42243
49239 55784
4979 73889
15602 45173
18206 26034
9666 17399
820 55186
43765 75383
41448 90274
20581 75633
50149 59419
4025 87631
27040 66842
30482 86224
3617 47630
59649 69425
11216 42027
14544 56246
55392 79895
68114 69065
66191 70768
3238 41301
21624 69319
48264 82959
19740 3...

output:

80

result:

ok 1 number(s): "80"

Test #45:

score: 0
Accepted
time: 110ms
memory: 24596kb

input:

99620 99710
35673 93077
62102 85411
18411 81524
64851 66326
55249 73474
50192 60550
33026 83413
3428 30145
22826 44154
8743 41346
14721 84204
88517 90542
17404 58136
42797 53870
38289 75461
26005 74314
71753 78642
26923 72098
9260 69069
50906 98852
11853 86847
17454 20478
50250 93505
25162 78748
488...

output:

18812

result:

ok 1 number(s): "18812"

Test #46:

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

input:

99945 93331
50870 56281
46761 65571
24227 65221
58150 92560
22771 99813
3754 85073
35341 47436
21943 43895
15702 32781
5 21233
4065 41902
15923 20327
1220 72317
28035 49926
6475 60044
6338 33328
64157 94403
22256 50028
2334 31202
28412 61852
25092 83939
42474 99667
31664 34045
56403 99198
32522 3698...

output:

17397

result:

ok 1 number(s): "17397"

Test #47:

score: 0
Accepted
time: 101ms
memory: 24292kb

input:

91863 91731
54651 60835
57042 72184
1095 17011
35953 47486
14171 70022
26170 34967
57797 90682
1680 36369
9198 48096
34119 38421
45771 56529
19235 85308
22006 72776
33892 69170
31990 52006
12050 74565
18834 44795
57668 77377
1324 38286
14931 65794
9494 83539
41545 74507
70762 87271
13670 65132
33638...

output:

17233

result:

ok 1 number(s): "17233"

Test #48:

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

input:

99345 99533
49126 89269
44151 75269
36302 64967
24989 32997
62380 95775
16800 67704
65492 94003
72054 74007
39748 48258
87940 92527
33220 33511
49855 97054
77523 91217
32382 75756
50928 66429
43728 64130
31601 41216
48194 77483
49655 93775
35029 80116
35202 99031
37591 82755
26249 86441
26905 97279
...

output:

945

result:

ok 1 number(s): "945"

Test #49:

score: 0
Accepted
time: 88ms
memory: 25108kb

input:

99302 99512
27713 57696
21572 59569
23425 91628
40576 53281
9965 38372
3553 70223
25478 41808
62919 96398
147 60271
38324 64008
76496 86616
69992 73179
56702 89839
25633 66881
58199 81756
51698 56178
78281 87912
4159 33211
13031 25628
3344 48958
61060 65966
42583 54545
78437 83708
69703 79084
10688 ...

output:

1055

result:

ok 1 number(s): "1055"

Test #50:

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

input:

99591 99767
6413 55298
4162 88802
2583 13244
61217 82973
27741 29567
1030 29139
408 14814
22263 69629
64890 70889
79665 99264
31714 32318
62845 95247
14311 92978
54955 74460
12902 17197
17658 29951
19806 44086
23976 84623
66557 83001
10424 36274
22635 67897
17313 22515
20396 85874
24935 55329
52054 ...

output:

1143

result:

ok 1 number(s): "1143"

Test #51:

score: 0
Accepted
time: 21ms
memory: 22408kb

input:

48096 49971
7427 45074
31556 43453
8099 33397
16122 28437
1512 4707
28602 45933
38728 40333
2720 45966
10694 36024
33964 35162
24228 34806
8160 39669
1744 28746
27189 39887
17881 42410
28181 31128
14483 30557
6403 17846
694 46125
10921 39693
39070 41122
7549 44339
3738 14575
22676 37603
34502 42169
...

output:

-1

result:

ok 1 number(s): "-1"

Test #52:

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

input:

67881 94996
1274 62412
9892 41558
3347 25879
44123 54339
1994 33568
35076 57004
22136 36425
13706 28330
55643 66474
32709 39507
35191 55843
14619 46570
14949 33005
44845 53910
21678 35410
26531 57670
28706 56679
1030 62000
13053 27655
13309 21461
11585 42701
4073 13800
15824 60368
10281 20434
14825 ...

output:

108644

result:

ok 1 number(s): "108644"

Test #53:

score: 0
Accepted
time: 60ms
memory: 24016kb

input:

56963 75887
17583 44770
29873 47055
26234 32654
29005 39778
4885 50936
31064 53909
23883 25703
16133 19075
36675 51100
6690 40705
4590 42667
40739 54821
19926 40755
1639 4777
2828 50668
25465 48050
13557 33426
12339 31721
2142 23492
13658 30949
3300 13181
5820 43554
17324 51126
1290 53923
6277 53954...

output:

75331

result:

ok 1 number(s): "75331"

Test #54:

score: 0
Accepted
time: 4ms
memory: 20776kb

input:

30 41
12 26
12 20
13 25
5 23
5 17
13 16
10 23
2 13
1 12
11 27
15 22
8 16
24 30
6 18
13 22
12 17
11 22
11 21
2 9
1 14
21 27
17 30
4 19
3 12
4 28
10 17
18 29
20 26
9 25
12 22
13 17
19 28
3 14
6 29
7 15
4 11
22 29
17 24
4 29
8 13
7 22

output:

46

result:

ok 1 number(s): "46"

Test #55:

score: 0
Accepted
time: 55ms
memory: 22736kb

input:

49640 49964
7806 25898
40061 41961
13094 49291
40015 45472
21176 43430
1842 4357
16610 44910
10146 43961
6534 27549
34355 43472
40445 49374
20895 41064
9051 43270
28359 30576
24038 32589
7602 34462
13890 17639
14987 30669
9580 34676
9583 11912
18390 19753
13925 20006
39693 48484
20233 31443
25823 31...

output:

1911

result:

ok 1 number(s): "1911"

Test #56:

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

input:

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

output:

10

result:

ok 1 number(s): "10"

Test #57:

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

input:

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

output:

-1

result:

ok 1 number(s): "-1"

Test #58:

score: 0
Accepted
time: 4ms
memory: 20892kb

input:

5 3
2 3
1 2
3 4

output:

0

result:

ok 1 number(s): "0"

Test #59:

score: 0
Accepted
time: 4ms
memory: 20912kb

input:

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

output:

6

result:

ok 1 number(s): "6"

Test #60:

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

input:

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

output:

5

result:

ok 1 number(s): "5"

Test #61:

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

input:

1000 1000
301 302
174 175
400 401
340 341
156 157
166 167
331 332
536 537
376 377
269 270
313 314
642 643
469 470
309 310
136 137
524 525
66 67
982 983
500 501
231 232
916 917
246 247
605 606
809 810
59 60
553 554
94 95
23 24
48 49
1 1000
902 903
711 712
974 975
32 33
320 321
925 926
674 675
362 363...

output:

5

result:

ok 1 number(s): "5"

Test #62:

score: 0
Accepted
time: 23ms
memory: 24464kb

input:

20000 20000
7426 7427
19709 19710
17711 17712
10660 10661
2599 2600
8917 8918
11212 11213
17600 17601
9763 9764
5728 5729
243 244
14876 14877
15246 15247
912 913
10010 10011
5055 5056
13697 13698
4170 4171
15780 15781
15953 15954
5943 5944
2016 2017
53 54
7452 7453
13412 13413
11226 11227
18054 1805...

output:

5

result:

ok 1 number(s): "5"

Test #63:

score: 0
Accepted
time: 23ms
memory: 24400kb

input:

20000 19999
10975 10976
10864 10865
6033 6034
13839 13840
984 985
914 915
13812 13813
9516 9517
8239 8240
15854 15855
1682 1683
19033 19034
7832 7833
1758 1759
8234 8235
1781 1782
13482 13483
19735 19736
11416 11417
16251 16252
4216 4217
12478 12479
11325 11326
3659 3660
19373 19374
16785 16786
6967...

output:

5

result:

ok 1 number(s): "5"

Test #64:

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

input:

100 99
17 64
8 33
13 25
18 56
17 19
31 99
10 30
36 41
26 61
42 82
1 36
21 22
15 91
8 9
28 32
25 50
6 13
3 6
51 88
11 66
37 38
3 39
61 81
22 71
2 7
2 28
11 74
16 29
16 45
15 97
45 100
31 51
8 35
40 98
12 47
1 4
64 75
67 90
63 69
44 54
15 58
5 31
91 94
53 76
77 79
31 43
27 48
23 44
80 85
10 18
12 52
4...

output:

0

result:

ok 1 number(s): "0"

Test #65:

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

input:

500 499
68 172
223 290
12 27
8 48
2 4
309 478
142 345
83 361
317 483
46 118
12 112
142 209
66 70
339 489
8 316
3 26
7 94
12 34
85 264
63 153
235 266
307 326
12 213
178 450
7 68
193 297
71 152
57 66
88 333
262 324
74 214
57 496
367 448
258 282
178 382
341 356
290 437
50 108
19 43
106 332
292 311
267 ...

output:

0

result:

ok 1 number(s): "0"

Test #66:

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

input:

1000 999
78 226
571 583
3 16
81 95
688 774
95 677
57 61
795 903
192 559
693 847
478 519
2 46
465 681
59 321
160 458
100 230
188 855
108 243
90 372
12 72
709 845
241 467
286 868
504 876
150 457
571 759
76 606
205 318
697 700
128 673
16 292
2 88
347 709
336 343
153 217
150 479
150 455
228 387
282 434
...

output:

0

result:

ok 1 number(s): "0"

Test #67:

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

input:

299 300
212 213
225 226
232 233
1 201
47 48
123 124
41 42
49 50
105 106
43 44
248 249
280 281
109 110
157 158
274 275
45 46
22 23
18 19
1 2
213 214
189 190
116 117
134 135
233 234
279 280
217 218
179 180
17 18
30 31
78 79
284 285
154 155
77 78
59 60
221 222
152 153
68 69
101 102
55 56
251 252
119 12...

output:

10

result:

ok 1 number(s): "10"

Test #68:

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

input:

4999 5000
2761 2762
4472 4473
4249 4250
2722 2723
6 7
4720 4721
4268 4269
978 979
2164 2165
2430 2431
2525 2526
2306 2307
886 887
4902 4903
3334 3335
4667 4668
440 441
2864 2865
4321 4322
3889 3890
1420 1421
2127 2128
2626 2627
972 973
4023 4024
1553 1554
4708 4709
234 235
4465 4466
3822 3823
3823 3...

output:

10

result:

ok 1 number(s): "10"

Test #69:

score: 0
Accepted
time: 22ms
memory: 22928kb

input:

20000 20001
14757 14758
11594 11595
15527 15528
14634 14635
116 117
7861 7862
13171 13172
7956 7957
306 307
10289 10290
16257 16258
1057 1058
7470 7471
14259 14260
13902 13903
1378 1379
18391 18392
11335 11336
3705 3706
5250 5251
11655 11656
8260 8261
14135 14136
6149 6150
8280 8281
1339 1340
14055 ...

output:

10

result:

ok 1 number(s): "10"

Test #70:

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

input:

328 406
84 273
58 191
137 138
199 201
10 285
46 50
49 50
171 172
231 232
17 18
225 226
28 32
153 154
162 164
123 126
173 281
249 250
174 176
93 199
105 106
58 59
1 10
294 295
89 203
34 35
100 300
175 176
78 79
266 267
30 120
313 314
165 166
283 287
196 197
7 8
291 304
165 169
87 89
147 149
14 15
82 ...

output:

399

result:

ok 1 number(s): "399"

Test #71:

score: 0
Accepted
time: 4ms
memory: 20916kb

input:

3670 4169
2570 2576
1725 1989
1841 1842
1441 1445
2956 2964
1602 1603
1275 1276
3455 3456
2775 2776
54 3060
1736 1737
776 777
1859 1860
1622 1627
773 774
1452 1453
3566 3567
1066 1067
1064 1065
2631 2632
718 719
1304 1305
221 222
1704 1705
3418 3419
416 767
2552 2553
1925 1926
3054 3055
2444 2445
12...

output:

2521

result:

ok 1 number(s): "2521"

Test #72:

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

input:

3147 3895
556 557
908 1107
1248 1249
480 481
2890 2892
1644 1645
2819 2820
724 725
2049 2050
1245 1246
130 1507
2878 2880
425 426
962 963
2155 2158
1003 1004
2299 2300
1270 1893
1553 1869
835 836
2101 2847
1442 1485
165 166
1309 1310
1008 1009
986 1588
270 271
208 209
1825 1829
854 954
264 533
2086 ...

output:

3919

result:

ok 1 number(s): "3919"

Test #73:

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

input:

305 379
47 201
190 191
153 154
252 256
294 295
74 75
158 159
299 300
47 50
79 80
147 148
1 2
65 70
118 120
100 101
64 65
283 284
196 197
110 113
151 152
114 117
25 83
75 257
93 291
167 168
293 296
70 211
14 178
9 10
189 192
25 241
87 88
95 96
25 185
249 250
279 280
157 158
20 21
114 115
135 136
131 ...

output:

384

result:

ok 1 number(s): "384"

Test #74:

score: 0
Accepted
time: 4ms
memory: 20940kb

input:

3228 3727
2846 2849
3155 3156
1111 1112
157 158
3110 3111
998 999
1725 1726
3026 3027
2499 2500
1798 3173
442 2144
2996 2997
2215 2216
2942 2946
1868 1869
1054 1055
1328 1329
3020 3021
1737 1738
2773 2774
1816 2794
1694 1695
2281 2282
224 225
2546 2547
1877 1878
767 768
3028 3029
217 218
970 971
127...

output:

2542

result:

ok 1 number(s): "2542"

Test #75:

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

input:

7333 8332
2600 3499
5177 5178
6335 6336
3922 3923
3937 3938
6731 6738
4463 4464
5556 5557
4757 4758
1503 1992
4970 4971
2454 2455
5015 5016
1235 1236
4306 4307
3750 3751
5208 5209
5059 6993
2470 2476
2589 2596
830 831
4060 4061
2702 2703
4828 4829
477 478
3093 3094
3035 3036
769 770
2550 2551
6702 6...

output:

5047

result:

ok 1 number(s): "5047"

Test #76:

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

input:

3840 3889
434 435
1957 1958
3833 3834
1345 1346
2602 2603
3630 3631
3189 3190
2900 2901
1757 1758
26 27
2724 2725
1260 1261
3714 3715
154 155
2420 2421
3575 3576
1937 1938
3301 3302
1655 1656
290 291
828 829
1361 1362
84 85
1950 1951
730 731
1914 1915
1796 1797
684 685
127 128
251 252
398 399
1066 1...

output:

250

result:

ok 1 number(s): "250"

Test #77:

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

input:

328 407
91 92
34 35
203 204
67 68
12 15
128 130
311 312
326 327
38 39
61 62
52 99
122 136
97 98
162 246
10 11
307 309
58 191
100 112
280 281
165 166
80 81
90 91
225 226
131 323
65 209
301 302
93 199
182 183
313 314
7 8
192 193
42 77
105 107
191 213
4 5
269 270
261 263
199 200
304 305
83 84
27 118
51...

output:

-1

result:

ok 1 number(s): "-1"

Test #78:

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

input:

3719 4263
2191 2192
2431 2432
627 628
2328 2329
655 656
3133 3134
208 209
1520 1521
1455 1460
3276 3277
1394 1395
2624 2625
106 107
1995 1996
1884 1885
2567 2568
3612 3613
3638 3639
254 951
670 671
2639 2640
2730 2731
634 635
3388 3389
2067 2068
951 1798
2907 2908
878 879
1648 1649
2702 2703
3 4
876...

output:

-1

result:

ok 1 number(s): "-1"

Test #79:

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

input:

3246 3995
1248 2359
3088 3089
116 2851
624 888
1880 1883
1909 1910
2469 2473
606 607
760 761
1831 3079
1860 1861
1274 1276
1369 1370
976 980
3188 3189
279 280
1753 1754
1983 1984
1026 1027
2584 2586
1292 1293
702 1429
2875 2879
2305 2306
1018 2024
867 868
1643 1644
1898 1899
747 2422
611 613
2000 20...

output:

-1

result:

ok 1 number(s): "-1"

Test #80:

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

input:

326 402
127 131
180 181
126 129
164 165
98 99
197 200
1 2
123 124
294 295
110 114
277 278
33 37
147 148
143 264
24 25
309 310
162 163
285 286
151 152
178 244
204 207
43 44
297 298
5 100
12 13
38 239
305 306
210 289
224 232
159 160
29 113
11 12
116 117
214 215
3 9
234 235
84 85
48 49
206 207
9 285
10...

output:

-1

result:

ok 1 number(s): "-1"

Test #81:

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

input:

3279 3878
1848 1849
2717 2725
1109 1117
1524 1525
1131 1132
53 153
733 734
143 144
974 2445
1946 1947
2033 2976
2461 2468
2283 2424
3046 3047
243 244
1881 1882
2405 2406
1429 1430
3048 3049
3072 3073
2983 2984
526 527
1137 1138
2572 2573
1075 1076
1419 1420
2223 2229
1241 1242
2825 2826
3083 3084
14...

output:

-1

result:

ok 1 number(s): "-1"

Test #82:

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

input:

7416 8438
6342 6349
80 81
5707 5708
5732 5733
1821 1822
4425 4426
6338 6339
1011 1012
6003 6004
4959 4960
3732 3733
4483 4484
4163 4164
52 369
4499 4500
1240 1241
7397 7398
3330 3337
1536 1537
6049 6050
5250 5251
3450 3451
6270 6271
1242 1243
2140 2141
1164 4790
3023 3028
6964 6971
865 1745
2620 262...

output:

-1

result:

ok 1 number(s): "-1"

Test #83:

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

input:

3840 3890
2549 2550
1748 1749
2422 2423
3285 3286
250 251
550 551
1521 1522
3042 3043
918 919
478 479
2690 2691
2938 2939
698 699
448 449
638 639
3634 3635
775 776
472 473
1384 1385
2560 2561
925 926
673 674
1909 1910
3550 3551
2563 2564
2301 2302
2359 2360
366 367
2076 2077
3111 3112
2113 2114
2975...

output:

-1

result:

ok 1 number(s): "-1"

Test #84:

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

input:

5866 6739
344 345
687 694
4704 4705
849 850
2323 2324
5621 5622
715 716
1804 1805
365 366
4997 4998
717 721
5681 5682
3815 3816
2082 2083
3671 3672
1 1796
2940 2941
5 4085
1818 1819
4 1481
2520 2521
431 432
546 547
2987 2989
4894 4895
3898 3899
5 15
303 304
8 2184
4654 4655
2159 2166
4031 4032
4932 ...

output:

5151

result:

ok 1 number(s): "5151"

Test #85:

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

input:

5804 6685
4724 4725
142 143
4929 4930
34 35
2381 2382
2255 2256
4548 4549
3908 5716
159 160
4207 5533
2261 2262
5649 5650
4247 4248
1907 5716
3436 3437
2154 2155
3655 3656
1351 1352
4026 5533
887 895
976 983
5529 5530
1004 1005
4887 4888
3991 3992
4606 4607
1014 1015
1227 1228
3152 3153
2119 2120
29...

output:

5175

result:

ok 1 number(s): "5175"

Test #86:

score: 0
Accepted
time: 4ms
memory: 20924kb

input:

3166 3901
1 3
282 3012
1170 1171
1230 1231
818 820
2460 2464
507 3162
2926 2927
1726 1727
1299 1300
2297 2298
1396 1400
163 164
2451 2452
2017 2018
3052 3054
1221 3134
2997 2998
1208 3134
615 616
2971 2972
1077 3162
708 709
1726 1728
3110 3112
1812 1815
1802 1803
3017 3018
2292 3134
703 704
309 310
...

output:

4152

result:

ok 1 number(s): "4152"

Test #87:

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

input:

3166 4901
1473 1474
2725 2727
501 505
930 931
918 1412
2682 2683
1139 1140
2114 2145
2585 2588
2147 2148
2090 3162
1601 1604
1327 1330
2341 2474
2223 3132
1998 3012
496 2548
216 220
162 165
1384 1385
552 553
2276 2278
2865 2866
2391 2395
2502 2503
212 2477
169 3162
2594 2598
2648 3162
1977 3134
1731...

output:

-1

result:

ok 1 number(s): "-1"

Test #88:

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

input:

999 1497
114 523
289 540
436 513
217 513
192 888
513 785
513 838
182 815
513 613
513 975
598 745
541 998
513 970
513 922
513 761
234 513
513 593
511 513
601 695
85 392
203 748
287 394
385 458
513 552
513 559
513 615
455 513
150 513
387 513
513 877
513 843
513 942
244 513
513 625
513 947
159 615
103 ...

output:

1497

result:

ok 1 number(s): "1497"

Test #89:

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

input:

10000 13332
2002 9393
4219 7855
4038 7855
7486 8358
701 2889
2679 7855
7855 7918
322 4647
2793 5264
3927 7145
5037 6525
244 9470
7855 7984
1678 7855
7287 7855
7855 8864
282 4820
8840 9295
704 7855
4039 6605
6706 7855
4706 7855
114 7692
3099 5414
875 7980
3131 5274
7855 8545
3332 6927
2904 7876
1325 ...

output:

16665

result:

ok 1 number(s): "16665"

Test #90:

score: 0
Accepted
time: 22ms
memory: 21808kb

input:

19999 29997
6827 18890
6827 17994
1648 6827
6827 14387
8247 10000
5588 8152
6827 18363
5185 14714
6827 17778
6827 19046
4069 6827
1816 6827
3585 6827
6827 9843
6827 7661
3134 6827
6827 9469
9142 14907
6524 6827
4777 8678
6827 7102
15739 17364
1608 2407
904 19844
6827 16785
86 12547
2431 19183
13713 ...

output:

29997

result:

ok 1 number(s): "29997"

Test #91:

score: 0
Accepted
time: 18ms
memory: 21720kb

input:

19996 23994
1986 19603
10335 15660
4398 16908
1986 15906
4755 19408
1893 10173
13173 14329
1986 19195
1986 17512
1986 10777
1986 7029
15444 18175
15462 17455
5510 7811
1986 16159
4055 15510
1065 18034
1986 10048
8218 16727
1986 15823
13957 15705
8652 14685
15478 16363
6365 19393
1986 15249
14332 158...

output:

19995

result:

ok 1 number(s): "19995"

Test #92:

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

input:

100 148
57 74
21 77
21 59
39 69
45 69
33 71
60 85
73 75
5 62
42 93
29 59
87 88
14 55
7 46
71 99
17 67
32 75
10 19
17 52
24 37
1 70
49 94
16 46
12 85
34 96
23 52
36 95
5 83
75 82
26 27
16 47
14 72
40 95
98 99
97 100
36 90
3 32
36 70
53 100
48 57
30 49
39 53
17 79
51 86
28 60
6 92
78 97
49 54
15 32
37...

output:

149

result:

ok 1 number(s): "149"

Test #93:

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

input:

10001 15000
75 9476
3473 4403
1506 4609
1436 8141
3944 8311
6324 6605
2975 7102
6811 9476
3977 6615
6120 7231
2727 9794
6549 9935
3118 4186
5346 5461
3588 8980
2217 7292
774 6109
1579 10000
709 1526
1737 7040
1898 6327
8292 8779
9222 9243
106 6656
3435 9732
855 4953
3736 9398
8171 9165
1967 4163
303...

output:

15000

result:

ok 1 number(s): "15000"

Test #94:

score: 0
Accepted
time: 27ms
memory: 28408kb

input:

19999 29997
6864 16215
5594 12272
11824 16160
11528 11675
5002 18527
8852 12015
744 19953
1461 14867
9858 11123
10236 13615
13256 15315
4821 11870
9063 14578
9019 15219
2702 4820
8435 8941
4334 15689
309 14456
5893 17062
10599 17138
3766 16164
2452 9530
11182 12419
6248 14436
2418 18469
327 6191
300...

output:

29997

result:

ok 1 number(s): "29997"

Test #95:

score: 0
Accepted
time: 23ms
memory: 30804kb

input:

20000 29998
4874 16133
17043 19434
3347 5906
6261 10053
9481 18283
909 17866
13013 14695
6998 18028
7637 14936
9876 12682
7744 19144
1995 8014
7618 17390
1689 19146
6203 15597
3577 19895
15974 17680
819 15431
13541 15346
2647 4172
3616 9353
3450 17344
15884 16697
17730 18799
8625 19857
2269 15679
44...

output:

29999

result:

ok 1 number(s): "29999"

Test #96:

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

input:

100 150
1 70
28 60
15 22
24 37
9 71
22 80
13 83
40 91
14 72
13 57
9 33
97 100
12 60
39 53
53 100
6 92
1 4
17 79
61 89
21 59
47 56
45 69
49 54
5 13
12 85
27 69
44 100
61 78
17 52
34 96
86 94
60 63
21 29
87 88
87 99
61 64
18 67
54 94
71 98
7 25
20 37
59 91
26 27
58 63
43 68
19 81
33 71
98 99
2 23
39 4...

output:

-1

result:

ok 1 number(s): "-1"

Test #97:

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

input:

10001 15001
2 2210
2930 3296
180 1451
1896 2643
5948 6722
169 1508
5718 6214
5360 8872
7189 8933
1469 7558
140 4135
4446 6825
5406 7935
5629 8425
2150 4026
2573 3235
7164 9959
1513 9554
5129 9669
6603 7342
2147 2244
497 571
2936 5655
3670 6758
1749 6263
2218 9203
3623 6714
7535 9423
3298 5612
4267 8...

output:

-1

result:

ok 1 number(s): "-1"

Test #98:

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

input:

19999 29998
3284 17363
2132 5236
47 8986
1720 2419
952 12898
98 18180
16635 17755
4007 9198
14471 19170
4313 18855
4799 9484
2108 16971
3472 14389
11206 18602
1604 12888
11933 18475
17146 17172
6709 8745
6122 18079
3818 16728
3542 5570
3291 19456
8948 13605
16201 19464
235 12006
6588 9127
1106 11766...

output:

-1

result:

ok 1 number(s): "-1"

Test #99:

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

input:

20000 30000
14712 16364
8795 11659
2848 19260
10893 12698
9436 17668
3148 11052
6525 16795
1223 18855
1309 5207
143 19607
1377 18153
9508 14364
6943 15101
8927 16722
5141 9099
4602 8118
5378 17741
3383 19977
19343 19475
13909 19733
2396 4961
3154 6611
5420 16459
7853 18967
263 11724
3750 12372
3361 ...

output:

-1

result:

ok 1 number(s): "-1"