QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#857381#9875. Don't Detect Cyclehos_lyricAC ✓1944ms5188kbC++146.9kb2025-01-15 16:49:292025-01-15 16:49:29

Judging History

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

  • [2025-01-15 16:49:29]
  • 评测
  • 测评结果:AC
  • 用时:1944ms
  • 内存:5188kb
  • [2025-01-15 16:49:29]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")



// gg: bipartite graph between {vertex} and {biconnected component}
//   (|gg| - n) biconnected components
//   isolated point: not regarded as biconnected component (==> isolated in gg)
// f: DFS out-forest
// ess: edges in biconnected component
//   (u, v) with dis[u] <= dis[v]
//   self-loop at isolated point: not included in ess
struct Biconnected {
  int n, m;
  vector<vector<int>> g, f, gg;
  vector<vector<pair<int, int>>> ess;
  vector<int> par, rs;
  int zeit;
  vector<int> dis, fin, low;

  Biconnected() {}
  explicit Biconnected(int n_) : n(n_), m(0), g(n_) {}
  void ae(int u, int v) {
    ++m;
    assert(0 <= u); assert(u < n);
    assert(0 <= v); assert(v < n);
    g[u].push_back(v);
    if (u != v) g[v].push_back(u);
  }

  int stackVLen, stackELen;
  vector<int> stackV;
  vector<pair<int, int>> stackE;
  vector<int> cntPar;
  void dfs(int u) {
    stackV[stackVLen++] = u;
    dis[u] = low[u] = zeit++;
    for (const int v : g[u]) {
      if (par[u] == v && !cntPar[u]++) continue;
      if (~dis[v]) {
        if (dis[u] >= dis[v]) stackE[stackELen++] = std::make_pair(v, u);
        if (low[u] > dis[v]) low[u] = dis[v];
      } else {
        // f[u].push_back(v);
        par[v] = u;
        rs[v] = rs[u];
        const int stackEPos = stackELen;
        stackE[stackELen++] = std::make_pair(u, v);
        dfs(v);
        if (low[u] > low[v]) low[u] = low[v];
        if (dis[u] <= low[v]) {
          const int x = gg.size();
          gg.emplace_back();
          ess.emplace_back();
          for (; ; ) {
            const int w = stackV[--stackVLen];
            gg[w].push_back(x);
            gg[x].push_back(w);
            if (w == v) break;
          }
          gg[u].push_back(x);
          gg[x].push_back(u);
          for (; stackELen > stackEPos; ) ess[x].push_back(stackE[--stackELen]);
        }
      }
    }
    fin[u] = zeit;
  }
  void build() {
    // f.assign(n, {});
    gg.assign(n, {});
    ess.assign(n, {});
    par.assign(n, -1);
    rs.assign(n, -1);
    zeit = 0;
    dis.assign(n, -1);
    fin.assign(n, -1);
    low.assign(n, -1);
    stackV.resize(n);
    stackE.resize(m);
    cntPar.assign(n, 0);
    for (int u = 0; u < n; ++u) if (!~dis[u]) {
      stackVLen = stackELen = 0;
      rs[u] = u;
      dfs(u);
    }
  }

  // Returns true iff u is an articulation point
  //   <=> # of connected components increases when u is removed.
  inline bool isArt(int u) const {
    return (gg[u].size() >= 2);
  }

  // Returns w s.t. w is a child of u and a descendant of v in the DFS forest.
  // Returns -1 instead if v is not a proper descendant of u
  //   O(log(deg(u))) time
  int dive(int u, int v) const {
    if (dis[u] < dis[v] && dis[v] < fin[u]) {
      int j0 = 0, j1 = f[u].size();
      for (; j0 + 1 < j1; ) {
        const int j = (j0 + j1) / 2;
        ((dis[f[u][j]] <= dis[v]) ? j0 : j1) = j;
      }
      return f[u][j0];
    } else {
      return -1;
    }
  }
  // Returns true iff there exists a v-w path when u is removed.
  //   O(log(deg(u))) time
  bool isStillReachable(int u, int v, int w) const {
    assert(0 <= u); assert(u < n);
    assert(0 <= v); assert(v < n);
    assert(0 <= w); assert(w < n);
    assert(u != v);
    assert(u != w);
    if (rs[v] != rs[w]) return false;
    if (rs[u] != rs[v]) return true;
    const int vv = dive(u, v);
    const int ww = dive(u, w);
    if (~vv) {
      if (~ww) {
        return (vv == ww || (dis[u] > low[vv] && dis[u] > low[ww]));
      } else {
        return (dis[u] > low[vv]);
      }
    } else {
      if (~ww) {
        return (dis[u] > low[ww]);
      } else {
        return true;
      }
    }
  }
};

////////////////////////////////////////////////////////////////////////////////


int N, M;
vector<int> A, B;

bool solve() {
  vector<int> ans(M, -1);
  vector<int> del(M, 0);
  for (int h = M; --h >= 0; ) {
    Biconnected bi(N);
    for (int i = 0; i < M; ++i) if (!del[i]) bi.ae(A[i], B[i]);
    bi.build();
    // adj. biconn. comp. with cycle
    vector<int> xs(N, -1);
    for (int u = 0; u < N; ++u) {
      for (const int x : bi.gg[u]) if (bi.ess[x].size() >= 2) {
        xs[u] = (~xs[u]) ? -2 : x;
      }
    }
// cerr<<"gg = "<<bi.gg<<", xs = "<<xs<<endl;
    pair<int, int> em(-1, -1);
    vector<int> deg(N, 0);
    for (int x = N; x < (int)bi.gg.size(); ++x) {
      for (const auto &e : bi.ess[x]) {
        ++deg[e.first];
        ++deg[e.second];
      }
      auto check = [&](int u) -> bool {
        if (~xs[u] && xs[u] != x) return false;
        if (deg[u] >= 3) return false;
        return true;
      };
      for (const auto &e : bi.ess[x]) {
        if (check(e.first) && check(e.second)) {
          em = e;
          break;
        }
      }
      for (const auto &e : bi.ess[x]) {
        --deg[e.first];
        --deg[e.second];
      }
      if (~em.first) break;
    }
    for (int i = 0; i < M; ++i) if (!del[i]) {
      if (em == make_pair(A[i], B[i]) || em == make_pair(B[i], A[i])) {
        ans[h] = i;
        del[i] = 1;
        goto found;
      }
    }
    return false;
   found:{}
  }
  for (int h = 0; h < M; ++h) {
    if (h) printf(" ");
    printf("%d", ans[h] + 1);
  }
  puts("");
  return true;
}

int main() {
  for (int numCases; ~scanf("%d", &numCases); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
    scanf("%d%d", &N, &M);
    A.resize(M);
    B.resize(M);
    for (int i = 0; i < M; ++i) {
      scanf("%d%d", &A[i], &B[i]);
      --A[i];
      --B[i];
    }
    
    if (!solve()) {
      puts("-1");
    }
  }
#ifndef LOCAL
  break;
#endif
  }
  return 0;
}

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

詳細信息

Test #1:

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

input:

1
4 4
1 2
2 3
3 4
4 2

output:

1 2 3 4

result:

ok Correct

Test #2:

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

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

result:

ok Correct

Test #3:

score: 0
Accepted
time: 1060ms
memory: 4568kb

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:

1852 765 575 358 759 2677 1367 2593 1273 1324 579 149 1602 2409 723 2130 349 1058 312 920 418 2226 1580 166 2352 1565 1688 707 2882 2883 2814 2361 633 2722 1184 194 2204 1841 2050 1555 278 1677 2161 521 1232 1344 610 1374 1097 2322 42 2305 2198 919 486 519 1671 2840 2162 1819 629 360 1279 2822 744 1...

result:

ok Correct

Test #4:

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

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:

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

result:

ok Correct

Test #5:

score: 0
Accepted
time: 921ms
memory: 4528kb

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:

1896 1083 811 501 1157 1198 184 557 1834 2206 1285 235 1128 1169 367 1859 957 720 1762 1670 12 658 1269 1150 1428 55 479 384 623 497 285 1242 66 1232 1580 1663 1207 198 1525 840 2002 642 835 2250 560 209 130 941 83 1307 1039 1863 1024 717 211 1007 241 1484 1987 378 425 761 1743 1467 1245 1975 773 15...

result:

ok Correct

Test #6:

score: 0
Accepted
time: 433ms
memory: 4464kb

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:

434 651 348 1495 1725 286 1352 635 1767 704 812 864 1566 1030 537 589 454 543 1115 244 834 217 800 1021 1363 1676 909 352 706 784 87 912 1260 934 1405 1458 1004 25 1752 1007 433 485 1527 122 1463 504 1335 528 322 1491 1155 257 928 877 983 1576 878 182 1438 620 180 817 1547 1263 576 1099 985 600 970 ...

result:

ok Correct

Test #7:

score: 0
Accepted
time: 238ms
memory: 4288kb

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

result:

ok Correct

Test #8:

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

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

result:

ok Correct

Test #9:

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

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

result:

ok Correct

Test #10:

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

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

result:

ok Correct

Test #11:

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

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

result:

ok Correct

Test #12:

score: 0
Accepted
time: 1944ms
memory: 4732kb

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:

3400 464 3389 82 3960 3232 2404 1320 466 108 3380 3069 2314 3514 2258 2484 3311 3003 2542 776 1673 295 2551 1552 3704 2719 2230 2238 3145 1756 724 579 1761 330 2397 1185 2622 1210 2618 2453 2987 2829 3269 267 1736 2649 2395 3505 1752 2431 1332 3362 652 3501 1455 3940 3492 3364 3049 3437 1493 211 319...

result:

ok Correct

Test #13:

score: 0
Accepted
time: 1904ms
memory: 4752kb

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:

3232 3467 2668 253 1810 3923 2276 1317 3336 1728 786 3605 2743 796 3259 313 1396 2314 2913 1946 424 3469 2932 3126 3725 3102 2999 1809 2918 2301 3002 751 1573 665 723 3858 673 1841 843 3117 3562 1484 2312 2292 1756 2517 880 3563 358 3962 2965 3217 3827 2366 3834 1250 2704 1057 2105 524 3867 991 1160...

result:

ok Correct

Test #14:

score: 0
Accepted
time: 1885ms
memory: 4972kb

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:

3529 1722 1260 1262 1391 424 3774 1618 2959 2626 1573 1356 1017 3754 1323 2262 3123 941 3620 409 2067 1975 3535 3748 1120 1596 927 3328 3295 36 3893 2217 3185 1478 2462 3548 3247 2663 1901 2359 1327 808 1739 1744 3855 3293 3933 3445 1168 763 1649 1027 3607 2307 45 220 1757 3696 2380 3432 1892 758 12...

result:

ok Correct

Test #15:

score: 0
Accepted
time: 1884ms
memory: 4860kb

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:

1340 607 2467 382 586 2176 2719 3793 2746 1072 1679 3605 2129 3447 819 3243 24 371 3756 478 2204 2956 3671 3040 3813 2159 3540 982 5 2942 2002 3558 1288 803 2328 2075 3123 2850 3971 1831 2171 650 2037 2764 1787 460 695 762 3278 1064 1308 415 3625 2918 2991 2936 1849 1739 3687 2167 866 1263 525 502 2...

result:

ok Correct

Test #16:

score: 0
Accepted
time: 1915ms
memory: 5024kb

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:

1200 2059 1125 2954 875 1461 2127 2983 1152 2321 1704 1881 1669 180 803 1743 2135 3058 2104 3592 1177 1278 868 2363 1405 3961 3536 324 1995 2979 3239 2487 372 2 3977 2862 1812 1300 601 1839 2685 2172 1749 3589 3953 2467 1448 997 3027 1304 3600 83 2549 1929 812 2776 3641 1828 2864 2722 3873 3605 293 ...

result:

ok Correct

Test #17:

score: 0
Accepted
time: 1902ms
memory: 4856kb

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:

2541 1430 2093 1117 1708 548 1881 886 2185 3278 3071 1649 441 83 1041 3143 2430 1978 1315 3033 3474 2162 3701 2583 3555 2183 623 2111 1317 2805 2240 186 190 1047 1662 1702 1416 475 1499 3510 3481 2625 3061 1156 843 3607 2130 383 1397 3732 877 1085 3983 3498 1914 1170 2108 842 3872 2273 3999 3318 925...

result:

ok Correct

Test #18:

score: 0
Accepted
time: 1930ms
memory: 4808kb

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:

3201 2169 1732 726 751 142 2712 1950 3217 1884 1111 720 272 2849 1144 3673 2556 1006 115 1473 1946 2831 2770 1477 610 3847 2514 513 3744 2266 258 288 1587 189 593 28 2915 3063 1860 3585 435 3670 1143 1757 1858 2966 479 229 994 1314 1842 437 604 3418 1212 208 823 1579 2219 1231 3806 315 2035 2774 173...

result:

ok Correct

Test #19:

score: 0
Accepted
time: 1917ms
memory: 4748kb

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:

2528 353 3945 2938 3646 2206 25 1264 276 477 2120 2223 1008 2632 3180 91 3381 3293 1317 2628 351 1814 1958 846 2297 3949 3695 428 2123 804 2960 2816 1173 538 1783 1234 57 1037 2203 1505 2266 1898 3446 1653 2517 3069 1886 1284 1298 930 2719 399 307 2717 3834 1347 2376 1022 1672 1244 3074 3857 2289 13...

result:

ok Correct

Test #20:

score: 0
Accepted
time: 1909ms
memory: 4772kb

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:

744 2280 3680 3992 596 3066 1021 1972 3257 133 3512 2312 3402 2713 3487 2264 3899 3345 2873 3730 3424 2294 3594 2611 309 2586 1046 2200 3051 3701 509 3821 2821 1523 3796 2593 440 1679 5 741 2201 1564 3645 1510 1910 982 2095 1440 937 2083 991 656 1875 1573 1372 1107 3089 1147 1996 824 1267 2720 1290 ...

result:

ok Correct

Test #21:

score: 0
Accepted
time: 1916ms
memory: 4776kb

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:

955 1470 2023 748 2191 710 3592 3020 1570 2528 1377 3431 2774 1245 485 2681 2008 881 2359 885 868 151 931 1489 149 3843 19 1848 2226 1314 385 522 3859 2560 1734 2276 2958 1636 1471 643 1284 1468 663 632 1930 3942 498 2027 1391 44 2088 3476 3157 3260 3041 3143 2788 1759 1104 3363 1711 1659 3653 1727 ...

result:

ok Correct

Test #22:

score: 0
Accepted
time: 1919ms
memory: 4992kb

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:

1362 2379 3903 1464 3386 2034 457 92 2326 2873 3135 1443 2872 723 3723 2567 1826 3781 3932 2930 2112 3886 3806 2427 1862 3681 849 2405 3551 2336 1855 100 1257 1677 1290 2975 3651 1055 3046 361 3951 215 3451 2248 11 790 782 3380 3956 3961 1958 3748 3872 2976 3118 3019 555 83 2062 869 898 2243 3449 13...

result:

ok Correct

Test #23:

score: 0
Accepted
time: 1925ms
memory: 4828kb

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 2635 2585 425 585 2052 992 3819 2899 1965 1131 1372 1299 568 2967 3792 3030 1534 944 1604 1668 2517 1181 547 3371 207 243 1355 7 2738 2195 3509 322 3402 3794 2755 2693 1524 3213 3853 3217 123 1544 508 902 1664 2853 388 377 1837 1469 1378 765 698 1855 98 886 668 3132 3341 2895 1304 2275 3161 117...

result:

ok Correct

Test #24:

score: 0
Accepted
time: 1937ms
memory: 4800kb

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:

3502 223 163 2496 1883 283 1753 2260 827 1798 654 3529 3205 3042 1702 2502 771 3721 3719 2482 256 1360 108 3418 2359 1032 840 2986 1022 2923 2785 3027 1509 3868 2115 2687 3391 1064 1042 1722 531 3924 1515 104 1122 3527 752 2897 1768 373 3941 1260 3462 2525 2412 3171 3088 1403 2791 569 1730 3154 457 ...

result:

ok Correct

Test #25:

score: 0
Accepted
time: 1934ms
memory: 4904kb

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:

2991 1453 1690 2280 1100 410 2273 3983 2523 917 3036 3162 1284 1196 3035 1301 3730 3064 3529 2289 2530 3844 1091 223 1149 2424 1258 2888 2225 3033 3323 1946 1374 79 760 3154 3152 3780 2185 2648 1152 1801 968 3299 1471 830 1257 568 3105 89 2968 192 3505 242 1417 3052 1199 1083 69 2738 640 2318 3804 3...

result:

ok Correct

Test #26:

score: 0
Accepted
time: 1871ms
memory: 5188kb

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:

2083 567 972 490 3480 1625 344 1761 1589 3226 1290 1584 465 1219 1356 753 80 2176 1248 330 3108 1994 1858 2952 2390 3944 2523 2908 27 1155 3557 3943 2544 2370 602 931 2773 3751 3167 291 3436 3668 3933 1995 72 3450 48 3946 3051 979 637 374 1968 2104 2072 2412 1246 2333 257 1758 2399 1603 2431 2786 64...

result:

ok Correct

Test #27:

score: 0
Accepted
time: 1905ms
memory: 4956kb

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:

3397 238 1958 389 1446 3033 3663 2236 1980 3245 2138 3348 795 2756 2929 2519 3485 2141 1084 2224 1310 2978 3899 3457 3914 3100 3572 2303 61 2126 3605 1754 3466 2871 3907 2774 2675 1205 807 702 1707 3910 3591 2344 1593 161 1071 3116 221 2481 2995 857 1413 942 1154 2888 1201 3 1049 2231 2008 2536 2095...

result:

ok Correct

Test #28:

score: 0
Accepted
time: 1917ms
memory: 4896kb

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:

2620 3090 2470 3253 1807 446 41 1228 2255 2897 2017 3773 499 1017 185 1915 3 525 2204 1692 575 1565 2166 3066 1985 3230 464 2015 2136 2960 1619 2257 1074 3971 633 3634 2810 1148 1511 2523 490 2752 2020 3924 303 762 184 3292 1720 2284 3123 1113 2290 1559 934 226 1378 684 3740 3946 385 1650 2509 2573 ...

result:

ok Correct

Test #29:

score: 0
Accepted
time: 1918ms
memory: 4820kb

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:

3459 601 138 3236 3741 2985 1056 2887 309 94 2747 2321 548 1764 1196 3081 1693 2003 2656 2007 3134 1171 2 1249 787 1579 872 3877 863 2783 658 31 1219 531 2341 2844 3276 2948 3458 3602 7 889 3817 533 1493 1214 385 3598 54 3491 3212 2255 540 2173 1209 1427 835 731 3422 3991 2994 2046 2523 3353 144 111...

result:

ok Correct

Test #30:

score: 0
Accepted
time: 1892ms
memory: 4764kb

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:

1891 2806 3061 3831 124 2670 3556 144 2607 2171 1706 2860 1158 652 903 3311 1726 125 3020 1263 3214 208 1844 389 1151 1820 3860 1987 1966 3365 3019 2907 1870 358 1606 979 644 3590 2800 3153 3737 960 955 3738 959 544 1879 1490 695 997 2742 3229 3929 1850 3054 2221 800 1135 2407 3131 261 3665 1189 813...

result:

ok Correct

Test #31:

score: 0
Accepted
time: 1920ms
memory: 4916kb

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:

3624 2478 1078 1364 1754 3308 3177 3048 1023 755 1338 2310 2619 618 2017 673 801 2654 2562 1655 843 175 3705 3201 3326 3155 1614 2403 917 500 2576 3986 3790 3085 2461 2384 3273 188 1850 3208 680 1982 1707 3051 3604 3744 535 3005 1353 1817 155 1615 1182 849 2335 3513 1243 1822 2225 402 1670 1005 3516...

result:

ok Correct

Test #32:

score: 0
Accepted
time: 1904ms
memory: 4728kb

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:

2461 2312 542 675 3881 1836 2418 9 2049 1159 3617 1938 202 1897 44 3533 921 2084 610 3281 2178 2960 803 3937 3716 1211 2127 1366 644 2833 845 1440 3370 2522 713 2955 138 3656 3729 3725 860 493 3151 1115 3145 1980 3386 2417 2277 902 1037 432 1219 1388 557 3138 2295 2618 3908 3427 2874 309 122 641 343...

result:

ok Correct

Test #33:

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

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
1 2
1 2
1 3 2
1
1
2 1
1
2 1
2 1
3 2 1
1
1 2
1 2
1 3 2
2 1
2 1 3
2 1 3
3 1 4 2
1
1 2
2 1
2 1 3
1 2
1 3 2
2 3 1
2 1 4 3
2 1
1 3 2
1 2 3
1 4 3 2
1 3 2
1 4 3 2
1 3 4 2
-1
1
2 1
1 2
2 3 1
1 2
2 3 1
1 3 2
2 4 1 3
1 2
1 2 3
1 3 2
1 3 4 2
1 3 2
1 3 4 2
1 4 3 2
-1
1 2
1 2 3
1 3 2
1 3 4 2
1 3 2
1 ...

result:

ok Correct

Test #34:

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

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
1 2
1 2
1 3 2
2 1
2 1 3
2 1 3
3 1 4 2
2 1
2 1 3
2 1 3
3 1 4 2
3 2 1
3 2 1 4
3 2 1 4
4 3 1 5 2
1
1 2
2 1
2 1 3
1 2
1 3 2
2 3 1
2 1 4 3
2 1
2 1 3
3 2 1
3 2 1 4
2 1 3
3 1 4 2
3 2 4 1
4 2 1 5 3
2 1
1 3 2
1 2 3
1 4 3 2
1 3 2
1 4 3 2
1 3 4 ...

result:

ok Correct

Test #35:

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

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
1 2
2 3 1
2 1
3 2 1
2 1 3
3 2 4 1
1 2
2 3 1
1 3 2
2 4 1 3
2 3 1
3 4 2 1
2 1 4 3
3 2 5 1 4
1 2
1 2 3
1 3 2
1 3 4 2
2 3 1
2 1 3 4
2 1 4 3
3 1 4 5 2
1 3 2
1 3 4 2
1 4 3 2
-1
2 4 3 1
2 1 4 5 3
2 1 5 4 3
-1
2 1
3 1 2
2 1 3
2 4 1 3
3 1 2
4 1 3 2
2 3 1 4
2 5 1 4 3
2 1 3
2 4 1 3
3 1 4 2
2 5 1 3 4
2 4 ...

result:

ok Correct

Test #36:

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

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
1 2
2 3 1
2 3 1
3 4 2 1
1 2
2 3 1
2 3 1
3 4 2 1
1 3 2
2 4 1 3
2 4 1 3
3 5 2 1 4
2 1
3 1 2
3 1 2
4 1 3 2
2 1 3
2 4 1 3
2 4 1 3
3 5 1 4 2
2 1 3
2 4 1 3
2 4 1 3
3 5 1 4 2
3 1 4 2
2 5 1 3 4
2 5 1 3 4
3 6 2 1 4 5
1 2
1 2 3
2 3 1
2 1 3 4
1 3 2
1 3 4 2
2 4 3 1
2 1 4 5 3
1 3 2
1 3 4 2
2 4 3 ...

result:

ok Correct

Test #37:

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

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:

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

result:

ok Correct

Test #38:

score: 0
Accepted
time: 1120ms
memory: 4716kb

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:

3236 3238 952 3235 3233 3231 951 3232 3234 3229 3230 950 3228 3227 949 3225 3226 948 3224 3223 947 3221 3222 946 3220 3219 945 3217 3218 944 3216 3215 943 3213 3214 942 3212 3211 941 3209 3210 940 3208 3207 939 3205 3206 938 3204 3203 937 3201 3202 936 3200 3199 935 3197 3198 934 3196 3195 933 3193 ...

result:

ok Correct

Test #39:

score: 0
Accepted
time: 1135ms
memory: 4764kb

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: 1124ms
memory: 4676kb

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:

3178 3180 923 3177 3175 3173 922 3174 3176 3171 3172 921 3170 3169 920 3167 3168 919 3166 3165 918 3163 3164 917 3162 3161 916 3159 3160 915 3158 3157 914 3155 3156 913 3154 3153 912 3151 3152 911 3150 3149 910 3147 3148 909 3146 3145 908 3143 3144 907 3142 3141 906 3139 3140 905 3138 3137 904 3135 ...

result:

ok Correct

Test #41:

score: 0
Accepted
time: 1176ms
memory: 4868kb

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: 1400ms
memory: 4668kb

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:

2238 2240 453 2237 2235 2233 452 2234 2236 2231 2232 451 2230 2229 450 2227 2228 449 2226 2225 448 2223 2224 447 2222 2221 446 2219 2220 445 2218 2217 444 2215 2216 443 2214 2213 442 2211 2212 441 2210 2209 440 2207 2208 439 2206 2205 438 2203 2204 437 2202 2201 436 2199 2200 435 2198 2197 434 2195 ...

result:

ok Correct

Test #43:

score: 0
Accepted
time: 1286ms
memory: 4676kb

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: 343ms
memory: 4440kb

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:

1698 299 1203 401 569 1567 754 1491 777 1534 58 882 297 732 384 1127 1384 1638 438 1262 116 1680 1588 362 888 931 912 24 1193 197 725 18 794 209 1033 638 1209 782 1520 734 134 832 350 400 1412 1587 540 583 174 56 538 208 1609 599 862 983 318 1006 1650 784 1572 787 1450 329 1320 1345 1220 48 14 595 1...

result:

ok Correct

Test #45:

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

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:

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

result:

ok Correct

Test #46:

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

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:

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

result:

ok Correct

Test #47:

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

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:

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

result:

ok Correct

Test #48:

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

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:

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

result:

ok Correct

Test #49:

score: 0
Accepted
time: 1874ms
memory: 4820kb

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:

1720 2391 3382 1607 1546 2857 2292 2096 515 3243 134 888 2996 2844 175 3233 426 132 585 3647 188 2250 2731 4 3322 2719 1237 664 2741 757 2917 1340 1217 3724 150 1019 136 3496 566 3711 3589 2974 503 3086 2898 1826 3176 1288 1687 2484 1375 1868 2847 3524 1491 751 2839 2135 3707 1037 2906 2001 211 1280...

result:

ok Correct

Test #50:

score: 0
Accepted
time: 1850ms
memory: 4884kb

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:

2975 2966 237 3512 1602 1710 3371 453 3473 3793 1981 1643 1701 3936 2401 2115 1464 408 3322 3161 1994 1807 998 65 1997 1476 1952 435 3656 407 1355 3112 2480 3884 1714 2231 1194 2374 3687 718 865 835 1669 647 3160 1394 3788 2669 2306 2597 1866 3889 3632 1459 482 1816 2451 2468 2156 968 978 3470 1913 ...

result:

ok Correct

Test #51:

score: 0
Accepted
time: 1859ms
memory: 5140kb

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:

1496 2443 1028 1642 2519 1100 3313 1883 426 647 1220 202 2289 2491 3611 818 3640 3069 1501 2386 1964 763 3734 1480 1772 3881 1244 753 2067 3509 1292 3781 2889 805 3414 1384 3799 3572 2334 961 904 1131 3305 3015 1475 2421 1810 1896 801 132 688 437 1271 3639 617 2468 3850 3388 2788 3608 2607 1830 1004...

result:

ok Correct

Test #52:

score: 0
Accepted
time: 1905ms
memory: 4868kb

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:

3343 582 359 2957 1706 3296 1730 1792 2689 2315 1676 3064 436 1679 578 247 3195 3812 2202 1757 2616 1654 1256 2066 1143 3346 2926 1003 3488 441 2416 3170 175 2023 2005 3349 3201 311 313 1778 2698 2635 1452 511 3402 741 680 3166 289 1169 1026 2237 1470 189 3101 1518 3871 1319 3369 1794 1556 645 1712 ...

result:

ok Correct

Test #53:

score: 0
Accepted
time: 1872ms
memory: 4908kb

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:

485 3127 3160 2633 3466 693 1398 3462 2558 1774 848 361 1064 688 3762 1390 2890 2740 3639 1913 1652 265 192 3545 2188 2747 583 2858 700 2825 497 2682 2965 2780 2562 3103 2898 3933 980 2609 1606 1963 1741 250 1378 3100 2390 2423 1993 3687 3861 897 531 2298 289 1354 442 2275 1362 3454 2606 2417 3494 2...

result:

ok Correct

Test #54:

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

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

result:

ok Correct

Test #55:

score: 0
Accepted
time: 11ms
memory: 3968kb

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

result:

ok Correct

Test #56:

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

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:

30 7 13 27 22 31 24 21 9 33 12 20 3 10 4 16 17 8 14 6 15 5 29 26 2 32 28 1 23 18 19 11 25
-1
12 7 17 13 6 2 3 9 8 4 19 18 10 15 11 5 1 14 16
6 1 13 4 18 9 16 17 3 8 11 5 14 10 2 12 15 19 7
18 43 54 47 72 21 38 28 1 67 52 10 58 50 32 7 64 40 51 57 26 15 78 29 56 30 20 8 35 44 27 70 23 42 34 22 19 41 ...

result:

ok Correct

Test #57:

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

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:

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

result:

ok Correct

Test #58:

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

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:

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

result:

ok Correct

Test #59:

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

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:

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

result:

ok Correct

Test #60:

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

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:

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

result:

ok Correct

Test #61:

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

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:

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

result:

ok Correct

Test #62:

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

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:

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

result:

ok Correct

Test #63:

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

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:

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

result:

ok Correct

Test #64:

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

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: 1ms
memory: 3840kb

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:

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

result:

ok Correct

Test #66:

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

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: 1ms
memory: 3968kb

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:

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

result:

ok Correct

Test #68:

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

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

result:

ok Correct

Test #69:

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

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 5 1 8 4 7 6 2
16 10 5 15 2 12 11 9 4 1 7 14 18 6 3 17 8 13
-1
1
1
1
1 3 4 2

result:

ok Correct

Test #70:

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

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:

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

result:

ok Correct

Test #71:

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

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:

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

result:

ok Correct

Test #72:

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

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

result:

ok Correct

Test #73:

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

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

result:

ok Correct

Test #74:

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

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
16 7 11 12 17 4 1 3 18 22 5 19 15 14 10 13 9 2 20 8 6 21
7 9 4 3 13 10 8 12 2 15 14 16 17 11 1 18 5 6

result:

ok Correct

Test #75:

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

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

result:

ok Correct

Test #76:

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

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 4 1 2 5
10 8 1 5 7 11 3 6 4 9 2
2 3 4 5 1
7 9 4 3 13 10 8 12 2 15 14 16 17 11 1 18 5 6

result:

ok Correct

Test #77:

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

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
1 3 2
7 9 4 3 13 10 8 12 2 15 14 16 17 11 1 18 5 6

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed