QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#817227#9875. Don't Detect CycleAfterlife#AC ✓111ms4384kbC++203.9kb2024-12-16 21:00:402024-12-16 21:00:41

Judging History

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

  • [2024-12-16 21:00:41]
  • 评测
  • 测评结果:AC
  • 用时:111ms
  • 内存:4384kb
  • [2024-12-16 21:00:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int N=4004;
int n,m,dep[N],f[N];
vector<pair<int,int> > G[N];
ull h[N];
mt19937_64 rnd(233);
bool vis[N];
ull he[N],hn[N];
void dfs1(int u,int fa){
    f[u]=fa;
    vis[u]=1;
    for(auto [v,id]:G[u]){
        if(v==fa)continue;
        if(vis[v]){
            if(dep[v]<dep[u]){
                he[u]^=h[id];
                he[v]^=h[id];
                hn[u]^=h[id];
                hn[f[v]]^=h[id];
            }
            continue;
        }
        dep[v]=dep[u]+1;
        dfs1(v,u);
        he[u]^=he[v];
        hn[u]^=hn[v];
    }
    //cerr<<" ?? "<<u<<" "<<he[u]<<" "<<hn[u]<<endl;
}
int o;
void dfs2(int u){
    //cerr<<" u: "<<u<<endl;
    if(o)return;
    for(auto [v,id]:G[u]){
        if(v==f[u])continue;
        if(f[v]==u){
            if(he[v]==0){
                if(hn[u]==hn[v]){
                    o=id;
                    return;
                }
            }
            else{
                bool ok=1;
                ull qwq=he[v];
                for(auto [z,id]:G[u]){
                    if(f[z]==u){
                        if(he[z]&&he[z]^qwq){
                            ok=0;
                        }
                    }
                    else if(f[u]==z){
                        if(he[u]&&he[u]^qwq){
                            ok=0;
                        }
                    }
                    else{
                        if(!(h[id]==hn[u]&&h[id]==hn[v]&&h[id]==he[v])){
                            ok=0;
                        }
                    }
                }
                for(auto [z,id]:G[v]){
                    if(f[z]==v){
                        if(he[z]&&he[z]^qwq){
                            ok=0;
                        }
                    }
                    else if(f[v]==z){
                        if(he[v]&&he[v]^qwq){
                            ok=0;
                        }
                    }
                    else{
                        if(!(h[id]==hn[u]&&h[id]==hn[v]&&h[id]==he[v])){
                            ok=0;
                        }
                    }
                }

                if(ok){
                    o=id;
                    return;
                }
            }
            dfs2(v);
        }
        else{
            if(hn[u]==hn[v]&&hn[u]==h[id]){
                o=id;
                return;
            }
        }
        
    }
}
int x[N],y[N];
int Find(){
    for(int i=1;i<=n;++i)vis[i]=dep[i]=he[i]=hn[i]=f[i]=0;
    o=0;
    for(int i=1;i<=n;++i){
        if(vis[i])continue;
        dfs1(i,0);
        dfs2(i);
        if(o){
            for(auto it=G[x[o]].begin();it!=G[x[o]].end();++it){
                if(it->first==y[o]){
                    G[x[o]].erase(it);
                    break;
                }
            }
            for(auto it=G[y[o]].begin();it!=G[y[o]].end();++it){
                if(it->first==x[o]){
                    G[y[o]].erase(it);
                    break;
                }
            }
            return o;
        }
    }
    return -1;
}
void Solve(){
    cin>>n>>m;
    for(int i=1;i<=n;++i){
        G[i].clear();
        
    }
    for(int i=1;i<=m;++i){
        h[i]=rnd();
    }
    for(int i=1;i<=m;++i){
        int u,v;
        cin>>u>>v;
        x[i]=u,y[i]=v;
        G[u].emplace_back(v,i);
        G[v].emplace_back(u,i);
    }
    vector<int> ans;
    for(int t=1;t<=m;++t){
        int x=Find();
        //cerr<<" ----------- "<<x<<endl;
        if(x==-1){
            cout<<-1<<'\n';
            return;
        }
        ans.push_back(x);
    }
    reverse(ans.begin(),ans.end());
    for(auto x:ans){
        cout<<x<<' ';
    }
    cout<<'\n';
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T;
    cin>>T;
    while(T--)Solve();
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
4 4
1 2
2 3
3 4
4 2

output:

3 4 1 2 

result:

ok Correct

Test #2:

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

input:

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

output:

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

result:

ok Correct

Test #3:

score: 0
Accepted
time: 41ms
memory: 4052kb

input:

50
3214 2907
970 1929
2860 3033
1322 2296
931 1192
861 2505
831 2469
231 2549
1 2306
1765 1842
999 3171
177 2007
1798 1894
827 3180
673 1738
1163 1573
2213 2781
2766 3200
1663 2197
1797 2281
315 2637
442 2689
558 2874
1520 2591
651 1923
1133 2920
1747 2412
1104 1528
313 2487
632 3124
660 2182
1581 2...

output:

759 1298 1885 2540 2761 1655 2575 1253 2143 1695 2418 2589 1206 1456 2304 2210 2583 2048 2416 1749 927 427 226 2904 1072 2483 1210 281 1811 1552 332 1605 2 1796 1852 1368 872 489 2240 1857 972 880 201 959 2685 1771 774 1485 1233 2365 2518 1264 2562 1619 17 1760 1134 1808 843 1403 1199 632 126 1952 1...

result:

ok Correct

Test #4:

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

input:

48
732 104
388 425
176 558
7 695
504 507
163 705
204 456
139 432
104 716
535 582
254 682
70 278
77 385
600 680
373 564
197 653
335 569
81 579
339 604
407 580
253 383
480 549
145 308
52 373
426 525
268 359
408 595
47 397
479 569
268 403
477 663
434 660
330 343
56 692
376 450
200 553
299 713
114 584
1...

output:

48 46 86 13 85 45 93 68 9 89 66 4 96 21 28 30 90 67 31 24 26 19 76 1 98 34 14 87 51 39 84 18 65 42 16 91 32 78 36 41 102 61 70 95 74 29 25 104 100 40 56 10 20 60 62 50 83 6 77 88 35 15 80 59 92 2 58 49 5 64 22 44 81 7 54 47 82 73 75 55 103 94 37 38 8 43 52 99 97 69 17 12 11 79 71 33 23 63 27 53 72 5...

result:

ok Correct

Test #5:

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

input:

24
3635 2454
724 2161
994 3233
30 278
2047 3627
693 1048
112 2609
9 1552
889 946
987 2538
923 1911
53 1198
2429 3200
1338 3544
504 2644
1116 3446
815 877
245 3601
2177 3180
212 1638
1140 3241
159 2455
2447 2460
957 1585
980 2338
1254 3014
382 3596
510 595
1408 2300
2053 2276
2177 3415
1051 3353
136 ...

output:

1802 556 644 596 1796 774 1362 1720 1553 2193 2288 645 2130 2258 1148 158 955 2098 1917 938 581 434 49 2438 1673 123 1427 821 2186 655 1041 111 2421 1105 461 332 669 1102 1328 1896 1140 912 2245 2229 139 363 1914 1083 1681 2033 2323 2061 654 2001 1674 188 1636 109 2440 913 1054 1508 811 1961 1021 11...

result:

ok Correct

Test #6:

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

input:

56
2367 1768
132 2148
1280 2214
473 2270
78 2126
374 2080
777 1617
74 152
46 125
36 1136
1340 2010
1536 1801
291 619
610 1567
1688 2303
1005 2308
1101 1988
1695 2257
1056 1405
1134 1579
1819 2281
1281 1952
2065 2102
1984 2353
215 1994
984 2258
1916 2059
1128 2198
966 1048
965 1424
866 932
227 543
33...

output:

745 920 563 935 852 170 887 1560 182 541 618 434 1731 1360 1533 1595 1544 1393 1399 830 195 941 766 651 1509 1123 22 1513 1602 1034 1207 632 456 561 1300 499 23 878 660 1314 308 226 409 1615 803 348 587 349 1063 1629 1290 1576 853 599 1697 441 26 421 229 1041 163 1100 1439 1112 242 1097 1349 1475 14...

result:

ok Correct

Test #7:

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

input:

56
1804 2031
215 520
41 228
505 1449
1202 1467
175 474
583 1684
127 1013
11 1132
251 1009
1333 1516
22 633
168 1160
866 1584
1501 1510
425 1494
563 1764
1341 1646
76 114
541 943
163 166
103 184
455 1225
708 1649
836 1551
551 1381
570 1509
125 221
371 1117
436 1012
392 732
76 379
1040 1359
119 1405
1...

output:

-1
15 11 10 9 4 13 12 18 14 1 17 16 5 6 8 7 3 2 
7 1 5 12 16 18 2 3 10 14 8 20 13 9 6 4 15 19 11 17 
19 13 2 5 11 9 16 7 23 17 12 10 25 15 4 1 14 20 24 22 21 3 18 8 6 
18 16 19 12 4 1 10 6 20 8 7 3 5 11 21 17 9 15 13 2 14 
7 10 19 16 13 20 12 1 3 18 17 2 6 14 11 9 5 8 4 15 
19 4 16 8 14 7 5 18 6 10 ...

result:

ok Correct

Test #8:

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

input:

38
17 122
7 11
1 8
2 13
5 6
6 10
9 17
6 13
10 12
2 9
12 14
14 15
3 8
8 12
3 16
3 17
6 16
5 12
4 11
11 16
5 13
5 17
1 4
1 10
8 15
2 16
3 10
6 7
5 7
2 17
10 17
7 12
3 6
9 11
6 17
4 6
9 16
1 16
12 15
7 17
9 10
1 5
10 15
7 10
3 13
1 14
8 14
4 5
4 17
1 17
8 17
7 8
1 2
10 13
11 15
15 16
2 12
2 11
3 7
8 9
...

output:

-1
-1
-1
-1
-1
15 11 10 9 4 13 12 18 14 1 17 16 5 6 8 7 3 2 
7 1 5 12 16 18 2 3 10 14 8 20 13 9 6 4 15 19 11 17 
19 13 2 5 11 9 16 7 23 17 12 10 25 15 4 1 14 20 24 22 21 3 18 8 6 
18 16 19 12 4 1 10 6 20 8 7 3 5 11 21 17 9 15 13 2 14 
7 10 19 16 13 20 12 1 3 18 17 2 6 14 11 9 5 8 4 15 
19 4 16 8 14 ...

result:

ok Correct

Test #9:

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

input:

61
12 66
11 12
5 8
9 12
4 9
2 9
6 12
2 11
1 2
3 6
3 12
6 10
5 6
2 12
10 12
8 12
7 8
7 9
2 8
3 11
3 9
3 10
8 11
2 6
5 12
5 9
4 7
4 5
4 6
5 11
1 3
5 7
1 7
7 10
5 10
6 7
4 12
3 5
4 8
2 3
1 8
6 11
4 11
3 7
1 5
3 4
9 11
1 10
4 10
6 9
7 11
1 4
8 9
10 11
1 11
7 12
1 9
9 10
1 12
6 8
8 10
2 10
2 5
3 8
2 7
1 ...

output:

-1
-1
-1
-1
-1
-1
15 11 10 9 4 13 12 18 14 1 17 16 5 6 8 7 3 2 
7 1 5 12 16 18 2 3 10 14 8 20 13 9 6 4 15 19 11 17 
19 13 2 5 11 9 16 7 23 17 12 10 25 15 4 1 14 20 24 22 21 3 18 8 6 
18 16 19 12 4 1 10 6 20 8 7 3 5 11 21 17 9 15 13 2 14 
7 10 19 16 13 20 12 1 3 18 17 2 6 14 11 9 5 8 4 15 
19 4 16 8 ...

result:

ok Correct

Test #10:

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

input:

18
51 1255
24 43
42 51
4 36
29 31
41 42
43 48
10 26
30 40
4 51
25 42
24 42
2 6
3 24
6 21
34 46
5 10
2 37
12 41
19 25
1 2
18 22
1 20
45 49
3 22
14 25
16 25
26 31
25 48
36 45
24 29
34 39
26 29
6 37
18 38
2 51
10 22
15 26
30 33
1 15
10 37
17 33
11 22
28 32
32 39
13 17
21 28
8 23
20 46
8 38
5 44
5 30
4 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
15 11 10 9 4 13 12 18 14 1 17 16 5 6 8 7 3 2 
7 1 5 12 16 18 2 3 10 14 8 20 13 9 6 4 15 19 11 17 
19 13 2 5 11 9 16 7 23 17 12 10 25 15 4 1 14 20 24 22 21 3 18 8 6 
18 16 19 12 4 1 10 6 20 8 7 3 5 11 21 17 9 15 13 2 14 
7 10 19 16 13 20 12 1 3 18 17 2 6 14 11 9 5 8 4 15 
19 4...

result:

ok Correct

Test #11:

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

input:

61
22 223
1 22
10 22
2 7
19 20
13 17
17 21
18 19
15 16
9 17
5 19
5 8
12 18
4 17
10 20
2 10
4 15
7 11
16 19
5 20
3 14
3 17
7 12
3 21
4 11
17 22
10 17
8 21
9 20
6 11
2 20
5 7
3 18
9 22
13 22
6 14
14 19
5 12
4 22
2 3
14 17
12 16
7 20
5 10
4 7
4 13
1 19
10 13
1 20
13 19
4 6
11 19
3 11
9 14
8 15
3 16
2 8...

output:

-1
-1
-1
-1
-1
-1
-1
15 11 10 9 4 13 12 18 14 1 17 16 5 6 8 7 3 2 
7 1 5 12 16 18 2 3 10 14 8 20 13 9 6 4 15 19 11 17 
19 13 2 5 11 9 16 7 23 17 12 10 25 15 4 1 14 20 24 22 21 3 18 8 6 
18 16 19 12 4 1 10 6 20 8 7 3 5 11 21 17 9 15 13 2 14 
7 10 19 16 13 20 12 1 3 18 17 2 6 14 11 9 5 8 4 15 
19 4 16...

result:

ok Correct

Test #12:

score: 0
Accepted
time: 103ms
memory: 4116kb

input:

1
4000 4000
1248 3248
260 3260
344 1017
843 3949
451 1483
275 1413
231 3477
264 940
567 1383
1072 3173
830 3445
437 2322
929 1624
1221 2034
3297 3458
1412 1642
837 2505
1918 3259
554 2070
3630 3807
1217 3188
3149 3199
949 1179
2697 3656
802 2039
2496 3757
1073 2857
765 2310
178 3862
1385 2597
1870 2...

output:

2384 3701 401 1775 2340 1532 2295 3230 1694 3627 3329 1959 2271 2163 2209 1553 1375 1087 3335 20 3074 3400 534 464 3415 2498 1890 901 912 2826 2471 2115 3184 3921 1665 1521 961 3174 231 1874 2286 1173 532 2346 2076 2417 2762 1501 1742 3908 1558 2874 175 1135 679 2267 1766 924 2587 2023 823 1875 3245...

result:

ok Correct

Test #13:

score: 0
Accepted
time: 98ms
memory: 4340kb

input:

1
4000 4000
224 2401
586 2589
379 1471
1805 2518
2145 2874
2310 3019
2487 3160
1729 3934
762 971
2734 3272
2633 2673
846 2606
1047 1755
2907 3577
2329 3026
2121 2725
375 3941
966 3109
30 1389
2721 3284
93 1944
2018 3260
384 2761
2318 3964
2917 3784
123 2934
409 3449
3701 3869
1343 2534
1171 2588
584...

output:

1137 1506 3358 1548 2833 2539 3314 664 3128 476 2977 2388 2406 28 2219 214 2767 1319 3552 1178 1526 3161 1964 3295 1935 2925 1852 134 2472 3860 3748 2184 891 3339 3624 3232 1346 633 1913 3677 3045 713 3201 1354 834 3953 3554 1761 1533 1362 1710 2490 3684 1360 2649 546 2360 388 66 740 3209 2692 2609 ...

result:

ok Correct

Test #14:

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

input:

1
4000 4000
2254 2471
2217 2613
3360 3617
152 3820
3226 3879
1688 3423
172 595
2149 2514
2373 3866
456 1567
8 1047
438 2143
1738 2761
219 3396
2476 2574
3209 3535
3572 3903
707 3740
810 1693
1866 3504
199 2163
1085 1137
104 2414
37 1979
3376 3387
1359 1860
816 1070
864 3772
1163 3054
2481 3600
1535 ...

output:

1089 3419 3621 3736 1312 2963 3174 2364 3080 801 344 3831 3750 1535 653 3848 2777 1427 3529 1468 3663 125 3795 3082 3444 3328 3647 2824 2667 698 1550 3753 3854 1635 1275 1722 1035 959 1511 564 2756 252 17 1040 634 771 3056 3324 1260 2142 1386 2051 1812 1382 166 1772 2810 160 3628 1194 1634 1952 2312...

result:

ok Correct

Test #15:

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

input:

1
4000 4000
1391 3587
137 3069
434 3678
630 1365
1721 2147
1885 3917
372 2688
215 1678
2581 2989
628 934
547 838
1835 2960
2265 3755
1393 3277
1906 3593
3053 3131
174 601
2770 3541
855 3399
320 3525
948 3966
3095 3976
560 3642
2417 3751
481 2338
2888 3493
19 3482
270 3754
922 1699
3272 3313
2066 376...

output:

1497 3005 3581 1960 3693 3246 303 1340 2529 2216 3236 2384 3179 1688 477 360 414 840 524 596 2052 2721 663 3233 1986 425 1355 1343 1155 3434 540 713 2708 110 1397 2898 3810 2262 1743 1005 3768 1075 631 61 2225 3902 1043 1191 36 1285 1047 3211 2632 794 406 541 453 1827 1001 2354 1955 2686 2132 3780 1...

result:

ok Correct

Test #16:

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

input:

1
4000 4000
857 1354
1781 2427
2049 3631
1583 2512
100 839
1824 2596
566 2096
2754 3971
8 3882
1291 1410
2768 2909
2481 3957
153 2599
340 3385
1911 2004
2161 2476
340 3663
44 1333
1034 3119
46 2602
2088 2164
2543 3112
127 2347
1056 1149
1837 2173
1715 3124
2750 3739
1584 1904
2951 3483
665 1963
127 ...

output:

3905 1928 991 2104 2793 420 1409 990 1753 1391 934 1817 51 469 1204 3968 1442 792 426 47 2661 210 196 3781 1200 1855 967 1962 1088 1253 2299 1396 3376 1227 556 32 2426 655 3829 2232 1314 617 1062 977 725 3645 709 2270 160 1380 1143 849 1121 1504 2099 2911 3277 3759 592 3121 3951 2409 583 2809 2733 2...

result:

ok Correct

Test #17:

score: 0
Accepted
time: 96ms
memory: 4368kb

input:

1
4000 4000
1849 3380
891 1650
1804 1937
3314 3847
124 3415
1489 3545
1000 3552
2600 3390
2047 2407
442 1613
2632 3692
2049 3312
495 589
145 1811
2345 2769
3666 3892
783 3201
584 1116
1406 1953
368 2322
1709 3910
1481 2979
1025 2467
1404 2572
1893 3528
413 518
619 917
111 3212
716 2004
280 793
1219 ...

output:

3613 1408 1336 1892 513 3675 3240 2498 3266 3624 1518 1132 958 533 927 3888 3320 2541 1327 2834 2306 2022 3400 2002 3133 1691 2391 16 940 911 2033 2509 1577 3616 3453 1799 1430 756 3825 1652 2301 3096 1391 413 2150 759 1667 2093 146 1006 786 2110 3167 613 2581 2902 325 2269 2841 694 874 3246 3348 74...

result:

ok Correct

Test #18:

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

input:

1
4000 4000
383 1621
1774 3258
129 2251
1694 2640
386 3612
477 1611
434 3737
1413 1920
2054 3773
94 1165
167 2412
1813 2474
2011 2115
2371 3915
229 1651
2553 3489
908 2479
687 2505
2227 3042
219 402
1404 1784
864 1828
798 3431
643 1755
1445 2283
1325 1659
832 1426
3320 3722
48 176
1859 3930
2996 340...

output:

2457 1066 104 210 2401 3317 1560 2585 2400 3025 1020 1605 1973 404 3442 2114 3201 2188 2064 2503 1340 152 2344 1916 129 2560 1170 3787 285 2009 1617 1285 3878 1297 3144 1214 1904 3549 2241 519 2282 3493 3682 3716 3164 1893 2818 3263 1141 3783 1606 3248 1624 1877 2556 445 1597 3444 1392 2243 2070 841...

result:

ok Correct

Test #19:

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

input:

1
4000 4000
2069 2090
745 803
3546 3918
1002 2097
94 442
158 403
1655 2002
941 1223
1669 3905
2108 2455
2812 3571
430 3214
327 2575
1240 3428
422 1160
914 2219
3 1449
108 3284
2398 3908
555 1207
1924 3504
1472 3187
2360 3247
2174 2420
2753 2758
1536 2813
699 950
2321 3501
1040 3308
159 1706
7 2088
2...

output:

2465 1218 379 3347 1085 376 3634 3586 200 3425 3207 2208 121 1087 3128 1108 2121 1637 3195 1883 1590 250 1152 2528 2498 1380 1478 904 3570 35 1477 3 2199 1795 1444 2259 2119 256 2620 577 803 2440 556 1142 1753 2546 1683 173 2366 2369 1202 3438 3086 955 477 2505 3708 202 353 1863 478 595 3936 2188 23...

result:

ok Correct

Test #20:

score: 0
Accepted
time: 98ms
memory: 4132kb

input:

1
4000 4000
1388 3080
144 796
229 2513
1648 3222
2292 3099
1881 2771
1200 1281
2240 2865
1634 2573
2066 2604
464 1615
2711 3961
2851 3143
3102 3567
1621 3707
3536 3568
201 3996
1176 2466
2201 3318
805 3076
1454 1550
2455 3385
2522 3598
1353 2032
1312 1747
1142 3879
404 2183
2276 3828
1592 2571
1993 ...

output:

1595 3835 1648 1470 243 523 2687 1118 1757 49 348 1754 1083 3401 337 1982 2340 2463 1662 486 2256 1768 1473 514 1907 2738 98 2689 2319 1112 2452 2315 2053 1661 2497 2094 888 3978 386 721 234 77 1602 2858 748 804 2656 3923 176 3982 137 3369 2574 1336 384 3311 3792 2025 744 2660 160 1987 3201 3188 53 ...

result:

ok Correct

Test #21:

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

input:

1
4000 4000
599 1640
57 3563
1764 2956
415 1083
988 2327
2258 3583
1721 2866
117 322
216 1491
2904 3861
1781 3007
1552 2059
1436 2167
2359 2733
1289 1543
929 2422
2529 3473
1494 1536
2483 2735
945 2118
3404 3813
1163 2724
2208 3585
342 2425
609 1888
3412 3825
956 2277
3005 3287
1468 3761
757 3952
12...

output:

1255 3064 3070 1930 2403 1230 2911 1578 1424 2426 3511 2174 2228 2970 410 1880 3204 3323 799 397 3567 886 2993 955 3027 609 1877 2938 3975 3672 3694 1477 3910 3504 534 885 930 2007 3713 2090 916 2916 3742 2536 1016 1258 449 424 614 2031 3602 854 101 3499 172 2694 1269 2818 1809 3081 2961 261 454 287...

result:

ok Correct

Test #22:

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

input:

1
4000 4000
124 2437
1479 1738
2506 3836
336 1763
489 1840
2193 2457
1139 2167
1975 3010
858 2835
763 2778
1474 1959
615 2586
603 2843
105 3410
868 1922
663 2136
286 1999
1705 3905
443 2261
1545 1879
1696 2785
928 1128
1698 3691
517 820
475 2735
1660 1688
1374 1947
16 500
1217 2310
626 3355
825 3368...

output:

2835 243 2333 3775 398 2372 3232 1367 2608 3181 2327 448 3047 3697 70 3546 2061 1000 1529 1416 3639 961 857 2134 100 634 3343 577 2074 1507 1665 1362 2335 657 3179 3396 2840 358 1174 3717 272 989 126 3635 88 1241 3280 3030 2047 2379 3381 3230 1939 3120 1027 2966 145 3398 3276 3485 3640 1323 2186 825...

result:

ok Correct

Test #23:

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

input:

1
4000 4000
2640 2931
781 1781
1356 2326
899 3001
112 3416
2176 3058
1963 2402
3734 3821
929 1637
1184 3733
2286 2423
251 3134
481 3204
652 857
3056 3355
34 1347
1237 2171
116 1048
1313 2773
1638 3625
2602 3486
1984 2942
817 3986
2889 3974
2581 3245
1203 1729
68 673
1879 2976
3598 3695
1428 3062
166...

output:

2739 3979 630 711 3819 3165 1347 3901 250 1819 3470 3063 2379 857 8 263 923 2354 3743 1233 3124 2086 2635 978 2585 1633 2325 3069 1591 3546 587 112 2403 1146 425 2722 888 445 2791 732 776 1127 777 1535 457 585 2704 3968 1563 2136 3792 1313 1298 1412 1936 3666 32 3076 679 314 580 1670 2747 1079 3567 ...

result:

ok Correct

Test #24:

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

input:

1
4000 4000
2584 3827
1642 3825
1231 1269
1968 3847
2014 3281
1042 2109
3063 3559
2264 2280
1187 2797
1103 3689
2380 3524
1334 3514
2892 2981
60 70
264 3761
97 3633
214 2878
371 2369
878 3044
1916 3642
693 3366
1368 3262
71 1787
919 2662
1897 2838
46 395
1 2677
1051 2591
102 1130
876 3903
706 2657
5...

output:

3790 3502 1772 2099 1900 2309 2423 2341 3192 3997 2138 3349 2161 2807 901 1853 3566 3884 2982 2478 1761 275 2648 658 2374 752 3029 2142 3866 2847 2916 160 1006 80 3248 2601 2527 2236 446 3135 3370 3920 2267 2338 234 2604 730 3998 2079 236 2487 2491 2228 2195 1767 3246 3526 1146 951 121 2272 3297 228...

result:

ok Correct

Test #25:

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

input:

1
4000 4000
547 2591
286 3922
2196 3068
2578 2917
835 1266
3148 3157
187 2045
872 951
1181 1665
1404 3787
1455 3381
1709 1931
3951 3955
416 992
1498 1591
2757 3441
3740 3906
126 3458
3670 3960
1767 3262
354 3956
316 1176
1407 3778
2319 2762
1125 2344
3083 3477
413 1410
739 2013
1993 3133
1683 2194
2...

output:

357 2005 2255 2855 2720 299 2245 442 758 1042 378 2092 1107 2537 1467 3306 1001 410 2445 329 19 1550 1773 3832 2990 1492 141 735 2921 550 2196 1149 2836 2391 1307 2650 1620 1650 3724 2118 2991 1191 3967 2843 915 416 3209 1592 1513 2837 316 1786 2788 3939 364 2359 3015 2860 567 3538 1899 2683 3662 28...

result:

ok Correct

Test #26:

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

input:

1
4000 4000
1030 1263
132 3186
430 2576
636 3420
1262 3141
599 2920
796 2546
1384 3451
275 1134
788 3228
1933 2752
1862 3696
1946 2286
137 1550
723 1944
1790 3458
2117 3103
905 1318
489 1003
17 1115
704 3506
1028 2129
3108 3154
1765 3098
536 2877
1278 1672
1919 3753
3189 3542
1172 2258
2379 3010
248...

output:

256 1938 2973 3063 2748 670 2844 3897 917 170 2681 2807 1005 3544 2083 3167 2968 3958 2115 2215 1979 3565 3796 2969 3096 3664 3205 354 3148 3514 1381 612 2221 1019 1623 3182 2155 2696 567 2899 675 1265 3902 2898 408 139 654 2859 3832 1294 2463 3160 269 3290 456 1447 3431 3233 972 3226 2377 2403 1384...

result:

ok Correct

Test #27:

score: 0
Accepted
time: 99ms
memory: 4308kb

input:

1
4000 4000
183 1656
21 2247
1518 1680
2834 3783
156 1065
557 1358
759 1845
1390 2208
191 1559
546 3980
1892 3508
1239 1251
2735 3088
305 644
2642 3483
708 1799
748 1634
601 1141
736 1413
640 2977
698 1568
2266 3837
2705 3388
512 2528
18 3087
484 1959
2547 3604
3178 3542
396 2064
324 3070
1616 3693
...

output:

473 2613 3521 1890 3647 210 1825 1017 2720 3397 1544 2248 362 238 2982 1158 3004 3021 896 2670 1822 2493 1672 1958 1045 3837 1603 90 3623 1713 2505 472 3947 2893 734 609 1882 1464 2944 2908 2022 3790 2378 755 2448 389 3215 2539 3477 3300 782 1898 1632 1095 2494 3261 3675 441 386 1342 1446 1452 423 3...

result:

ok Correct

Test #28:

score: 0
Accepted
time: 99ms
memory: 4140kb

input:

1
4000 4000
567 2891
2734 2894
2315 3205
293 3742
1306 3744
186 2629
2544 3454
566 3863
2489 2670
886 1213
1771 3242
4 2136
1384 3689
1974 3078
336 1482
471 2301
2553 3063
1640 2046
3020 3456
2164 3972
2294 2646
554 3475
1960 2990
89 1020
563 2120
973 1827
149 2943
2158 2858
982 3543
995 3049
498 34...

output:

771 2767 2620 1791 3475 2480 2369 246 243 3090 3927 3808 3917 1946 963 3433 2187 652 489 1852 3190 756 2766 1052 3509 3790 2603 1244 3334 2750 1637 264 248 2427 688 1291 2932 2676 3241 2361 3218 3812 1295 1071 2880 3340 399 2669 2787 2894 2590 1112 3124 2837 1366 2997 3307 1656 92 286 600 3950 1282 ...

result:

ok Correct

Test #29:

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

input:

1
4000 4000
73 1104
1963 3399
1916 3595
1759 1941
1144 2204
861 3316
1415 2794
260 3545
411 428
1137 1416
2280 3214
127 2192
2793 3102
2048 2157
933 3017
1500 2353
513 3976
892 3236
2269 2434
532 2551
2927 3537
229 2810
2457 3568
1891 2380
2514 3483
1915 2167
2501 3286
346 1808
3181 3903
383 2516
15...

output:

937 2975 3500 1169 75 1928 1916 3027 2933 1117 3354 2214 490 1224 348 2013 3346 1762 2509 3764 3170 1764 1347 1653 2524 1741 2926 2381 320 3882 1078 3302 1270 2428 1219 2595 1612 1920 968 1318 1017 2537 1931 1365 2649 523 723 882 1918 1688 574 732 3459 827 205 3954 3071 2257 2076 3571 2298 596 841 1...

result:

ok Correct

Test #30:

score: 0
Accepted
time: 103ms
memory: 4376kb

input:

1
4000 4000
82 3284
1814 2006
1618 2435
57 2861
232 2959
169 2668
1718 2748
506 3604
2148 2231
3110 3993
3589 3875
1690 3387
256 3376
1067 1531
43 3211
2724 3985
675 3128
323 701
50 1754
251 2459
3086 3775
3328 3506
1158 2762
1870 3879
467 1410
1044 2314
2381 2485
957 1432
693 1700
75 1656
34 2290
1...

output:

2004 3030 240 1119 625 2022 1834 3891 2105 379 1039 2213 3143 784 2553 1207 951 1102 2051 715 1000 2404 3640 1418 1948 944 3431 2059 1961 2571 1412 3521 1204 503 1375 719 64 2320 11 865 1757 1309 2586 2726 2862 3091 2491 2487 1258 482 1936 3684 1059 1720 157 3777 2983 3447 2922 2986 1228 2341 1504 2...

result:

ok Correct

Test #31:

score: 0
Accepted
time: 96ms
memory: 4148kb

input:

1
4000 4000
1837 3254
678 3631
2009 3325
2084 2160
954 1704
266 3555
1857 1923
1584 3192
1855 3080
978 3030
1513 2113
1085 1279
2186 2256
359 2276
245 416
2087 2172
1561 3688
2495 3233
894 1710
2337 2866
1150 2428
481 1172
2668 3079
2440 2745
3362 3935
2470 3359
2890 3602
2681 2940
2033 3792
2995 39...

output:

3448 3649 3624 2123 2678 3541 1243 849 2840 2126 2505 3793 1495 2793 3368 977 1674 2478 3572 298 948 451 3159 56 168 3546 3978 399 2022 3073 2983 166 1077 1882 81 2711 1078 1364 261 2524 3767 516 1754 89 1653 3268 3507 2412 2843 2314 102 2681 227 2728 1726 54 1216 270 25 2779 604 642 3671 193 3308 8...

result:

ok Correct

Test #32:

score: 0
Accepted
time: 99ms
memory: 4080kb

input:

1
4000 4000
2666 2788
1806 3099
799 2195
252 2483
1011 1837
1177 1351
754 2378
386 2651
2444 3234
1836 3950
1718 3367
2171 3630
1177 2162
2017 2708
2226 2308
2022 2183
1004 1086
944 2510
669 3126
545 731
253 3292
2218 2491
2695 2948
1009 3866
247 3119
1497 3806
1061 3704
648 2105
1349 2085
2566 3245...

output:

1909 1345 797 1089 1715 1193 1915 3047 3695 3638 173 423 2548 1410 3320 3207 1706 1157 972 2194 2117 3479 700 2461 780 352 3786 2165 3133 67 1786 599 3544 1667 1170 959 1949 722 2743 2867 1261 2166 1757 3981 583 1663 1893 693 2312 370 3789 782 162 542 2964 1976 991 2069 372 1857 319 2128 3434 1608 2...

result:

ok Correct

Test #33:

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

input:

70
2 1
1 2
3 1
1 2
3 1
1 3
3 2
1 2
1 3
3 1
2 3
3 2
1 2
2 3
3 2
1 3
2 3
3 3
1 2
1 3
2 3
4 1
1 2
4 1
1 3
4 2
1 2
1 3
4 1
1 4
4 2
1 2
1 4
4 2
1 3
1 4
4 3
1 2
1 3
1 4
4 1
2 3
4 2
1 2
2 3
4 2
1 3
2 3
4 3
1 2
1 3
2 3
4 2
1 4
2 3
4 3
1 2
1 4
2 3
4 3
1 3
1 4
2 3
4 4
1 2
1 3
1 4
2 3
4 1
2 4
4 2
1 2
2 4
4 2
1...

output:

1 
1 
1 
2 1 
1 
2 1 
2 1 
3 2 1 
1 
1 
2 1 
1 
2 1 
2 1 
3 2 1 
1 
2 1 
2 1 
3 2 1 
2 1 
3 2 1 
3 2 1 
4 3 2 1 
1 
2 1 
2 1 
3 2 1 
2 1 
3 2 1 
3 2 1 
4 3 2 1 
2 1 
3 2 1 
3 2 1 
4 3 2 1 
3 2 1 
4 3 2 1 
4 3 2 1 
-1
1 
2 1 
2 1 
3 2 1 
2 1 
3 2 1 
3 2 1 
4 3 1 2 
2 1 
3 2 1 
3 2 1 
4 3 2 1 
3 2 1 
...

result:

ok Correct

Test #34:

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

input:

255
5 1
1 2
5 1
1 3
5 2
1 2
1 3
5 1
1 4
5 2
1 2
1 4
5 2
1 3
1 4
5 3
1 2
1 3
1 4
5 1
1 5
5 2
1 2
1 5
5 2
1 3
1 5
5 3
1 2
1 3
1 5
5 2
1 4
1 5
5 3
1 2
1 4
1 5
5 3
1 3
1 4
1 5
5 4
1 2
1 3
1 4
1 5
5 1
2 3
5 2
1 2
2 3
5 2
1 3
2 3
5 3
1 2
1 3
2 3
5 2
1 4
2 3
5 3
1 2
1 4
2 3
5 3
1 3
1 4
2 3
5 4
1 2
1 3
1 4
...

output:

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

result:

ok Correct

Test #35:

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

input:

256
5 1
3 5
5 2
1 2
3 5
5 2
1 3
3 5
5 3
1 2
1 3
3 5
5 2
1 4
3 5
5 3
1 2
1 4
3 5
5 3
1 3
1 4
3 5
5 4
1 2
1 3
1 4
3 5
5 2
1 5
3 5
5 3
1 2
1 5
3 5
5 3
1 3
1 5
3 5
5 4
1 2
1 3
1 5
3 5
5 3
1 4
1 5
3 5
5 4
1 2
1 4
1 5
3 5
5 4
1 3
1 4
1 5
3 5
5 5
1 2
1 3
1 4
1 5
3 5
5 2
2 3
3 5
5 3
1 2
2 3
3 5
5 3
1 3
2 3
...

output:

1 
2 1 
2 1 
3 2 1 
2 1 
3 2 1 
3 2 1 
4 3 2 1 
2 1 
3 2 1 
3 2 1 
4 3 1 2 
3 2 1 
4 3 2 1 
4 3 2 1 
5 4 3 1 2 
2 1 
3 2 1 
3 2 1 
4 3 2 1 
3 2 1 
4 3 2 1 
4 3 2 1 
5 4 3 2 1 
3 2 1 
4 3 2 1 
4 3 2 1 
-1
4 3 2 1 
5 4 3 2 1 
5 4 3 2 1 
-1
2 1 
3 2 1 
3 2 1 
4 3 2 1 
3 2 1 
4 3 2 1 
4 3 2 1 
5 4 3 2 1...

result:

ok Correct

Test #36:

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

input:

256
5 1
4 5
5 2
1 2
4 5
5 2
1 3
4 5
5 3
1 2
1 3
4 5
5 2
1 4
4 5
5 3
1 2
1 4
4 5
5 3
1 3
1 4
4 5
5 4
1 2
1 3
1 4
4 5
5 2
1 5
4 5
5 3
1 2
1 5
4 5
5 3
1 3
1 5
4 5
5 4
1 2
1 3
1 5
4 5
5 3
1 4
1 5
4 5
5 4
1 2
1 4
1 5
4 5
5 4
1 3
1 4
1 5
4 5
5 5
1 2
1 3
1 4
1 5
4 5
5 2
2 3
4 5
5 3
1 2
2 3
4 5
5 3
1 3
2 3
...

output:

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

result:

ok Correct

Test #37:

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

input:

256
5 2
3 5
4 5
5 3
1 2
3 5
4 5
5 3
1 3
3 5
4 5
5 4
1 2
1 3
3 5
4 5
5 3
1 4
3 5
4 5
5 4
1 2
1 4
3 5
4 5
5 4
1 3
1 4
3 5
4 5
5 5
1 2
1 3
1 4
3 5
4 5
5 3
1 5
3 5
4 5
5 4
1 2
1 5
3 5
4 5
5 4
1 3
1 5
3 5
4 5
5 5
1 2
1 3
1 5
3 5
4 5
5 4
1 4
1 5
3 5
4 5
5 5
1 2
1 4
1 5
3 5
4 5
5 5
1 3
1 4
1 5
3 5
4 5
5 6
...

output:

2 1 
3 2 1 
3 2 1 
4 3 2 1 
3 2 1 
4 3 2 1 
4 3 2 1 
5 4 3 1 2 
3 2 1 
4 3 2 1 
4 3 2 1 
5 4 3 1 2 
4 3 2 1 
5 4 3 1 2 
-1
-1
3 2 1 
4 3 2 1 
4 3 2 1 
5 4 3 2 1 
4 3 2 1 
5 4 3 2 1 
5 4 3 2 1 
5 4 3 2 1 6 
4 3 2 1 
5 4 3 2 1 
5 4 3 2 1 
-1
5 4 3 2 1 
6 5 3 1 2 4 
-1
-1
3 2 1 
4 3 2 1 
4 3 2 1 
5 4 3...

result:

ok Correct

Test #38:

score: 0
Accepted
time: 94ms
memory: 4176kb

input:

1
4000 3994
2609 1656
3268 840
769 1738
3439 1042
3805 288
1790 1841
2661 3157
3560 2665
3486 2381
725 3579
2621 2158
2246 3697
2923 1728
565 2922
2150 2856
1972 2196
1010 790
3817 2083
1909 3542
2536 2939
141 2051
3293 800
843 706
3267 3007
473 3411
3389 2798
693 599
2647 771
2350 210
2783 2619
359...

output:

2603 2892 3547 2666 1616 2085 2815 1703 1896 1864 3435 3229 3231 2881 3847 2444 3838 3002 2013 3052 3050 2443 2390 2048 3979 2326 2348 1802 1800 2018 3099 3532 3305 2243 3840 3446 2142 2140 3412 1529 1527 1347 2548 2617 2045 2442 3163 3432 3923 3921 3800 2796 2138 1339 2706 1994 3581 1813 3918 3208 ...

result:

ok Correct

Test #39:

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

input:

1
4000 3996
3022 1706
217 798
3846 114
1413 3018
1914 2614
2737 120
1511 998
3898 3588
726 3783
475 1138
2071 46
2287 369
2419 2400
1970 1133
2429 3343
1760 531
2021 388
3907 1515
1114 3687
1840 2881
1136 1398
3946 1314
1171 3958
1575 1610
2533 2909
2745 953
818 1846
3062 1891
3123 3143
2892 3318
37...

output:

-1

result:

ok Correct

Test #40:

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

input:

1
4000 3994
910 3139
3000 219
801 2172
1962 161
2284 653
810 1548
300 852
335 2572
1922 2795
2970 482
423 1596
490 3372
348 2771
2483 558
3454 3931
577 2060
2517 821
3534 1670
2030 848
2581 170
1031 3044
1178 3114
1146 3183
2412 1931
1629 2266
3436 1299
3533 1183
3918 2053
3196 3604
3830 1721
1230 4...

output:

1644 1913 3380 2631 2629 2849 3943 3798 3635 2605 3142 3059 2257 3759 1825 3945 2169 2512 2951 1532 1530 2125 2094 2685 2032 1838 3222 3198 1685 3491 3489 2918 3615 1464 3420 3774 3772 3632 2615 3196 2030 1652 3758 3872 3796 1385 3683 2334 3854 1877 2633 2364 1650 3871 2167 3480 1704 3359 1383 2058 ...

result:

ok Correct

Test #41:

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

input:

1
4000 3996
1307 3803
1514 2254
79 1282
937 1493
1163 1895
2180 1780
2043 3379
2284 1084
2261 1455
3101 3256
2588 3494
910 3568
2539 1793
1013 1443
1647 1030
117 1694
2285 444
2892 2348
3090 2114
3605 338
3574 2922
1926 3831
786 852
1680 1078
3886 1004
3437 3838
2448 1122
350 1681
1726 3717
3610 232...

output:

-1

result:

ok Correct

Test #42:

score: 0
Accepted
time: 78ms
memory: 4140kb

input:

1
4000 3994
1092 3679
2596 1292
1283 2710
627 3944
3067 3817
3512 2530
2271 220
2546 2881
1005 2267
3768 489
2682 2737
847 3134
3276 3719
2750 2087
1789 1395
1839 2956
1103 924
2766 316
1506 818
3634 3050
621 350
1957 1361
2399 528
1964 3573
2810 374
919 900
874 1429
224 952
1931 860
590 700
1409 10...

output:

3307 2154 1870 2974 2152 1550 2627 1340 1571 1573 2873 2818 3634 1548 2633 2789 1621 2279 2794 1712 3915 3581 3413 2247 1931 2573 2912 3687 3410 1792 1744 1521 2740 3443 1552 2778 2448 3788 2301 2299 3470 1959 2211 3731 3089 2245 2611 2171 1829 1821 2792 2452 2450 1823 3694 2442 2549 3637 2267 2484 ...

result:

ok Correct

Test #43:

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

input:

1
4000 3996
133 3956
3856 2401
1161 3631
2436 992
653 2913
940 3748
2096 1276
1293 3978
934 723
3975 15
2357 3454
1832 597
240 3319
3719 843
1808 3229
1019 3178
1742 2306
3161 2356
1867 1565
1897 2317
1465 1695
2602 452
1011 1858
3599 2738
3821 3143
2047 2082
444 3438
960 2619
220 2729
427 1228
1928...

output:

-1

result:

ok Correct

Test #44:

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

input:

1
1805 1711
394 1668
457 489
128 212
799 1388
82 1084
583 1469
1041 1188
710 1402
789 1711
341 453
430 1219
170 557
538 1356
240 661
994 1150
71 626
1301 1647
544 1316
770 1755
307 1296
574 1482
363 1260
128 986
596 1245
452 1020
1249 1619
194 1410
425 887
23 854
1377 1557
793 1359
361 1771
177 1464...

output:

1632 622 160 943 1604 1350 1020 1390 471 1044 385 1086 698 1342 1368 693 1222 1601 383 1607 1221 1141 1234 779 1517 956 958 961 1280 1233 544 940 1698 80 1275 1568 1153 1156 1581 787 911 446 235 1554 1238 875 575 626 654 1426 680 1215 1678 1023 775 1127 1014 669 1269 349 95 163 1167 1616 1545 1198 1...

result:

ok Correct

Test #45:

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

input:

42
17 23
2 8
10 11
1 10
9 17
5 12
1 4
7 13
13 15
8 12
3 6
3 5
1 17
8 11
2 14
8 17
6 13
13 14
7 12
6 15
2 16
10 17
5 15
4 16
19 22
10 16
7 12
9 11
15 17
9 18
11 17
5 17
1 4
7 11
11 14
2 11
14 18
6 15
18 19
6 8
2 19
5 8
13 18
1 18
16 18
1 14
5 6
15 17
8 13
3 13
4 9
1 5
5 15
3 8
7 12
4 7
7 11
5 14
11 1...

output:

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

result:

ok Correct

Test #46:

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

input:

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

output:

15 11 10 9 4 13 12 18 14 1 17 16 5 6 8 7 3 2 
7 1 5 12 16 18 2 3 10 14 8 20 13 9 6 4 15 19 11 17 
19 13 2 5 11 9 16 7 23 17 12 10 25 15 4 1 14 20 24 22 21 3 18 8 6 
18 16 19 12 4 1 10 6 20 8 7 3 5 11 21 17 9 15 13 2 14 
7 10 19 16 13 20 12 1 3 18 17 2 6 14 11 9 5 8 4 15 
19 4 16 8 14 7 5 18 6 10 17 ...

result:

ok Correct

Test #47:

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

input:

15
54 58
31 37
40 44
29 48
19 54
35 36
13 25
5 42
21 41
25 46
5 7
16 50
22 31
14 30
3 7
12 13
2 26
12 25
38 49
19 40
2 27
3 11
11 38
45 46
11 32
39 51
46 48
14 43
40 54
16 45
8 9
18 19
9 41
13 52
21 46
21 50
35 38
30 44
20 35
36 41
19 43
14 50
29 49
27 44
36 45
27 43
23 29
5 48
15 31
33 45
37 38
4 2...

output:

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

result:

ok Correct

Test #48:

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

input:

62
15 17
7 10
4 7
7 9
10 11
3 10
10 15
4 15
3 12
9 13
1 14
6 14
2 14
2 9
1 8
1 13
1 6
11 15
12 15
10 12
8 12
4 10
3 5
4 9
3 7
3 11
6 7
6 11
1 8
4 8
5 11
9 10
2 12
2 6
19 22
14 16
1 17
6 19
6 14
11 15
3 8
13 16
5 14
16 18
9 19
5 9
1 7
1 3
7 17
10 19
2 18
2 5
8 18
11 13
4 8
4 7
16 19
15 19
8 10
9 12
4...

output:

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

result:

ok Correct

Test #49:

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

input:

3
3960 3967
937 3123
2575 3091
263 2767
2233 3478
552 3510
812 3093
721 3160
1830 3890
1854 3310
407 1115
866 1033
1204 3558
1866 2279
1964 2250
2036 2929
1129 3111
1725 1994
378 958
2761 3502
2488 2494
1802 2046
99 2510
2998 3872
366 3221
1726 1936
1659 3352
3568 3579
497 969
2272 3691
2274 3167
55...

output:

1974 2280 3936 1082 630 2416 43 2833 928 1387 3345 3210 65 197 1245 3467 3793 2053 1745 2718 3541 271 3729 2378 1470 569 3843 27 1161 118 49 3365 3653 1960 128 3290 2105 3662 378 1720 2192 942 3227 2904 3493 2657 1661 2828 590 3026 1829 2148 3610 1094 814 2353 2002 1020 618 2857 87 2369 2216 3870 81...

result:

ok Correct

Test #50:

score: 0
Accepted
time: 98ms
memory: 4080kb

input:

4
3955 3943
363 1845
92 111
2718 2963
314 3924
1365 1859
1420 2183
1237 1803
935 2088
2201 3595
383 2157
1936 2467
1318 3215
1375 3931
2621 3099
1532 3716
3188 3696
143 2696
2022 2484
1740 2309
1772 3772
1231 2205
1049 1563
67 2068
2588 3667
1020 2460
961 2113
171 526
965 2881
1019 1212
851 3174
417...

output:

2314 1809 3632 1794 2979 2097 1456 3665 817 904 3030 234 3081 812 2941 2064 1624 2287 1617 88 3886 601 507 3748 1802 3420 144 352 1389 2164 266 1578 2975 2202 1408 578 1541 3038 2972 2411 38 2486 1119 3043 610 1286 278 1780 2458 734 3920 851 243 1231 1491 3431 1581 3092 2025 1366 350 2966 2433 3459 ...

result:

ok Correct

Test #51:

score: 0
Accepted
time: 93ms
memory: 4176kb

input:

2
3989 3960
932 3335
2784 3545
1581 3968
2252 2687
1066 3050
54 1103
1987 3568
921 3151
405 1546
1510 3800
987 2778
1725 3388
605 680
2325 2456
594 3276
539 542
1192 3674
1127 1426
1064 3074
1816 2273
97 3867
742 892
366 1639
809 1385
108 776
358 1409
572 3242
1586 3090
1543 1845
1665 2114
162 2413
...

output:

383 3627 1889 3858 391 816 2109 404 211 70 80 823 2061 2130 123 1496 3079 1366 3912 3901 1876 2154 3949 1501 2443 2895 1887 1028 2952 2289 3785 48 988 3326 3886 1946 1927 1758 2121 3355 1524 1426 1269 2012 3448 2033 2995 3865 515 3618 1903 1572 1511 2519 860 1642 2003 726 3907 207 3175 2002 1081 597...

result:

ok Correct

Test #52:

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

input:

1
3937 3994
2877 3051
771 3317
1788 2832
1167 3673
1409 3682
1417 1965
1466 3052
99 3464
491 592
2914 3230
2090 3824
976 2867
273 1897
1515 2245
951 3578
670 2098
2900 3629
82 1098
1014 1107
2687 3483
605 2523
1653 2240
3545 3558
1727 1970
2887 3037
2756 3177
567 2697
3345 3869
407 2133
493 1519
110...

output:

2970 1283 574 255 363 2673 3806 633 1041 3788 2379 2807 3725 3175 3343 2487 1676 3486 23 3713 323 3948 2209 141 2627 502 3240 1274 3792 3692 2245 3443 974 404 3293 582 2689 2761 3981 549 2641 3892 3631 3528 3779 828 2523 1113 675 1128 3658 1711 1193 1662 966 2986 1102 2632 101 3342 1305 702 3539 689...

result:

ok Correct

Test #53:

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

input:

3
3965 3964
299 1234
3303 3667
3065 3181
570 1699
1835 3939
999 1041
1332 2928
2791 3878
2230 3582
2595 3637
1680 3886
1772 1972
3556 3781
2525 3809
2276 2380
1753 3384
413 2245
556 2652
754 3856
1550 1814
392 1136
692 2314
690 1570
1589 2676
2217 2249
3674 3734
742 1421
377 724
2334 3673
1920 2787
...

output:

3211 2416 290 3030 1950 3555 1720 2557 2208 3751 3930 3625 223 2758 2858 1130 3126 2002 3648 26 1970 3143 1030 2871 2494 2182 2309 1392 1098 1149 593 3793 127 13 3553 3056 337 1132 1133 1492 2176 3537 1156 1773 2408 3523 2109 976 788 3808 1649 1902 303 2770 561 3729 3437 1934 2874 2334 359 1309 1864...

result:

ok Correct

Test #54:

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

input:

53
78 34
7 16
1 21
37 39
37 76
19 52
60 63
2 42
16 34
51 63
9 14
5 37
68 78
12 22
58 62
17 53
39 67
15 16
15 30
37 72
10 18
18 52
35 39
22 64
39 47
21 53
57 70
31 40
29 76
6 51
29 57
31 54
44 73
59 74
10 25
52 17
4 34
21 48
32 51
46 48
22 40
4 18
12 25
1 47
3 48
1 44
33 51
7 49
14 16
14 52
35 36
9 3...

output:

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

result:

ok Correct

Test #55:

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

input:

56
61 87
12 21
3 28
26 52
21 55
28 51
8 30
10 28
7 45
8 42
3 51
9 35
12 44
30 59
8 22
6 38
35 61
20 46
5 61
26 31
1 37
24 38
38 43
13 21
8 9
48 54
8 18
39 47
16 19
2 20
9 41
18 47
4 26
10 55
19 36
1 50
15 41
33 54
26 61
6 61
22 33
36 50
7 53
22 31
9 30
16 18
60 61
12 22
40 61
5 37
18 32
28 31
40 41
...

output:

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

result:

ok Correct

Test #56:

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

input:

57
80 33
2 36
11 30
15 20
20 21
27 75
21 27
70 78
72 80
49 71
19 20
5 24
23 38
37 79
52 76
27 33
21 52
52 80
5 57
5 32
17 59
42 71
35 68
36 57
50 71
1 74
12 77
53 79
3 62
28 75
67 70
68 71
4 69
35 49
86 161
20 21
74 84
52 57
39 50
22 33
21 27
53 74
11 42
62 72
1 65
35 42
46 53
43 84
59 63
5 34
34 39...

output:

8 7 31 30 27 17 14 24 9 21 13 23 33 22 29 15 5 12 16 6 4 10 20 3 26 2 19 18 11 32 28 1 25 
-1
12 7 17 13 15 10 6 5 18 16 2 19 4 3 11 9 8 1 14 
6 12 2 1 8 13 4 11 14 10 15 17 18 9 16 3 5 19 7 
48 18 50 64 7 68 14 4 79 69 13 60 32 74 6 31 38 28 37 17 78 44 27 30 20 8 40 77 19 65 41 53 66 58 34 3 36 71...

result:

ok Correct

Test #57:

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

input:

54
63 18
2 46
15 63
21 53
16 32
14 37
21 27
5 10
53 54
17 51
18 54
51 57
15 60
26 60
31 41
16 26
11 21
20 27
8 47
57 108
36 37
30 35
13 23
29 30
3 27
7 28
44 51
14 38
4 38
28 40
23 52
22 27
20 47
8 23
15 30
53 54
7 42
28 45
9 45
18 34
1 41
2 12
26 31
17 18
1 30
26 43
10 31
2 5
30 39
31 38
42 52
21 4...

output:

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

result:

ok Correct

Test #58:

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

input:

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

output:

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

result:

ok Correct

Test #59:

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

input:

1
72 86
38 44
43 64
8 65
20 49
9 12
5 15
36 69
6 55
16 59
2 48
2 11
33 60
41 67
5 26
25 31
10 44
39 59
6 13
16 71
7 10
20 25
25 54
13 14
15 53
3 17
30 63
38 57
2 44
61 63
54 57
43 62
23 59
6 14
38 47
22 27
61 72
15 65
2 66
54 55
53 64
4 55
35 69
1 66
14 21
33 58
30 50
4 67
22 64
33 62
9 24
5 51
36 5...

output:

36 63 30 65 31 2 13 17 34 27 52 42 86 49 12 67 26 22 32 85 62 48 35 21 4 81 9 24 40 72 37 44 83 23 69 58 16 50 3 59 20 79 33 8 18 56 51 14 41 71 61 25 28 1 84 39 64 38 11 10 74 6 66 45 15 60 68 46 53 47 80 19 54 78 57 77 73 29 82 76 5 7 55 75 70 43 

result:

ok Correct

Test #60:

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

input:

5
17 23
2 8
10 11
1 10
9 17
5 12
1 4
7 13
13 15
8 12
3 6
3 5
1 17
8 11
2 14
8 17
6 13
13 14
7 12
6 15
2 16
10 17
5 15
4 16
19 22
10 16
7 12
9 11
15 17
9 18
11 17
5 17
1 4
7 11
11 14
2 11
14 18
6 15
18 19
6 8
2 19
5 8
13 18
1 18
16 18
1 14
5 6
15 17
8 13
3 13
4 9
1 5
5 15
3 8
7 12
4 7
7 11
5 14
11 12...

output:

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

result:

ok Correct

Test #61:

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

input:

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

output:

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

result:

ok Correct

Test #62:

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

input:

1
54 58
31 37
40 44
29 48
19 54
35 36
13 25
5 42
21 41
25 46
5 7
16 50
22 31
14 30
3 7
12 13
2 26
12 25
38 49
19 40
2 27
3 11
11 38
45 46
11 32
39 51
46 48
14 43
40 54
16 45
8 9
18 19
9 41
13 52
21 46
21 50
35 38
30 44
20 35
36 41
19 43
14 50
29 49
27 44
36 45
27 43
23 29
5 48
15 31
33 45
37 38
4 28...

output:

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

result:

ok Correct

Test #63:

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

input:

1
100 94
49 67
71 72
15 90
29 1
97 81
100 25
5 80
55 63
99 56
9 98
94 32
44 22
73 91
77 58
2 50
46 14
66 12
20 13
70 38
31 93
65 78
16 95
74 11
48 30
86 19
7 41
4 39
60 21
35 52
61 62
10 23
82 92
49 71
67 72
71 15
72 90
15 29
90 1
29 97
1 81
97 100
81 25
100 5
25 80
5 55
80 63
55 99
63 56
99 9
56 98...

output:

41 32 74 72 57 36 34 46 58 50 48 47 90 60 33 79 77 63 55 53 84 70 89 87 52 71 69 39 44 42 94 92 56 54 88 86 67 65 82 80 75 73 37 35 62 68 66 64 78 76 93 91 31 30 29 51 49 81 45 43 85 28 83 27 26 25 24 23 22 21 20 19 18 17 61 16 59 15 14 13 12 11 10 9 8 7 6 40 5 38 4 3 2 1 

result:

ok Correct

Test #64:

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

input:

1
100 96
50 96
7 47
83 28
81 9
20 54
70 36
73 17
78 52
85 65
40 71
49 37
19 6
91 63
38 72
41 33
25 24
88 1
74 56
84 8
26 97
82 23
13 69
48 2
16 32
93 64
100 5
62 44
87 31
4 61
27 75
94 67
60 76
50 7
96 47
7 83
47 28
83 81
28 9
81 20
9 54
20 70
54 36
70 73
36 17
73 78
17 52
78 85
52 65
85 40
65 71
40...

output:

-1

result:

ok Correct

Test #65:

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

input:

1
100 94
26 70
86 8
82 42
94 3
79 98
55 45
25 99
2 71
12 47
22 48
13 76
75 17
46 80
57 96
65 9
41 74
28 38
6 63
88 83
43 72
51 53
14 90
40 4
69 36
5 85
19 77
87 60
29 93
58 31
50 66
78 44
30 49
26 86
70 8
86 82
8 42
82 94
42 3
94 79
3 98
79 55
98 45
55 25
45 99
25 2
99 71
2 12
71 47
12 22
47 48
22 1...

output:

37 35 58 39 82 70 46 68 86 84 59 41 74 72 91 89 30 52 50 48 57 55 44 42 94 92 71 69 61 77 66 64 80 90 88 93 31 32 87 29 85 28 63 33 43 83 27 56 54 75 73 53 51 49 62 60 36 34 67 65 81 26 79 25 78 24 76 23 22 21 20 19 18 17 16 15 14 13 12 11 10 40 38 47 9 45 8 7 6 5 4 3 2 1 

result:

ok Correct

Test #66:

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

input:

1
100 96
48 24
77 1
97 80
36 90
68 11
98 76
30 51
40 7
85 70
28 4
54 42
96 3
39 18
83 93
66 56
64 75
2 63
31 55
23 61
33 99
26 50
52 58
15 47
8 32
65 62
34 92
82 100
22 67
27 5
78 95
53 81
87 14
48 77
24 1
77 97
1 80
97 36
80 90
36 68
90 11
68 98
11 76
98 30
76 51
30 40
51 7
40 85
7 70
85 28
70 4
28...

output:

-1

result:

ok Correct

Test #67:

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

input:

1
100 94
26 7
53 92
36 61
33 29
67 34
39 42
47 68
10 1
27 73
20 57
13 2
66 90
46 63
96 76
40 74
95 64
54 44
28 8
85 31
59 4
60 5
11 79
45 25
51 3
86 52
48 43
78 91
55 62
37 21
94 22
14 16
30 97
26 53
7 92
53 36
92 61
36 33
61 29
33 67
29 34
67 39
34 42
39 47
42 68
47 10
68 1
10 27
1 73
27 20
73 57
2...

output:

60 62 58 56 86 36 71 69 50 85 63 79 83 81 57 55 77 64 84 82 44 61 59 43 41 89 87 35 42 39 37 32 40 38 67 65 33 76 90 88 49 94 92 93 91 31 30 29 28 27 26 53 51 75 73 47 45 68 66 34 74 72 70 80 25 78 24 23 22 21 20 19 18 17 16 15 14 13 54 12 52 11 10 48 9 46 8 7 6 5 4 3 2 1 

result:

ok Correct

Test #68:

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

input:

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

output:

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

result:

ok Correct

Test #69:

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

input:

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

output:

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

result:

ok Correct

Test #70:

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

input:

4
78 47
29 39
52 74
5 70
50 78
35 50
43 65
32 43
49 66
44 52
22 57
38 60
32 57
43 52
24 55
39 51
20 64
62 66
22 43
42 61
36 41
57 71
64 67
20 72
7 16
63 65
22 65
5 73
60 62
4 11
33 39
21 74
19 71
10 49
25 27
37 43
43 51
7 26
25 49
3 6
25 39
42 64
34 64
36 76
10 39
35 43
25 26
34 50
2 1
1 2
15 11
13 ...

output:

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

result:

ok Correct

Test #71:

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

input:

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

output:

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

result:

ok Correct

Test #72:

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

input:

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

output:

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

result:

ok Correct

Test #73:

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

input:

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

output:

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

result:

ok Correct

Test #74:

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

input:

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

output:

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

result:

ok Correct

Test #75:

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

input:

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

output:

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

result:

ok Correct

Test #76:

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

input:

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

output:

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

result:

ok Correct

Test #77:

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

input:

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

output:

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

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed