QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#140451#5545. Contingency Planchenchi#TL 1988ms37020kbC++202.4kb2023-08-15 22:49:392023-08-15 22:49:42

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 9992kb

input:

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

output:

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

result:

ok AC

Test #2:

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

input:

3
1 2
2 3

output:

-1

result:

ok AC

Test #3:

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

input:

2
2 1

output:

-1

result:

ok AC

Test #4:

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

input:

5
2 1
2 3
2 4
4 5

output:

5 1
5 3
2 5
1 4

result:

ok AC

Test #5:

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

input:

5
1 4
3 4
4 5
2 5

output:

2 1
2 3
4 2
1 5

result:

ok AC

Test #6:

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

input:

5
5 2
1 2
4 2
3 4

output:

3 5
3 1
2 3
1 4

result:

ok AC

Test #7:

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

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
19999 4
19999 5
19999 6
19999 7
20000 8
20000 9
20000 10
20000 11
19999 12
20000 13
19999 14
20000 15
20000 16
19999 17
20000 18
20000 19
19999 20
19999 21
19999 22
20000 23
19999 24
20000 25
19999 26
20000 27
19999 28
19999 29
19999 30
20000 31
20000 32
20000 33
20000 34
20000 35
19...

result:

ok AC

Test #8:

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

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:

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

result:

ok AC

Test #9:

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

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:

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

result:

ok AC

Test #10:

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

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:

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

result:

ok AC

Test #11:

score: 0
Accepted
time: 17ms
memory: 15304kb

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:

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

result:

ok AC

Test #12:

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

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
14227 8947
9353 4887
9353 14605
14227 2947
14227 9038
14227 5326
14227 9021
9353 11087
14227 19562
9353 895
9353 14653
14227 10803
14227 9750
14227 16331
9353 4689
9353 14307
9353 11631
14227 13244
9353 10554
9353 8112
14227 9394
14227 5945
9353 15279
14227 15512
9353 1334
14227 ...

result:

ok AC

Test #13:

score: 0
Accepted
time: 87ms
memory: 35276kb

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
99999 3
100000 4
99999 5
100000 6
100000 7
100000 8
100000 9
99999 10
100000 11
100000 12
99999 13
100000 14
100000 15
99999 16
99999 17
99999 18
100000 19
100000 20
100000 21
100000 22
100000 23
99999 24
99999 25
99999 26
99999 27
99999 28
99999 29
99999 30
99999 31
100000 32
99999 33
9999...

result:

ok AC

Test #14:

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

input:

5
2 1
3 2
4 3
5 4

output:

5 1
5 2
3 5
1 4

result:

ok AC

Test #15:

score: 0
Accepted
time: 165ms
memory: 35060kb

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:

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

result:

ok AC

Test #16:

score: 0
Accepted
time: 169ms
memory: 35296kb

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
49349 28108
49349 87682
49349 79359
49349 16128
78172 90652
78172 55874
49349 27276
78172 66899
78172 10296
78172 37870
78172 78978
49349 26221
49349 28589
78172 46430
49349 32252
49349 22407
49349 68230
49349 64944
78172 53457
49349 31023
78172 57101
78172 82578
78172 33273
49349 69683
...

result:

ok AC

Test #17:

score: 0
Accepted
time: 92ms
memory: 35292kb

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:

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

result:

ok AC

Test #18:

score: 0
Accepted
time: 169ms
memory: 35004kb

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
21982 13919
21982 86413
26907 78418
21982 36904
26907 60478
26907 78563
26907 23855
21982 63531
21982 15574
21982 73713
21982 62532
26907 19461
26907 80750
26907 57012
26907 27046
21982 55780
21982 69619
21982 58970
21982 65824
26907 3195
21982 26782
21982 71411
21982 84915
21982 95347
26907...

result:

ok AC

Test #19:

score: 0
Accepted
time: 168ms
memory: 35088kb

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
15917 51514
86919 83613
15917 16333
15917 25291
86919 61711
86919 37621
86919 66805
86919 59550
15917 67744
86919 46644
86919 21771
86919 98164
86919 6655
15917 75053
15917 90431
86919 58023
15917 48769
15917 11506
15917 19125
15917 52852
15917 98702
15917 53360
86919 3999
15917 66767
15...

result:

ok AC

Test #20:

score: 0
Accepted
time: 20ms
memory: 15264kb

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:

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

result:

ok AC

Test #21:

score: 0
Accepted
time: 17ms
memory: 15128kb

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:

15050 14400
5679 16805
15050 11979
15050 5949
5679 9916
5679 2445
15050 15141
15050 16655
15050 16186
15050 1523
15050 1443
15050 10091
5679 9218
5679 16617
15050 16466
15050 1217
5679 19150
5679 2830
15050 7234
5679 11460
5679 8101
15050 6331
15050 14871
5679 10725
15050 12241
5679 8902
15050 7265
...

result:

ok AC

Test #22:

score: 0
Accepted
time: 19ms
memory: 15104kb

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:

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

result:

ok AC

Test #23:

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

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:

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

result:

ok AC

Test #24:

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

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:

16305 19213
7692 12395
16305 12980
16305 7848
16305 11920
7692 6906
7692 3923
16305 4837
16305 11135
16305 2457
16305 9770
16305 10251
16305 6770
16305 12079
7692 7559
7692 15051
7692 1146
16305 17621
16305 8041
7692 19973
16305 11112
7692 3176
7692 957
16305 830
7692 3194
7692 11400
7692 6914
7692 ...

result:

ok AC

Test #25:

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

input:

5
2 1
3 1
4 1
1 5

output:

-1

result:

ok AC

Test #26:

score: 0
Accepted
time: 19ms
memory: 15044kb

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:

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

result:

ok AC

Test #27:

score: 0
Accepted
time: 32ms
memory: 15344kb

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:

971 1
971 5390
6357 10221
6357 16259
971 8902
971 10509
6357 16551
6357 13314
6357 12754
6357 11707
6357 7781
6357 2105
6357 18132
6357 12907
6357 5609
6357 15234
6357 18609
6357 13919
6357 13882
6357 15621
6357 1997
6357 14002
6357 18056
971 7498
971 13534
971 1530
6357 14773
6357 2001
6357 10679
6...

result:

ok AC

Test #28:

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

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:

3062 5445
19398 12966
3062 8179
3062 5779
3062 9123
3062 5079
19398 5478
19398 13748
3062 7203
19398 7645
19398 14929
3062 4717
19398 4564
19398 14318
19398 7348
19398 17915
19398 15109
3062 3853
3062 15246
3062 8228
3062 7726
19398 16617
3062 16607
3062 6228
3062 1615
3062 11897
19398 14499
19398 1...

result:

ok AC

Test #29:

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

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:

19849 10558
19849 7298
19849 3082
16917 17807
16917 793
16917 11663
16917 12412
16917 10699
19849 1146
16917 2462
19849 12577
16917 11701
19849 7622
16917 3831
16917 19955
16917 3001
19849 18329
19849 851
19849 16782
19849 17396
19849 15015
16917 12771
19849 10926
16917 4736
16917 9088
16917 4867
16...

result:

ok AC

Test #30:

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

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
5988 11767
5988 10226
5988 6246
5988 6576
4129 458
5988 5997
4129 16052
5988 10900
4129 4370
4129 17480
5988 11379
5988 4859
5988 14663
5988 18363
5988 1454
4129 18490
4129 17760
5988 19850
5988 19832
5988 4252
5988 5482
5988 2802
4129 17779
5988 8601
4129 10844
5988 17372
4129 1230
4129 1301...

result:

ok AC

Test #31:

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

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:

18123 18166
18123 17313
18123 14313
5770 11207
18123 831
18123 7420
18123 1161
5770 575
18123 3052
18123 7101
18123 18976
5770 18772
5770 18805
18123 10412
5770 8160
18123 15062
5770 19241
5770 11876
5770 613
18123 14829
18123 16531
5770 11665
5770 15722
5770 19841
5770 5758
18123 14519
5770 3637
18...

result:

ok AC

Test #32:

score: 0
Accepted
time: 1963ms
memory: 15436kb

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: 1988ms
memory: 15344kb

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: 28ms
memory: 15268kb

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:

548 12144
548 8713
15026 10266
548 6116
548 5943
548 10496
15026 9193
548 4497
548 5480
548 6858
15026 3003
15026 1958
548 5579
15026 12167
15026 16648
548 18876
15026 10656
15026 6918
548 5632
548 10135
548 11253
548 10068
15026 3833
15026 16257
15026 6924
548 9806
15026 8077
548 8650
15026 9461
15...

result:

ok AC

Test #35:

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

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:

5653 1284
5653 1436
5653 17852
5997 13068
5997 19730
5997 15453
5997 3888
5653 5853
5653 18440
5997 5242
5997 12315
5997 12021
5997 19105
5997 1977
5997 11095
5653 4122
5997 4873
5997 10548
5997 11649
5997 1199
5653 228
5653 4006
5997 10763
5997 1980
5997 9649
5653 11446
5653 14111
5653 14896
5653 6...

result:

ok AC

Test #36:

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

input:

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

output:

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

result:

ok AC

Test #37:

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

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:

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

result:

ok AC

Test #38:

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

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:

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

result:

ok AC

Test #39:

score: 0
Accepted
time: 25ms
memory: 15268kb

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:

4022 3828
14489 5873
4022 17224
14489 7554
14489 6507
4022 17619
14489 1012
14489 18616
14489 19398
4022 16411
4022 578
4022 9621
4022 9684
4022 16733
14489 19501
14489 3217
14489 11111
4022 6539
14489 12001
14489 2251
4022 13411
14489 9228
4022 15833
14489 4315
4022 19092
4022 8033
14489 1103
4022 ...

result:

ok AC

Test #40:

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

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:

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

result:

ok AC

Test #41:

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

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:

14808 11751
14808 1300
2294 9597
14808 6762
14808 6089
14808 10054
14808 17666
2294 14050
2294 2754
14808 10070
14808 10053
2294 3703
14808 13628
14808 17144
2294 15031
14808 10414
14808 4857
2294 15396
2294 6623
2294 3946
14808 17484
14808 8811
14808 7551
2294 3439
14808 6076
14808 1678
14808 4749
...

