QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#477043#5545. Contingency Plankaruna#AC ✓66ms18380kbC++201.5kb2024-07-13 22:50:472024-07-13 22:50:50

Judging History

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

  • [2024-07-13 22:50:50]
  • 评测
  • 测评结果:AC
  • 用时:66ms
  • 内存:18380kb
  • [2024-07-13 22:50:47]
  • 提交

answer

#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int SZ = 101010;

int n, u[SZ], v[SZ], deg[SZ];
vector<int> g[SZ];

int dep[SZ], par[SZ], son[SZ], chk[SZ];
void dfs(int p, int v) {
	for (int x : g[v]) if (p != x) {
		dep[x] = dep[v] + 1;
		par[x] = v;
		son[v] = x;
		dfs(v, x);
	}
}

int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);
	
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		cin >> u[i] >> v[i];
		deg[u[i]]++;
		deg[v[i]]++;
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
	}

	for (int i = 1; i <= n; i++) if (deg[i] == n - 1) return !(cout << "-1\n");

	int pos = -1;
	for (int i = 1; i <= n; i++) {
		if (deg[i] == 1 && !chk[i]) {
			dep[i] = 0;
			dfs(-1, i);

			int pos = g[i][0];
			int can = -1;

			set<int> st;
			for (int x : g[pos]) st.insert(x);

			vector<pii> V;
			bool flag = true;
			for (int j = 0; j < n - 1; j++) {
				int x = u[j];
				int y = v[j];

				if (dep[x] > dep[y]) swap(x, y);
				
				if (y != pos) {
					V.push_back({i, y});
					if (son[y]) can = son[y];
					else if (st.find(y) == st.end()) can = y;
				}
				else {
					if (can == -1) {
						for (int x : g[pos]) chk[x] = true;
						flag = false;
						break;
					}
					else {
						V.push_back({pos, can});
					}
				}
			}
			if (flag) {
				for (auto [x, y] : V) {
					cout << x << ' ' << y << '\n';
				}
				return 0;
			}
		}
	}
	assert(false);
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok AC

Test #2:

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

input:

3
1 2
2 3

output:

-1

result:

ok AC

Test #3:

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

input:

2
2 1

output:

-1

result:

ok AC

Test #4:

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

input:

5
2 1
2 3
2 4
4 5

output:

5 1
5 3
5 2
4 3

result:

ok AC

Test #5:

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

input:

5
1 4
3 4
4 5
2 5

output:

2 1
2 3
2 4
5 3

result:

ok AC

Test #6:

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

input:

5
5 2
1 2
4 2
3 4

output:

3 5
3 1
3 2
4 1

result:

ok AC

Test #7:

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

input:

20000
1 2
1 3
4 1
5 1
6 1
7 1
1 8
1 9
1 10
1 11
12 1
1 13
14 1
1 15
1 16
17 1
1 18
1 19
20 1
21 1
22 1
1 23
24 1
1 25
26 1
1 27
28 1
29 1
30 1
1 31
1 32
1 33
1 34
1 35
36 1
1 37
1 38
1 39
40 1
41 1
1 42
1 43
44 1
1 45
46 1
1 47
48 1
49 1
1 50
1 51
52 1
53 1
54 1
1 55
56 1
57 1
58 1
1 59
60 1
61 1
1 ...

output:

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

result:

ok AC

Test #8:

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

input:

20000
7662 1
9205 1
5971 1
1 9886
1 18853
14108 1
998 1
1 14958
7100 1
1 2670
1 18493
13838 1
4644 1
2139 1
1 18540
1 14081
1 16836
1 9357
245 1
242 1
1 13472
1 1471
3792 1
1 17875
13976 1
1 15085
1 17283
15014 1
17477 1
11578 1
18441 1
1 14367
3018 1
1 7186
1 4939
2470 1
2993 1
6175 1
1 19886
1 125...

output:

17029 7662
17029 9205
17029 5971
17029 9886
17029 18853
17029 14108
17029 998
17029 14958
17029 7100
17029 2670
17029 18493
17029 13838
17029 4644
17029 2139
17029 18540
17029 14081
17029 16836
17029 9357
17029 245
17029 242
17029 13472
17029 1471
17029 3792
17029 17875
17029 13976
17029 15085
17029...

result:

ok AC

Test #9:

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

input:

20000
8854 1
15635 1
8088 1
1 12138
12367 1
1 15051
6392 1
15564 1
17334 1
1 10164
8704 1
1 13795
1 10292
12108 1
1 50
4 1
1 18364
13341 1
19203 1
1 3017
1 5133
3499 1
19202 1
1 10304
12975 1
1 17220
1 1716
1 4158
1 16763
1 301
1 16645
8690 1
1 10064
16977 1
1 19618
1 5471
1 8763
3997 1
1 3283
11332...

output:

18216 8854
18216 15635
18216 8088
18216 12138
18216 12367
18216 15051
18216 6392
18216 15564
18216 17334
18216 10164
18216 8704
18216 13795
18216 10292
18216 12108
18216 50
18216 4
18216 18364
18216 13341
18216 19203
18216 3017
18216 5133
18216 3499
18216 19202
18216 10304
18216 12975
18216 17220
18...

result:

ok AC

Test #10:

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

input:

20000
1 2
2 3
4 2
2 5
2 6
2 7
2 8
9 2
10 2
2 11
12 2
2 13
14 2
2 15
2 16
17 2
2 18
19 2
20 2
2 21
22 2
2 23
24 2
2 25
26 2
2 27
2 28
29 2
30 2
2 31
2 32
2 33
2 34
35 2
36 2
37 2
38 2
2 39
40 2
2 41
42 2
43 2
2 44
45 2
46 2
2 47
2 48
2 49
50 2
51 2
2 52
2 53
54 2
55 2
56 2
57 2
2 58
2 59
60 2
61 2
2 ...

output:

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

result:

ok AC

Test #11:

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

input:

20000
1 13291
13291 19998
3314 13291
13291 3339
13291 10237
13244 13291
13291 3392
13291 4459
13291 17335
13291 10356
6124 13291
13291 4470
12896 13291
13291 12094
3309 13291
13319 13291
13291 15658
13291 2305
13291 13710
13291 16520
13291 16234
6697 13291
13291 6686
9187 13291
13291 43
13291 2764
1...

output:

19555 1
19555 19998
19555 3314
19555 3339
19555 10237
19555 13244
19555 3392
19555 4459
19555 17335
19555 10356
19555 6124
19555 4470
19555 12896
19555 12094
19555 3309
19555 13319
19555 15658
19555 2305
19555 13710
19555 16520
19555 16234
19555 6697
19555 6686
19555 9187
19555 43
19555 2764
19555 9...

result:

ok AC

Test #12:

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

input:

20000
4030 5565
1206 5565
5565 8947
4887 5565
14605 5565
5565 2947
5565 9038
5565 5326
5565 9021
11087 5565
5565 19562
895 5565
14653 5565
5565 10803
5565 9750
5565 16331
4689 5565
14307 5565
11631 5565
5565 13244
10554 5565
8112 5565
5565 9394
5565 5945
15279 5565
5565 15512
1334 5565
5565 6025
556...

output:

9353 4030
9353 1206
9353 8947
9353 4887
9353 14605
9353 2947
9353 9038
9353 5326
9353 9021
9353 11087
9353 19562
9353 895
9353 14653
9353 10803
9353 9750
9353 16331
9353 4689
9353 14307
9353 11631
9353 13244
9353 10554
9353 8112
9353 9394
9353 5945
9353 15279
9353 15512
9353 1334
9353 6025
9353 1956...

result:

ok AC

Test #13:

score: 0
Accepted
time: 31ms
memory: 16116kb

input:

100000
1 2
3 1
1 4
5 1
1 6
1 7
1 8
1 9
10 1
1 11
1 12
13 1
1 14
1 15
16 1
17 1
18 1
1 19
1 20
1 21
1 22
1 23
24 1
25 1
26 1
27 1
28 1
29 1
30 1
31 1
1 32
33 1
34 1
35 1
36 1
37 1
1 38
1 39
1 40
1 41
1 42
43 1
1 44
45 1
1 46
1 47
48 1
49 1
1 50
51 1
52 1
53 1
54 1
1 55
56 1
57 1
58 1
59 1
60 1
1 61
1...

output:

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

result:

ok AC

Test #14:

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

input:

5
2 1
3 2
4 3
5 4

output:

5 1
5 2
5 3
4 2

result:

ok AC

Test #15:

score: 0
Accepted
time: 66ms
memory: 16932kb

input:

100000
21871 1
13678 1
27196 1
70437 1
1 35891
1 43010
28018 1
1 64489
61157 1
1 35572
1 41613
1 73049
93865 1
83507 1
1 92127
86278 1
1 15004
1 44154
2005 1
1 94210
41410 1
1 5886
69836 1
1 24120
1 80802
1 9940
66220 1
66549 1
1 20103
1 5
1 33021
35482 1
76185 1
34850 1
1 55173
1 72488
1 76286
1 99...

output:

99803 21871
99803 13678
99803 27196
99803 70437
99803 35891
99803 43010
99803 28018
99803 64489
99803 61157
99803 35572
99803 41613
99803 73049
99803 93865
99803 83507
99803 92127
99803 86278
99803 15004
99803 44154
99803 2005
99803 94210
99803 41410
99803 5886
99803 69836
99803 24120
99803 80802
99...

result:

ok AC

Test #16:

score: 0
Accepted
time: 49ms
memory: 16560kb

input:

100000
1 12976
28108 1
87682 1
79359 1
16128 1
1 90652
1 55874
27276 1
1 66899
1 10296
1 37870
1 78978
26221 1
28589 1
1 46430
32252 1
22407 1
68230 1
64944 1
1 53457
31023 1
1 57101
1 82578
1 33273
69683 1
64357 1
1 32517
1 45623
1 29497
41082 1
1 43731
1 28620
1 64304
1 23462
1 81982
1 91877
1 309...

output:

78172 12976
78172 28108
78172 87682
78172 79359
78172 16128
78172 90652
78172 55874
78172 27276
78172 66899
78172 10296
78172 37870
78172 78978
78172 26221
78172 28589
78172 46430
78172 32252
78172 22407
78172 68230
78172 64944
78172 53457
78172 31023
78172 57101
78172 82578
78172 33273
78172 69683
...

result:

ok AC

Test #17:

score: 0
Accepted
time: 38ms
memory: 16172kb

input:

100000
1 2
2 3
4 2
5 2
2 6
7 2
2 8
2 9
2 10
2 11
2 12
2 13
2 14
2 15
16 2
2 17
18 2
19 2
20 2
21 2
2 22
23 2
24 2
2 25
2 26
27 2
28 2
29 2
30 2
2 31
32 2
2 33
34 2
35 2
2 36
2 37
38 2
2 39
40 2
2 41
42 2
43 2
44 2
45 2
2 46
47 2
2 48
49 2
50 2
2 51
2 52
2 53
2 54
2 55
56 2
2 57
58 2
59 2
60 2
61 2
6...

output:

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

result:

ok AC

Test #18:

score: 0
Accepted
time: 44ms
memory: 16380kb

input:

100000
15924 1
13919 15924
86413 15924
15924 78418
36904 15924
15924 60478
15924 78563
15924 23855
63531 15924
15574 15924
73713 15924
62532 15924
15924 19461
15924 80750
15924 57012
15924 27046
55780 15924
69619 15924
58970 15924
65824 15924
15924 3195
26782 15924
71411 15924
84915 15924
95347 1592...

output:

26907 1
26907 13919
26907 86413
26907 78418
26907 36904
26907 60478
26907 78563
26907 23855
26907 63531
26907 15574
26907 73713
26907 62532
26907 19461
26907 80750
26907 57012
26907 27046
26907 55780
26907 69619
26907 58970
26907 65824
26907 3195
26907 26782
26907 71411
26907 84915
26907 95347
26907...

result:

ok AC

Test #19:

score: 0
Accepted
time: 59ms
memory: 16672kb

input:

100000
40659 47250
51514 40659
40659 83613
16333 40659
25291 40659
40659 61711
40659 37621
40659 66805
40659 59550
67744 40659
40659 46644
40659 21771
40659 98164
40659 6655
75053 40659
90431 40659
40659 58023
48769 40659
11506 40659
19125 40659
52852 40659
98702 40659
53360 40659
40659 3999
66767 4...

output:

86919 47250
86919 51514
86919 83613
86919 16333
86919 25291
86919 61711
86919 37621
86919 66805
86919 59550
86919 67744
86919 46644
86919 21771
86919 98164
86919 6655
86919 75053
86919 90431
86919 58023
86919 48769
86919 11506
86919 19125
86919 52852
86919 98702
86919 53360
86919 3999
86919 66767
86...

result:

ok AC

Test #20:

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

input:

20000
13211 1
1 10767
13211 16998
13211 495
10767 7635
10767 6994
10669 16998
1369 16998
495 4745
722 495
7635 251
3552 7635
7267 6994
6994 1772
10669 18929
10669 9328
3076 1369
1369 14212
4745 284
4745 9599
722 6137
722 10565
15137 251
5349 251
16431 3552
3552 15719
7267 10917
598 7267
19533 1772
1...

output:

2 1
2 10767
2 13211
2 495
2 7635
2 6994
2 10669
2 16998
2 4745
2 722
2 251
2 3552
2 7267
2 1772
2 18929
2 9328
2 1369
2 14212
2 284
2 9599
2 6137
2 10565
2 15137
2 5349
2 16431
2 15719
2 10917
2 598
2 19533
2 5233
2 13724
2 10707
2 7333
2 13598
2 3076
2 6305
2 16056
2 12864
2 16760
2 18952
2 13114
2...

result:

ok AC

Test #21:

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

input:

20000
11262 14400
16805 2790
19084 11979
15259 5949
9916 12236
2445 1637
1905 15141
9540 16655
12812 16186
19052 1523
6643 1443
13738 10091
9218 1337
16617 16436
17295 16466
1171 1217
19150 5280
2830 8076
16135 7234
11460 213
8101 341
5438 6331
5029 14871
10725 2090
5998 12241
8902 3420
4340 7265
18...

output:

5 14400
5 16805
5 11979
5 5949
5 9916
5 2445
5 15141
5 16655
5 16186
5 1523
5 1443
5 10091
5 9218
5 16617
5 16466
5 1217
5 19150
5 2830
5 7234
5 11460
5 8101
5 6331
5 14871
5 10725
5 12241
5 8902
5 7265
5 5618
5 14867
5 741
5 19617
5 10801
5 12234
5 1508
5 18805
5 18298
5 8321
5 11096
5 12347
5 1363...

result:

ok AC

Test #22:

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

input:

20000
19272 1
19272 7240
6952 7240
6952 10594
12564 10594
12564 13132
14483 13132
14483 1891
9772 1891
16614 9772
14519 16614
12050 14519
4039 12050
4039 9679
8408 4039
12050 6797
17990 6797
6797 17659
14519 14985
16415 14985
1735 16415
16415 18821
14985 9402
9402 18947
9402 5386
17560 16614
17560 1...

output:

4 1
4 7240
4 6952
4 10594
4 12564
4 13132
4 14483
4 1891
4 9772
4 16614
4 14519
4 12050
4 4039
4 9679
4 8408
4 6797
4 17990
4 17659
4 14985
4 16415
4 1735
4 18821
4 9402
4 18947
4 5386
4 17560
4 1094
4 7537
4 19700
4 9876
4 16466
4 11779
4 8212
4 793
4 12138
4 1491
4 3819
4 12635
4 8903
4 5872
4 197...

result:

ok AC

Test #23:

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

input:

20000
4410 1
7210 1
1 2389
4410 18377
4410 4507
7905 4410
7210 14849
12441 7210
7210 9005
17807 2389
2389 6619
2389 6604
6913 18377
5811 18377
7249 18377
4507 1582
4507 8857
4507 17635
10077 7905
7905 4687
8607 7905
14849 16870
14849 3298
14849 2376
12441 9009
12441 10729
19879 12441
9005 19790
7715...

output:

2 1
2 7210
2 2389
2 18377
2 4410
2 7905
2 14849
2 12441
2 9005
2 17807
2 6619
2 6604
2 6913
2 5811
2 7249
2 1582
2 8857
2 4507
2 10077
2 4687
2 8607
2 16870
2 3298
2 2376
2 9009
2 10729
2 19879
2 19790
2 7715
2 4016
2 18955
2 11427
2 8360
2 2365
2 19675
2 7633
2 7521
2 5414
2 16483
2 18283
2 14304
2...

result:

ok AC

Test #24:

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

input:

20000
7223 19213
12395 18674
16451 12980
18029 7848
16056 11920
6906 11077
3923 10662
9192 4837
17604 11135
16462 2457
18842 9770
15130 10251
19601 6770
7954 12079
7559 642
15051 17509
1146 18583
18196 17621
4980 8041
19973 15310
16834 11112
3176 8010
957 12737
4072 830
3194 1873
11400 3394
6914 806...

output:

2 19213
2 12395
2 12980
2 7848
2 11920
2 6906
2 3923
2 4837
2 11135
2 2457
2 9770
2 10251
2 6770
2 12079
2 7559
2 15051
2 1146
2 17621
2 8041
2 19973
2 11112
2 3176
2 957
2 830
2 3194
2 11400
2 6914
2 14516
2 15976
2 1868
2 19612
2 163
2 13285
2 3523
2 5435
2 11408
2 5989
2 17775
2 17594
2 15194
2 1...

result:

ok AC

Test #25:

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

input:

5
2 1
3 1
4 1
1 5

output:

-1

result:

ok AC

Test #26:

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

input:

20000
1 4794
4794 19823
8249 19823
8249 19672
16549 19672
13478 16549
3608 13478
3608 14623
14623 10303
19353 14623
14623 7999
3608 14367
14367 17910
14367 8488
16947 14367
3608 1121
1121 1836
13048 1121
17393 1121
11488 13478
11488 17346
8954 17346
17346 4922
17346 13440
11488 2278
16202 2278
593 2...

output:

2 4794
2 19823
2 8249
2 19672
2 16549
2 13478
2 3608
2 14623
2 10303
2 19353
2 7999
2 14367
2 17910
2 8488
2 16947
2 1121
2 1836
2 13048
2 17393
2 11488
2 17346
2 8954
2 4922
2 13440
2 2278
2 16202
2 593
2 13598
2 12496
2 7488
2 8346
2 2126
2 4302
2 5211
2 4461
2 13940
2 11704
2 3287
2 2229
2 2841
2...

result:

ok AC

Test #27:

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

input:

20000
1 17253
5390 1
1 10221
1 16259
8902 1
10509 1
1 16551
1 13314
1 12754
1 11707
1 7781
1 2105
1 18132
1 12907
1 5609
1 15234
1 18609
1 13919
1 13882
1 15621
1 1997
1 14002
1 18056
7498 1
13534 1
1530 1
1 14773
1 2001
1 10679
1 13745
6140 1
19975 1
14198 1
1 7536
5623 1
1 6120
1 6954
730 1
1 1601...

output:

2 17253
2 5390
2 10221
2 16259
2 8902
2 10509
2 16551
2 13314
2 12754
2 11707
2 7781
2 2105
2 18132
2 12907
2 5609
2 15234
2 18609
2 13919
2 13882
2 15621
2 1997
2 1
2 18056
2 7498
2 13534
2 1530
2 14773
2 2001
2 10679
2 13745
2 6140
2 19975
2 14198
2 7536
2 5623
2 6120
2 6954
2 730
2 16011
2 12255
...

result:

ok AC

Test #28:

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

input:

20000
5445 4016
925 12966
8179 19342
5779 1
9123 4530
5079 8720
8754 5478
17667 13748
7203 13819
10489 7645
8537 14929
4717 5427
239 4564
17407 14318
6756 7348
4638 17915
19455 15109
3853 19342
15246 17470
8228 16612
7726 13819
1 16617
16607 6208
6228 12081
1615 14545
11897 16624
7653 14499
7273 195...

output:

2 5445
2 12966
2 8179
2 5779
2 9123
2 5079
2 5478
2 13748
2 7203
2 7645
2 14929
2 4717
2 4564
2 14318
2 7348
2 17915
2 15109
2 3853
2 15246
2 8228
2 7726
2 16617
2 16607
2 6228
2 1615
2 11897
2 14499
2 19530
2 15437
2 17582
2 9523
2 18894
2 7204
2 1183
2 6264
2 12776
2 10060
2 4195
2 15487
2 6735
2 ...

result:

ok AC

Test #29:

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

input:

20000
1 10558
10558 7298
7298 3082
17807 7298
793 7298
11663 7298
12412 7298
10699 7298
7298 1146
2462 7298
7298 12577
11701 7298
7298 7622
3831 7298
19955 7298
3001 7298
7298 18329
7298 851
7298 16782
7298 17396
7298 15015
12771 7298
7298 10926
4736 7298
9088 7298
4867 7298
16066 7298
7298 2148
729...

output:

2 10558
2 7298
2 3082
2 17807
2 793
2 11663
2 12412
2 10699
2 1146
2 2462
2 12577
2 11701
2 7622
2 3831
2 19955
2 3001
2 18329
2 851
2 16782
2 17396
2 15015
2 12771
2 10926
2 4736
2 9088
2 4867
2 16066
2 2148
2 9282
2 3101
2 1177
2 16186
2 18525
2 9265
2 10881
2 15895
2 14732
2 15331
2 10411
2 13920...

result:

ok AC

Test #30:

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

input:

20000
1 11767
10226 11767
6246 10226
6576 6246
458 6576
458 5997
16052 5997
16052 10900
4370 10900
4370 17480
17480 11379
4859 11379
14663 4859
18363 14663
1454 18363
18490 1454
18490 17760
17760 19850
19832 19850
4252 19832
5482 4252
2802 5482
17779 2802
17779 8601
10844 8601
10844 17372
1230 17372...

output:

4129 1
4129 11767
4129 10226
4129 6246
4129 6576
4129 458
4129 5997
4129 16052
4129 10900
4129 4370
4129 17480
4129 11379
4129 4859
4129 14663
4129 18363
4129 1454
4129 18490
4129 17760
4129 19850
4129 19832
4129 4252
4129 5482
4129 2802
4129 17779
4129 8601
4129 10844
4129 17372
4129 1230
4129 1301...

result:

ok AC

Test #31:

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

input:

20000
16653 18166
1123 17313
12716 14313
11207 7401
2794 831
480 7420
4462 1161
575 456
15192 3052
12389 7101
15729 18976
18772 19492
18805 2052
866 10412
8160 3697
13319 15062
19241 11526
11876 3502
613 17770
15035 14829
6518 16531
11665 19122
15722 18062
19841 14843
5758 3123
1633 14519
3637 13277...

output:

1 18166
1 17313
1 14313
1 11207
1 831
1 7420
1 1161
1 456
1 3052
1 7101
1 18976
1 18772
1 18805
1 10412
1 8160
1 15062
1 11526
1 11876
1 613
1 14829
1 16531
1 11665
1 15722
1 19841
1 5758
1 14519
1 3637
1 14004
1 11487
1 383
1 18796
1 9464
1 14763
1 7614
1 8865
1 15552
1 19583
1 3795
1 19770
1 1595
...

result:

ok AC

Test #32:

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

input:

20000
5613 1
1 999
1 16709
1 2491
9549 1
19706 1
1 1022
1 3884
1 1916
6627 1
1 1600
10265 1
1 19100
19766 1
1 7450
1 14375
5986 1
10295 1
8625 1
11810 1
1 15542
1 5745
3506 1
12842 1
1 11860
1 16317
1 6553
12476 1
1 6031
8445 1
6462 1
1 1601
1 3014
14100 1
1 6771
1 2360
1 15402
4549 1
6116 1
1 17848...

output:

-1

result:

ok AC

Test #33:

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

input:

20000
2509 13795
17043 13795
12006 13795
13795 822
3022 13795
8572 13795
2579 13795
13795 9673
12654 13795
4181 13795
13795 15912
13795 8902
13795 19201
5015 13795
243 13795
13795 6524
13795 9461
16403 13795
13795 18444
1316 13795
15366 13795
13795 17126
13795 309
13795 10938
13795 1255
13795 5588
1...

output:

-1

result:

ok AC

Test #34:

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

input:

20000
12144 2902
8713 11740
8870 10266
6116 3885
5943 8380
10496 956
14162 9193
4497 3275
5480 4601
6858 17285
1067 3003
19501 1958
5579 12167
844 12167
5372 16648
18876 13545
6559 10656
2910 6918
5632 16656
10135 11948
11253 13524
10068 15948
17884 3833
6830 16257
1248 6924
9806 14359
11033 8077
86...

output:

3 12144
3 8713
3 10266
3 6116
3 5943
3 10496
3 9193
3 4497
3 5480
3 6858
3 3003
3 1958
3 5579
3 12167
3 16648
3 18876
3 10656
3 6918
3 5632
3 10135
3 11253
3 10068
3 3833
3 16257
3 6924
3 9806
3 8077
3 8650
3 9461
3 2145
3 18808
3 17834
3 17118
3 5268
3 17239
3 12697
3 18861
3 6613
3 14103
3 3550
3 ...

result:

ok AC

Test #35:

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

input:

20000
1284 10854
1436 9770
17852 14859
19561 13068
19123 19730
8297 15453
7167 3888
5853 15710
18440 5611
9368 5242
6667 12315
19899 12021
13550 19105
16314 1977
18051 11095
4122 16348
1987 4873
14613 10548
375 11649
6442 1199
228 18390
4006 7870
2115 10763
13056 1980
4042 9649
11446 10078
14111 289...

output:

1 1284
1 1436
1 17852
1 13068
1 19730
1 15453
1 3888
1 5853
1 18440
1 5242
1 12315
1 12021
1 19105
1 1977
1 11095
1 4122
1 4873
1 10548
1 11649
1 1199
1 228
1 4006
1 10763
1 1980
1 9649
1 11446
1 14111
1 14896
1 6991
1 6627
1 4581
1 10616
1 18363
1 430
1 4544
1 2417
1 19156
1 10018
1 11010
1 9777
1 ...

result:

ok AC

Test #36:

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

input:

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

output:

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

result:

ok AC

Test #37:

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

input:

20000
1 1914
16448 1914
16448 447
1 19785
19232 19785
17236 19785
12409 17236
11707 12409
15526 11707
15526 12645
19367 12645
19367 7871
12617 7871
658 7871
2936 7871
10186 2936
10186 12483
4222 12483
4222 6106
3280 6106
7313 6106
17305 6106
2244 17305
17305 18735
16748 6106
16748 1554
16748 1261
73...

output:

2 1914
2 16448
2 447
2 1
2 19232
2 19785
2 17236
2 12409
2 15526
2 12645
2 19367
2 7871
2 12617
2 658
2 2936
2 10186
2 12483
2 4222
2 6106
2 3280
2 7313
2 17305
2 2244
2 18735
2 16748
2 1554
2 1261
2 7318
2 9524
2 7917
2 6734
2 18980
2 13963
2 17414
2 18244
2 12882
2 13768
2 221
2 17327
2 14857
2 10...

result:

ok AC

Test #38:

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

input:

20000
8234 1
16079 8234
18825 16079
18825 12361
12361 6709
6709 10905
12205 10905
3916 12205
16311 3916
16423 16311
16423 10094
10094 9710
1474 9710
1474 18631
18631 13459
6640 13459
19380 6640
19380 6320
19874 6320
2212 19874
2212 8880
8880 2809
15348 2809
14869 15348
14869 8029
924 8029
924 10270
...

output:

2 1
2 8234
2 16079
2 18825
2 12361
2 6709
2 10905
2 12205
2 3916
2 16311
2 16423
2 10094
2 9710
2 1474
2 18631
2 13459
2 6640
2 19380
2 6320
2 19874
2 2212
2 8880
2 2809
2 15348
2 14869
2 8029
2 924
2 10270
2 16526
2 4694
2 1818
2 15046
2 10755
2 124
2 8951
2 3035
2 3827
2 4302
2 16023
2 7306
2 1817...

result:

ok AC

Test #39:

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

input:

20000
3828 10203
17892 5873
17224 10321
12241 7554
2948 6507
17619 16861
11410 1012
17019 18616
13582 19398
16411 15552
578 14161
9621 19542
9684 1699
16733 9223
16474 19501
15178 3217
9743 11111
6539 14379
5655 12001
10637 2251
13411 7006
7104 9228
15833 19339
12622 4315
19092 7490
8033 12870
19399...

output:

1 3828
1 5873
1 10321
1 7554
1 6507
1 17619
1 1012
1 18616
1 19398
1 16411
1 578
1 9621
1 9684
1 16733
1 19501
1 3217
1 11111
1 6539
1 12001
1 2251
1 13411
1 9228
1 15833
1 4315
1 19092
1 8033
1 1103
1 12722
1 5264
1 3401
1 13502
1 15830
1 11848
1 464
1 16042
1 8567
1 4102
1 985
1 848
1 4426
1 8368
...

result:

ok AC

Test #40:

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

input:

20000
6712 1
6712 16871
8572 16871
8572 10641
10641 16702
16702 18095
14014 18095
14014 10577
10577 1956
1956 13463
4593 13463
4593 17604
8524 17604
8524 4625
4625 5906
5906 17983
17983 13029
13029 7366
13038 7366
13038 3804
3804 3699
3699 15717
15717 967
16443 967
16443 1797
3079 1797
9213 3079
232...

output:

2 1
2 6712
2 16871
2 8572
2 10641
2 16702
2 18095
2 14014
2 10577
2 1956
2 13463
2 4593
2 17604
2 8524
2 4625
2 5906
2 17983
2 13029
2 7366
2 13038
2 3804
2 3699
2 15717
2 967
2 16443
2 1797
2 3079
2 9213
2 232
2 16743
2 1222
2 4937
2 10300
2 9423
2 871
2 15884
2 11121
2 7931
2 15720
2 3455
2 16899
...

result:

ok AC

Test #41:

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

input:

20000
2591 11751
5562 1300
9597 7814
11201 6762
9942 6089
18201 10054
14040 17666
14050 3479
2754 6286
5122 10070
2705 10053
3703 8076
33 13628
18330 17144
15031 16159
668 10414
14591 4857
15396 13207
6623 13987
3946 9270
15622 17484
4063 8811
12866 7551
3439 8748
10982 6076
15522 1678
8947 4749
677...

output:

4 11751
4 1300
4 9597
4 6762
4 6089
4 10054
4 17666
4 14050
4 2754
4 10070
4 10053
4 3703
4 13628
4 17144
4 15031
4 10414
4 4857
4 15396
4 6623
4 3946
4 17484
4 8811
4 7551
4 3439
4 6076
4 1678
4 4749
4 6774
4 19379
4 16853
4 7621
4 12599
4 3694
4 12070
4 12012
4 1957
4 2402
4 4213
4 15277
4 18381
4...

result:

ok AC

Test #42:

score: 0
Accepted
time: 24ms
memory: 12096kb

input:

100000
1 72500
1 89151
72500 50542
16422 72500
31678 89151
89151 54297
19071 50542
25039 50542
59896 16422
57305 16422
17263 31678
31678 3514
54297 25341
13381 54297
19071 7507
15806 19071
25039 62775
20433 25039
59896 28013
59896 2793
84857 57305
57305 84225
17263 6434
17263 61853
37741 3514
3514 8...

output:

2 1
2 89151
2 72500
2 16422
2 31678
2 54297
2 19071
2 50542
2 59896
2 57305
2 17263
2 3514
2 25341
2 13381
2 7507
2 15806
2 25039
2 20433
2 28013
2 2793
2 84857
2 84225
2 6434
2 61853
2 37741
2 83001
2 44061
2 13085
2 58193
2 55647
2 77954
2 78764
2 76195
2 7022
2 9513
2 62775
2 49029
2 40559
2 8430...

result:

ok AC

Test #43:

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

input:

100000
37174 25594
26356 56758
70911 5299
53571 20298
89704 67180
69629 74497
31785 14492
10546 1814
71677 54029
2466 28838
57294 23003
35667 41920
5998 95159
14430 34895
74794 85483
87138 10195
54295 96087
21621 26770
92353 70922
56725 17254
67745 92044
30390 34948
64685 31050
54736 78533
63644 859...

output:

3 37174
3 26356
3 70911
3 20298
3 89704
3 74497
3 14492
3 10546
3 71677
3 28838
3 23003
3 41920
3 95159
3 34895
3 74794
3 10195
3 54295
3 21621
3 70922
3 56725
3 67745
3 30390
3 31050
3 78533
3 8591
3 41599
3 83052
3 72832
3 91279
3 67635
3 93515
3 12147
3 42902
3 62955
3 28269
3 74934
3 54184
3 527...

result:

ok AC

Test #44:

score: 0
Accepted
time: 28ms
memory: 12012kb

input:

100000
90403 1
90403 84049
84049 28339
50038 28339
50038 23735
23735 87291
87291 26404
26404 3276
3276 37488
67144 37488
67144 15335
15335 73596
32815 73596
58348 32815
32340 58348
77042 32340
32340 17210
58348 68281
68281 13360
68281 52957
32815 3781
88746 3781
33513 88746
88746 23338
11895 3781
90...

output:

6 1
6 84049
6 28339
6 50038
6 23735
6 87291
6 26404
6 3276
6 37488
6 67144
6 15335
6 73596
6 32815
6 58348
6 32340
6 77042
6 17210
6 68281
6 13360
6 52957
6 3781
6 88746
6 33513
6 23338
6 11895
6 90021
6 30580
6 48662
6 63248
6 74409
6 81851
6 86494
6 83685
6 90724
6 63215
6 55619
6 58689
6 39231
6 ...

result:

ok AC

Test #45:

score: 0
Accepted
time: 26ms
memory: 12136kb

input:

100000
10753 1
31716 1
1 8354
41344 10753
10753 22340
33736 10753
31716 74747
24655 31716
31716 93736
4454 8354
65308 8354
36992 8354
53743 41344
59301 41344
41344 86462
22340 77782
22340 49193
90415 22340
33736 2126
72574 33736
33736 98153
92064 74747
23614 74747
74747 96121
24655 95702
47727 24655...

output:

3 10753
3 31716
3 1
3 41344
3 22340
3 33736
3 74747
3 24655
3 93736
3 4454
3 65308
3 8354
3 53743
3 59301
3 86462
3 77782
3 49193
3 90415
3 2126
3 72574
3 98153
3 92064
3 23614
3 96121
3 95702
3 47727
3 49727
3 66140
3 85606
3 19727
3 80356
3 40253
3 52474
3 57593
3 56468
3 11024
3 36992
3 5716
3 87...

result:

ok AC

Test #46:

score: 0
Accepted
time: 31ms
memory: 12136kb

input:

100000
82182 59525
43093 74187
83434 62328
30609 75691
98351 97443
93951 9234
89762 57868
66707 24839
91314 82444
9148 12031
46318 817
9254 56692
67828 19158
29614 79432
64090 86748
43645 44758
91501 26481
13108 70283
53676 76180
2183 16343
17086 64156
13813 38661
1934 69441
21652 50770
62980 13969
...

output:

2 82182
2 74187
2 83434
2 30609
2 97443
2 93951
2 57868
2 24839
2 91314
2 9148
2 817
2 56692
2 67828
2 79432
2 64090
2 44758
2 26481
2 70283
2 76180
2 2183
2 17086
2 38661
2 69441
2 50770
2 13969
2 32887
2 53464
2 31201
2 75999
2 72413
2 94757
2 65182
2 73092
2 67989
2 9866
2 97622
2 27396
2 56173
2...

result:

ok AC

Test #47:

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

input:

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

output:

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

result:

ok AC

Test #48:

score: 0
Accepted
time: 33ms
memory: 11988kb

input:

100000
1 59819
46211 59819
46211 78631
78631 6887
6887 15685
45496 15685
45496 38399
38399 43932
22491 43932
22491 57782
25655 57782
57782 81578
40906 57782
22491 8185
8185 92518
96199 8185
63790 8185
22491 64847
84427 64847
34665 64847
30015 64847
34952 43932
34952 12997
41447 12997
19357 12997
307...

output:

2 1
2 59819
2 78631
2 6887
2 15685
2 45496
2 38399
2 43932
2 22491
2 57782
2 25655
2 81578
2 40906
2 8185
2 92518
2 96199
2 63790
2 64847
2 84427
2 34665
2 30015
2 34952
2 12997
2 41447
2 19357
2 30750
2 41985
2 17269
2 73496
2 97851
2 56846
2 2593
2 73876
2 90232
2 20892
2 3411
2 65784
2 17544
2 49...

result:

ok AC

Test #49:

score: 0
Accepted
time: 30ms
memory: 12620kb

input:

100000
70720 1
71027 1
48338 1
1 61809
1 79963
1 39740
86644 1
14939 1
39918 1
41470 1
23364 1
1 54664
1 96370
1 53835
1 67313
33696 1
44243 1
50423 1
1 70539
73776 1
560 1
98363 1
71623 1
72365 1
1 73548
1 82843
1 64083
52686 1
1 44452
1 94601
1 43725
88136 1
1 65340
30989 1
1 94282
76705 1
1 4208
...

output:

2 70720
2 71027
2 48338
2 61809
2 79963
2 39740
2 86644
2 14939
2 39918
2 41470
2 23364
2 54664
2 96370
2 53835
2 67313
2 33696
2 44243
2 50423
2 70539
2 73776
2 560
2 98363
2 71623
2 72365
2 73548
2 82843
2 64083
2 52686
2 44452
2 94601
2 43725
2 88136
2 65340
2 30989
2 94282
2 76705
2 4208
2 51677...

result:

ok AC

Test #50:

score: 0
Accepted
time: 35ms
memory: 12728kb

input:

100000
55448 49209
4084 16405
52470 22193
57007 13008
43787 82824
91893 67413
72105 89438
5791 85302
74502 44950
57906 11997
53465 42216
63894 41770
20892 54078
19530 68055
34937 22893
43941 47065
54015 53196
91519 81132
80483 71834
1399 53196
18226 23550
46619 51969
78131 47878
85576 60764
37319 88...

output:

2 55448
2 4084
2 22193
2 13008
2 82824
2 91893
2 72105
2 5791
2 44950
2 11997
2 42216
2 41770
2 20892
2 68055
2 22893
2 47065
2 54015
2 91519
2 80483
2 1399
2 23550
2 46619
2 47878
2 85576
2 37319
2 32182
2 81586
2 8618
2 79665
2 71947
2 32200
2 98413
2 2876
2 42148
2 83951
2 9727
2 95950
2 24562
2 ...

result:

ok AC

Test #51:

score: 0
Accepted
time: 30ms
memory: 12700kb

input:

100000
1 13485
13485 21238
21238 89751
21238 74621
14404 21238
60040 21238
21238 46089
46928 21238
73214 21238
88224 21238
47403 21238
21238 99205
89778 21238
21238 89464
22870 21238
21238 75159
40123 21238
33512 21238
21238 30257
70298 21238
21238 79591
57804 21238
21238 99840
64087 21238
12717 212...

output:

2 13485
2 21238
2 89751
2 74621
2 14404
2 60040
2 46089
2 46928
2 73214
2 88224
2 47403
2 99205
2 89778
2 89464
2 22870
2 75159
2 40123
2 33512
2 30257
2 70298
2 79591
2 57804
2 99840
2 64087
2 12717
2 80599
2 94369
2 17735
2 40969
2 4985
2 18584
2 2198
2 19418
2 83752
2 84416
2 20892
2 61478
2 9546...

result:

ok AC

Test #52:

score: 0
Accepted
time: 40ms
memory: 18228kb

input:

100000
43730 1
43730 8413
8413 13508
53025 13508
44444 53025
44444 46747
54535 46747
54535 16058
16058 27066
27066 73721
35961 73721
18398 35961
18398 3188
3188 9998
57229 9998
57229 96831
2109 96831
2109 89059
89059 89520
89520 62512
62512 9136
9136 32949
27353 32949
19993 27353
19993 17305
91005 1...

output:

91469 1
91469 43730
91469 8413
91469 13508
91469 53025
91469 44444
91469 46747
91469 54535
91469 16058
91469 27066
91469 73721
91469 35961
91469 18398
91469 3188
91469 9998
91469 57229
91469 96831
91469 2109
91469 89059
91469 89520
91469 62512
91469 9136
91469 32949
91469 27353
91469 19993
91469 173...

result:

ok AC

Test #53:

score: 0
Accepted
time: 38ms
memory: 18380kb

input:

100000
5616 54215
70847 24268
13256 88765
87054 72678
65173 1284
61132 24104
29759 37270
50005 62107
8909 58386
97772 68628
3463 41963
93835 10608
7780 68599
97385 40426
52295 15155
65521 84045
97372 22218
24089 69011
44236 64952
21273 33469
21618 31458
76924 4738
27278 21658
6790 18294
2343 82355
8...

output:

1 54215
1 24268
1 88765
1 72678
1 1284
1 61132
1 37270
1 50005
1 8909
1 97772
1 3463
1 10608
1 7780
1 97385
1 15155
1 65521
1 97372
1 69011
1 44236
1 33469
1 31458
1 4738
1 21658
1 18294
1 2343
1 9539
1 10328
1 83798
1 4010
1 71648
1 59096
1 94048
1 31044
1 863
1 50160
1 62216
1 47790
1 68108
1 7127...

result:

ok AC

Test #54:

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

input:

100000
1 81565
21567 1
86484 1
95714 1
1 93565
1 15812
51087 1
15941 1
36746 1
1 34149
1 71887
1 61269
1 93111
1 52394
8732 1
1 62378
1 74176
1362 1
15806 1
91535 1
1 77121
1 17356
1 23401
70673 1
1 21367
77472 1
1 44692
1 45094
1 43652
62628 1
1 81187
1 98635
2258 1
1 491
1 1963
1 83580
12393 1
1 5...

output:

-1

result:

ok AC

Test #55:

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

input:

100000
62999 54230
62172 54230
54230 87813
80978 54230
54230 13635
8808 54230
34109 54230
54230 13451
54230 30179
9847 54230
93260 54230
54230 45610
54230 7282
54230 42958
54230 54480
54230 62452
54230 95890
32418 54230
54230 8456
54230 64404
54230 40018
54230 70843
38010 54230
57364 54230
95022 542...

output:

-1

result:

ok AC

Test #56:

score: 0
Accepted
time: 35ms
memory: 12064kb

input:

100000
85431 10525
82137 81079
48778 58755
215 90110
51120 51131
16823 69899
6320 72931
65015 30930
68354 78098
32070 13344
55633 13621
69157 69872
92675 79903
96312 24145
13234 89857
62310 15217
7671 50027
34561 73029
90324 42836
14988 3767
96314 18015
665 82164
49080 34432
24022 62814
89664 13182
...

output:

1 85431
1 81079
1 48778
1 215
1 51131
1 16823
1 72931
1 30930
1 78098
1 13344
1 13621
1 69157
1 79903
1 24145
1 13234
1 15217
1 7671
1 73029
1 90324
1 3767
1 18015
1 665
1 49080
1 24022
1 13182
1 34581
1 15439
1 37149
1 98006
1 28737
1 556
1 21022
1 81316
1 25192
1 44380
1 29136
1 94415
1 22535
1 56...

result:

ok AC

Test #57:

score: 0
Accepted
time: 29ms
memory: 12080kb

input:

100000
54861 12509
16932 42872
34657 39417
13373 37054
53410 71695
2271 28730
77047 80422
7187 34867
94140 69441
47384 90599
15092 60892
94502 35186
58059 98865
46037 92080
96465 56648
81008 245
86644 72226
35703 96730
7922 3613
97616 90536
41294 92557
22776 10335
74308 16656
86493 81735
91472 93048...

output:

2 12509
2 42872
2 34657
2 37054
2 53410
2 28730
2 77047
2 7187
2 94140
2 47384
2 60892
2 35186
2 98865
2 46037
2 96465
2 245
2 86644
2 96730
2 3613
2 97616
2 41294
2 22776
2 74308
2 81735
2 93048
2 76450
2 54929
2 95864
2 61190
2 99747
2 14994
2 75
2 40957
2 3200
2 22509
2 10962
2 75699
2 67894
2 96...

result:

ok AC

Test #58:

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

input:

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

output:

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

result:

ok AC

Test #59:

score: 0
Accepted
time: 34ms
memory: 12084kb

input:

100000
88390 1
1 51242
1 73844
73844 82993
69357 82993
82993 89153
89153 92016
36977 89153
75137 36977
82993 53533
97404 53533
49989 97404
67125 49989
53533 7006
7006 63635
60387 7006
59312 60387
24309 59312
26526 24309
24309 9985
9985 26403
60387 55203
55203 79993
79993 71230
71230 52071
52071 8306...

output:

6 88390
6 51242
6 1
6 73844
6 69357
6 89153
6 92016
6 36977
6 75137
6 82993
6 97404
6 49989
6 67125
6 53533
6 63635
6 60387
6 59312
6 24309
6 26526
6 9985
6 26403
6 55203
6 79993
6 71230
6 52071
6 83065
6 86192
6 31224
6 95661
6 7006
6 78908
6 55189
6 20955
6 6350
6 61764
6 92937
6 39888
6 77120
6 2...

result:

ok AC

Test #60:

score: 0
Accepted
time: 46ms
memory: 15204kb

input:

100000
1 7264
7264 69649
85097 69649
29848 85097
29848 68683
68683 42523
15272 42523
97689 15272
97689 7996
30390 7996
54151 30390
22264 54151
22264 98123
98123 16751
27570 16751
9987 27570
9987 86950
86950 67445
67445 87275
8871 87275
8871 74967
74967 53362
53362 10217
10217 52404
45262 52404
45262...

output:

2 1
2 7264
2 69649
2 85097
2 29848
2 68683
2 42523
2 15272
2 97689
2 7996
2 30390
2 54151
2 22264
2 98123
2 16751
2 27570
2 9987
2 86950
2 67445
2 87275
2 8871
2 74967
2 53362
2 10217
2 52404
2 45262
2 72843
2 86772
2 18694
2 30955
2 43425
2 68130
2 6209
2 97483
2 6778
2 29735
2 60476
2 16825
2 1146...

result:

ok AC

Test #61:

score: 0
Accepted
time: 37ms
memory: 12100kb

input:

100000
3518 47523
14887 83452
31336 87320
47772 87482
71420 24559
99732 17539
45904 20872
52728 70439
38581 75203
18345 49294
7385 74056
95971 72826
48547 37020
61306 27212
53241 59530
32550 2892
5369 8488
4000 50453
45119 41435
5899 77096
19235 37917
75044 40239
44198 79848
23637 99807
40855 52471
...

output:

1 3518
1 14887
1 87320
1 87482
1 71420
1 99732
1 20872
1 70439
1 75203
1 49294
1 7385
1 95971
1 37020
1 61306
1 53241
1 2892
1 8488
1 50453
1 45119
1 77096
1 37917
1 40239
1 79848
1 99807
1 52471
1 24560
1 59232
1 97918
1 85990
1 27308
1 80650
1 74356
1 61763
1 62302
1 28194
1 91879
1 91535
1 5717
1...

result:

ok AC

Test #62:

score: 0
Accepted
time: 30ms
memory: 14984kb

input:

100000
56405 1
56405 66063
66801 66063
66801 9845
9845 42911
42911 64818
67482 64818
35942 67482
35942 75546
75546 4505
4505 45628
45628 29159
29159 29378
83665 29378
83665 85205
85205 94326
78400 94326
91544 78400
92293 91544
95489 92293
20854 95489
20854 94810
91796 94810
91796 49331
49331 66242
9...

output:

3 1
3 56405
3 66063
3 66801
3 9845
3 42911
3 64818
3 67482
3 35942
3 75546
3 4505
3 45628
3 29159
3 29378
3 83665
3 85205
3 94326
3 78400
3 91544
3 92293
3 95489
3 20854
3 94810
3 91796
3 49331
3 66242
3 9479
3 14120
3 30274
3 82180
3 62981
3 80630
3 92767
3 15026
3 37107
3 90649
3 16204
3 36373
3 9...

result:

ok AC

Test #63:

score: 0
Accepted
time: 31ms
memory: 14688kb

input:

100000
29993 41605
84963 10140
60237 62389
66780 93449
98439 1174
75487 87344
56945 1098
7281 10192
90231 22033
95031 94597
88728 56965
74791 64971
68584 15462
91264 43556
80943 25018
89575 23985
46970 91618
7237 89928
26433 7488
10258 93471
44420 34919
39007 60649
64537 14238
89107 56906
58805 7576...

output:

1 29993
1 84963
1 62389
1 66780
1 1174
1 87344
1 1098
1 7281
1 90231
1 95031
1 88728
1 74791
1 15462
1 43556
1 80943
1 23985
1 46970
1 7237
1 26433
1 93471
1 44420
1 60649
1 14238
1 56906
1 75769
1 48637
1 14216
1 61560
1 71181
1 43209
1 65213
1 890
1 20561
1 51092
1 76815
1 31667
1 54739
1 52808
1 ...

result:

ok AC

Test #64:

score: 0
Accepted
time: 38ms
memory: 12212kb

input:

100000
87758 1
87758 8566
8566 53230
53230 68035
45464 68035
43933 45464
7611 43933
7611 72530
72530 97898
97898 68231
2236 84498
71861 63091
76814 62314
24969 43571
98738 76356
71858 14301
12495 4041
49101 10912
83218 63817
60387 86854
59093 27607
35192 6135
76119 58917
15976 50822
5377 60508
39902...

output:

2 1
2 87758
2 8566
2 53230
2 68035
2 45464
2 43933
2 7611
2 72530
2 97898
2 84498
2 71861
2 76814
2 43571
2 76356
2 14301
2 4041
2 49101
2 63817
2 86854
2 59093
2 35192
2 76119
2 50822
2 5377
2 39902
2 62754
2 47841
2 23602
2 65106
2 72292
2 97173
2 64193
2 46660
2 64231
2 74997
2 7293
2 53179
2 889...

result:

ok AC

Test #65:

score: 0
Accepted
time: 54ms
memory: 14476kb

input:

100000
49400 1
1 55311
78355 1
58471 1
25325 1
8216 1
19123 1
47311 1
1 87302
68137 1
1 98931
11168 1
1 42489
44803 1
25464 1
34243 1
63702 1
29572 1
14941 1
1 46103
1 54830
43707 1
57172 1
1 17538
75154 1
67663 1
1 6784
14487 1
45840 1
1 82849
1 77260
1 18850
1 7003
1 76083
16640 1
54748 1
46731 1
...

output:

2 49400
2 55311
2 78355
2 58471
2 25325
2 8216
2 19123
2 47311
2 87302
2 68137
2 98931
2 11168
2 42489
2 44803
2 25464
2 34243
2 63702
2 29572
2 14941
2 46103
2 54830
2 43707
2 57172
2 17538
2 75154
2 67663
2 6784
2 14487
2 45840
2 82849
2 77260
2 18850
2 7003
2 76083
2 16640
2 54748
2 46731
2 43207...

result:

ok AC

Test #66:

score: 0
Accepted
time: 24ms
memory: 12052kb

input:

100000
59098 1
88393 1
10097 1
1 27732
12542 1
1 74984
63414 1
1 68750
1 38087
65706 38087
46675 927
57918 60950
11844 60891
1200 51250
17750 31241
12177 66972
57772 85920
49826 92407
3739 18636
15328 31458
47706 69254
95722 85793
92734 12473
72338 65624
66312 27618
47426 68757
39713 32969
50029 618...

output:

2 59098
2 88393
2 10097
2 27732
2 12542
2 74984
2 63414
2 68750
2 1
2 38087
2 46675
2 60950
2 60891
2 51250
2 17750
2 66972
2 57772
2 49826
2 3739
2 31458
2 47706
2 85793
2 12473
2 72338
2 27618
2 68757
2 39713
2 61891
2 54472
2 65357
2 68498
2 43879
2 12766
2 56491
2 65221
2 33848
2 32753
2 54306
2...

result:

ok AC

Test #67:

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

input:

5
2 1
1 3
4 1
5 4

output:

5 2
5 3
5 1
4 3

result:

ok AC

Test #68:

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

input:

5
4 1
3 1
5 1
5 2

output:

2 4
2 3
2 1
5 3

result:

ok AC

Test #69:

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

input:

5
5 1
3 1
1 2
2 4

output:

4 5
4 3
4 1
2 3

result:

ok AC