result:

ok AC

Test #42:

score: 0
Accepted
time: 151ms
memory: 34652kb

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:

36204 72500
5005 1
36204 50542
5005 16422
36204 89151
36204 54297
5005 19071
5005 25039
5005 59896
5005 57305
36204 31678
36204 3514
36204 25341
5005 13381
36204 7507
5005 15806
36204 62775
5005 20433
36204 28013
36204 2793
5005 84857
36204 84225
5005 17263
36204 61853
5005 37741
36204 83001
5005 44...

result:

ok AC

Test #43:

score: 0
Accepted
time: 184ms
memory: 34624kb

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:

16018 37174
16018 26356
16018 70911
48890 20298
16018 89704
48890 74497
48890 14492
16018 10546
16018 71677
48890 28838
48890 23003
48890 41920
48890 95159
48890 34895
16018 74794
48890 10195
16018 54295
16018 21621
48890 70922
16018 56725
16018 67745
16018 30390
48890 31050
48890 78533
48890 8591
1...

result:

ok AC

Test #44:

score: 0
Accepted
time: 136ms
memory: 34612kb

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:

3481 90403
6550 84049
6550 28339
3481 50038
6550 23735
6550 87291
6550 26404
6550 3276
6550 37488
3481 67144
6550 15335
6550 73596
3481 32815
3481 58348
3481 32340
3481 77042
6550 17210
6550 68281
6550 13360
6550 52957
6550 3781
3481 88746
3481 33513
6550 23338
3481 11895
3481 90021
3481 30580
3481 ...

result:

ok AC

Test #45:

score: 0
Accepted
time: 161ms
memory: 34908kb

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:

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

result:

ok AC

Test #46:

score: 0
Accepted
time: 165ms
memory: 34964kb

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:

97189 82182
99779 74187
97189 83434
97189 30609
99779 97443
97189 93951
99779 57868
99779 24839
97189 91314
97189 9148
99779 817
99779 56692
97189 67828
99779 79432
97189 64090
99779 44758
99779 26481
99779 70283
99779 76180
97189 2183
97189 17086
99779 38661
99779 69441
99779 50770
99779 13969
9718...

result:

ok AC

Test #47:

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

input:

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

output:

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

result:

ok AC

Test #48:

score: 0
Accepted
time: 151ms
memory: 34628kb

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:

73495 59819
2111 46211
73495 78631
73495 6887
73495 15685
2111 45496
73495 38399
73495 43932
2111 22491
73495 57782
2111 25655
73495 81578
2111 40906
73495 8185
73495 92518
2111 96199
2111 63790
73495 64847
2111 84427
2111 34665
2111 30015
2111 34952
73495 12997
2111 41447
2111 19357
2111 30750
7349...

result:

ok AC

Test #49:

score: 0
Accepted
time: 197ms
memory: 35328kb

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:

52710 1
1833 71027
1833 48338
52710 61809
52710 79963
52710 39740
1833 86644
1833 14939
1833 39918
1833 41470
1833 23364
52710 54664
52710 96370
52710 53835
52710 67313
1833 33696
1833 44243
1833 50423
52710 70539
1833 73776
1833 560
1833 98363
1833 71623
1833 72365
52710 73548
52710 82843
52710 640...

result:

ok AC

Test #50:

score: 0
Accepted
time: 419ms
memory: 35588kb

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:

20608 55448
20608 4084
78082 22193
78082 13008
78082 82824
20608 91893
20608 72105
20608 5791
78082 44950
78082 11997
78082 42216
78082 41770
20608 20892
78082 68055
78082 22893
78082 47065
20608 54015
20608 91519
20608 80483
20608 1399
78082 23550
20608 46619
78082 47878
20608 85576
20608 37319
780...

result:

ok AC

Test #51:

score: 0
Accepted
time: 320ms
memory: 35232kb

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:

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

result:

ok AC

Test #52:

score: 0
Accepted
time: 173ms
memory: 37020kb

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
71340 43730
71340 8413
91469 13508
91469 53025
71340 44444
91469 46747
71340 54535
71340 16058
71340 27066
91469 73721
91469 35961
71340 18398
71340 3188
91469 9998
71340 57229
91469 96831
71340 2109
71340 89059
71340 89520
71340 62512
71340 9136
91469 32949
91469 27353
71340 19993
91469 173...

result:

ok AC

Test #53:

score: 0
Accepted
time: 167ms
memory: 36100kb

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:

57535 54215
57535 24268
57535 88765
57535 72678
57535 1284
56525 61132
57535 37270
56525 50005
57535 58386
56525 97772
56525 3463
57535 10608
57535 68599
57535 40426
57535 15155
56525 65521
57535 22218
57535 69011
57535 64952
57535 33469
57535 31458
56525 76924
56525 27278
57535 18294
56525 2343
575...

result:

ok AC

Test #54:

score: -100
Time Limit Exceeded

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:


result: