QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#818396#9875. Don't Detect Cycleucup-team5243AC ✓388ms4960kbC++2313.6kb2024-12-17 19:48:132024-12-17 19:48:15

Judging History

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

  • [2024-12-17 19:48:15]
  • 评测
  • 测评结果:AC
  • 用时:388ms
  • 内存:4960kb
  • [2024-12-17 19:48:13]
  • 提交

answer

//line 1 "answer.cpp"
#if !__INCLUDE_LEVEL__
#include __FILE__
// https://algo-logic.info/bridge-lowlink
struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;
using P = pair<long long, long long>;
/* Lowlink: グラフの関節点・橋を列挙する構造体
    作成: O(E+V)
    関節点の集合: vector<int> aps
    橋の集合: vector<P> bridges
*/
struct LowLink {
    const Graph &G;
    vector<int> used, ord, low;
    vector<int> aps;  // articulation points
    vector<P> bridges;
    LowLink(const Graph &G_) : G(G_) {
        used.assign(G.size(), 0);
        ord.assign(G.size(), 0);
        low.assign(G.size(), 0);
        int k = 0;
        for (int i = 0; i < (int)G.size(); i++) {
            if (!used[i]) k = dfs(i, k, -1);
        }
        sort(aps.begin(), aps.end()); // 必要ならソートする
        sort(bridges.begin(), bridges.end()); // 必要ならソートする
    }
    int dfs(int id, int k, int par) { // id:探索中の頂点, k:dfsで何番目に探索するか, par:idの親
        used[id] = true;
        ord[id] = k++;
        low[id] = ord[id];
        bool is_aps = false;
        int count = 0; // 子の数
        for (auto &e : G[id]) {
            if (!used[e.to]) {
                count++;
                k = dfs(e.to, k, id);
                low[id] = min(low[id], low[e.to]);
                if (par != -1 && ord[id] <= low[e.to]) is_aps = true;
                if (ord[id] < low[e.to]) bridges.emplace_back(min(id, e.to), max(id, e.to)); // 条件を満たすので橋
            } else if (e.to != par) { // eが後退辺の時
                low[id] = min(low[id], ord[e.to]);
            }
        }
        if (par == -1 && count >= 2) is_aps = true;
        if (is_aps) aps.push_back(id);
        return k;
    }
};
int solve() {
    ll n,m; input(n,m);
    vector<pll> edges(m);
    map<pll,ll> eid;
    rep(i, m) {
        ll u,v; input(u, v);
        --u; --v;
        edges[i] = {u, v};
        eid[{u, v}] = i;
        eid[{v, u}] = i;
    }
    vl seen(m, 0);
    vl lower, upper;
    while (sum(seen) < m) {
        auto g = Graph(n);
        vl cnt(n, 0);
        rep(i, m) if (!seen[i]) {
            auto [u, v] = edges[i];
            cnt[u]++;
            cnt[v]++;
            g[u].emplace_back(v);
            g[v].emplace_back(u);
        }
        auto lowlink = LowLink(g);
        bool update = false;
        debug(lowlink.bridges, cnt);
        if (lowlink.bridges.empty()) {
            rep(i, m) if (!seen[i]) {
                auto [u, v] = edges[i];
                if (cnt[u] <= 2 && cnt[v] <= 2) {
                    auto id = eid[{u, v}];
                    seen[id] = true;
                    update = true;
                    upper.push_back(id);
                }
            }
        } else {
            for (auto [u, v] : lowlink.bridges) {
                auto id = eid[{u, v}];
                seen[id] = true;
                update = true;
                lower.push_back(id);
            }
        }
        if (!update) {return print(-1);}
    }
    reverse(all(upper));
    vl ans;
    repe(x, lower) ans.push_back(x+1);
    repe(x, upper) ans.push_back(x+1);
    print(ans);
    return 0;
}
int main() {
    ll t; input(t);
    rep(t) solve();
}
#else
//line 2 "/home/seekworser/.cpp_lib/competitive_library/competitive/std/std.hpp"
#include <bits/stdc++.h>
#ifndef LOCAL_TEST
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif // LOCAL_TEST
using namespace std;
using std::cout;
// shorten typenames
using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using vi = vector<int>;  using vvi = vector<vi>; using vvvi = vector<vvi>;
using vl = vector<ll>;  using vvl = vector<vl>; using vvvl = vector<vvl>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vc = vector<char>; using vvc = vector<vc>; using vvvc = vector<vvc>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using vs = vector<string>; using vvs = vector<vector<string>>; using vvvs = vector<vector<vector<string>>>;
template<typename T> vector<vector<T>> vv(int h, int w, T val = T()) { return vector(h, vector<T>(w, val)); }
template<typename T> vector<vector<vector<T>>> vvv(int h1, int h2, int h3, T val = T()) { return vector(h1, vector(h2, vector<T>(h3, val))); }
template<typename T> vector<vector<vector<vector<T>>>> vvvv(int h1, int h2, int h3, int h4, T val = T()) { return vector(h1, vector(h2, vector(h3, vector<T>(h4, val)))); }
template <class T> using priority_queue_min = priority_queue<T, vector<T>, greater<T>>;
// define CONSTANTS
constexpr double PI = 3.14159265358979323;
constexpr int INF = 100100111; constexpr ll INFL = 3300300300300300491LL;
float EPS = 1e-8; double EPSL = 1e-10;
template<typename T> bool eq(const T x, const T y) { return x == y; }
template<> bool eq<double>(const double x, const double y) { return (abs(x - y) < EPSL * x || abs(x - y) < EPSL); }
template<> bool eq<float>(const float x, const float y) { return abs(x - y) < EPS * x; }
template<typename T> bool neq(const T x, const T y) { return !(eq<T>(x, y)); }
template<typename T> bool ge(const T x, const T y) { return (eq<T>(x, y) || (x > y)); }
template<typename T> bool le(const T x, const T y) { return (eq<T>(x, y) || (x < y)); }
template<typename T> bool gt(const T x, const T y) { return !(le<T>(x, y)); }
template<typename T> bool lt(const T x, const T y) { return !(ge<T>(x, y)); }
constexpr int MODINT998244353 = 998244353;
constexpr int MODINT1000000007 = 1000000007;
// fasten io
struct Nyan { Nyan() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(18); } } nyan;
// define macros
#define all(a) (a).begin(), (a).end()
#define sz(x) ((ll)(x).size())
#define rep1(n) for(ll dummy_iter = 0LL; dummy_iter < n; ++dummy_iter) // 0,1,...,n-1
#define rep2(i, n) for(ll i = 0LL, i##_counter = 0LL; i##_counter < ll(n); ++(i##_counter), (i) = i##_counter) // i=0,1,...,n-1
#define rep3(i, s, t) for(ll i = ll(s), i##_counter = ll(s); i##_counter < ll(t); ++(i##_counter), (i) = (i##_counter)) // i=s,s+1,...,t-1
#define rep4(i, s, t, step) for(ll i##_counter = step > 0 ? ll(s) : -ll(s), i##_end = step > 0 ? ll(t) : -ll(t), i##_step = abs(step), i = ll(s); i##_counter < i##_end; i##_counter += i##_step, i = step > 0 ? i##_counter : -i##_counter) // i=s,s+step,...,<t
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define repe(a, v) for(auto& a : (v)) // iterate over all elements in v
#define smod(n, m) ((((n) % (m)) + (m)) % (m))
#define sdiv(n, m) (((n) - smod(n, m)) / (m))
#define uniq(a) {sort(all(a)); (a).erase(unique(all(a)), (a).end());}
int Yes(bool b=true) { cout << (b ? "Yes\n" : "No\n"); return 0; };
int YES(bool b=true) { cout << (b ? "YES\n" : "NO\n"); return 0; };
int No(bool b=true) {return Yes(!b);};
int NO(bool b=true) {return YES(!b);};
template<typename T, size_t N> T max(array<T, N>& a) { return *max_element(all(a)); };
template<typename T, size_t N> T min(array<T, N>& a) { return *min_element(all(a)); };
template<typename T> T max(vector<T>& a) { return *max_element(all(a)); };
template<typename T> T min(vector<T>& a) { return *min_element(all(a)); };
template<typename T> vector<T> vec_slice(const vector<T>& a, int l, int r) { vector<T> rev; rep(i, l, r) rev.push_back(a[i]); return rev; };
template<typename T> T sum(vector<T>& a, T zero = T(0)) { T rev = zero; rep(i, sz(a)) rev += a[i]; return rev; };
template<typename T> bool in_range(const T& val, const T& s, const T& t) { return s <= val && val < t; };

template <class T> inline vector<T>& operator--(vector<T>& v) { repe(x, v) --x; return v; }
template <class T> inline vector<T>& operator++(vector<T>& v) { repe(x, v) ++x; return v; }

ll powm(ll a, ll n, ll mod=INFL) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * a) % mod;
        if (n > 1) a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}
ll sqrtll(ll x) {
    assert(x >= 0);
    ll rev = sqrt(x);
    while(rev * rev > x) --rev;
    while((rev+1) * (rev+1)<=x) ++rev;
    return rev;
}
template <class T> inline bool chmax(T& M, const T& x) { if (M < x) { M = x; return true; } return false; }
template <class T> inline bool chmin(T& m, const T& x) { if (m > x) { m = x; return true; } return false; }
int digit(ll x, int d=10) { int rev=0; while (x > 0) { rev++; x /= d;}; return rev; }
/**
 * @brief std.hpp
 * @docs docs/std/std.md
 */
//line 3 "/home/seekworser/.cpp_lib/competitive_library/competitive/std/io.hpp"
// overload operators (prototypes)
template <class T, class U> inline istream& operator>>(istream& is, pair<T, U>& p);
template <class T> inline istream& operator>>(istream& is, vector<T>& v);
template <class T, class U> inline ostream& operator<<(ostream& os, const pair<T, U>& p);
template <class T> inline ostream& operator<<(ostream& os, const vector<T>& v);
template <typename T, typename S> ostream &operator<<(ostream &os, const map<T, S> &mp);
template <typename T> ostream &operator<<(ostream &os, const set<T> &st);
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st);
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &st);
template <typename T> ostream &operator<<(ostream &os, queue<T> q);
template <typename T> ostream &operator<<(ostream &os, deque<T> q);
template <typename T> ostream &operator<<(ostream &os, stack<T> st);
template <class T, class Container, class Compare> ostream &operator<<(ostream &os, priority_queue<T, Container, Compare> pq);

// overload operators
template <class T, class U> inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template <class T> inline istream& operator>>(istream& is, vector<T>& v) { repe(x, v) is >> x; return is; }
template <class T, class U> inline ostream& operator<<(ostream& os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; }
template <class T> inline ostream& operator<<(ostream& os, const vector<T>& v) { rep(i, sz(v)) { os << v.at(i); if (i != sz(v) - 1) os << " "; } return os; }
template <typename T, typename S> ostream &operator<<(ostream &os, const map<T, S> &mp) { for (auto &[key, val] : mp) { os << key << ":" << val << " "; } return os; }
template <typename T> ostream &operator<<(ostream &os, const set<T> &st) { auto itr = st.begin(); for (int i = 0; i < (int)st.size(); i++) { os << *itr << (i + 1 != (int)st.size() ? " " : ""); itr++; } return os; }
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st) { auto itr = st.begin(); for (int i = 0; i < (int)st.size(); i++) { os << *itr << (i + 1 != (int)st.size() ? " " : ""); itr++; } return os; }
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &st) { ll cnt = 0; for (auto &e : st) { os << e << (++cnt != (int)st.size() ? " " : ""); } return os; }
template <typename T> ostream &operator<<(ostream &os, queue<T> q) { while (q.size()) { os << q.front() << " "; q.pop(); } return os; }
template <typename T> ostream &operator<<(ostream &os, deque<T> q) { while (q.size()) { os << q.front(); q.pop_front(); if (q.size()) os << " "; } return os; }
template <typename T> ostream &operator<<(ostream &os, stack<T> st) { while (st.size()) { os << st.top() << " "; st.pop(); } return os; }
template <class T, class Container, class Compare> ostream &operator<<(ostream &os, priority_queue<T, Container, Compare> pq) { while (pq.size()) { os << pq.top() << " "; pq.pop(); } return os; }

template <typename T> int print_sep_end(string sep, string end, const T& val) { (void)sep; cout << val << end; return 0; };
template <typename T1, typename... T2> int print_sep_end(string sep, string end, const T1 &val, const T2 &...remain) {
    cout << val << sep;
    print_sep_end(sep, end, remain...);
    return 0;
};
template <typename... T> int print(const T &...args) { print_sep_end(" ", "\n", args...); return 0; };
template <typename... T> void flush() { cout << flush; };
template <typename... T> int print_and_flush(const T &...args) { print(args...); flush(); return 0; };
#define debug(...) debug_func(0, #__VA_ARGS__, __VA_ARGS__) // debug print
template <typename T> void input(T &a) { cin >> a; };
template <typename T1, typename... T2> void input(T1&a, T2 &...b) { cin >> a; input(b...); };
#ifdef LOCAL_TEST
template <typename T> void debug_func(int i, const T name) { (void)i; (void)name; cerr << endl; }
template <typename T1, typename T2, typename... T3> void debug_func(int i, const T1 &name, const T2 &a, const T3 &...b) {
    int scope = 0;
    for ( ; (scope != 0 || name[i] != ',') && name[i] != '\0'; i++ ) {
        cerr << name[i];
        if (name[i] == '(' || name[i] == '{') scope++;
        if (name[i] == ')' || name[i] == '}') scope--;
    }
    cerr << ":" << a << " ";
    debug_func(i + 1, name, b...);
}
template <typename T1, typename T2, typename... T3> void debug_func(int i, const T1 &name, T2 &a, T3 &...b) {
    int scope = 0;
    for ( ; (scope != 0 || name[i] != ',') && name[i] != '\0'; i++ ) {
        cerr << name[i];
        if (name[i] == '(' || name[i] == '{') scope++;
        if (name[i] == ')' || name[i] == '}') scope--;
    }
    cerr << ":" << a << " ";
    debug_func(i + 1, name, b...);
}
#endif
#ifndef LOCAL_TEST
template <typename... T>
void debug_func(T &...) {}
template <typename... T>
void debug_func(const T &...) {}
#endif
/**
 * @brief io.hpp
 * @docs docs/std/io.md
 */
//line 112 "answer.cpp"
#endif

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
4 4
1 2
2 3
3 4
4 2

output:

1 4 3 2

result:

ok Correct

Test #2:

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

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

result:

ok Correct

Test #3:

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

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:

892 700 1487 2450 647 2886 1223 2074 2070 1788 1333 2834 835 2457 689 1638 1115 2006 105 440 347 1894 2419 2762 1495 2781 2818 903 79 2476 1004 1039 165 981 1054 1694 2536 203 2003 2695 1217 1055 1338 270 2807 1682 213 1962 100 2759 1494 2836 2608 80 2775 2087 1898 1954 1380 2347 2031 172 1114 2435 ...

result:

ok Correct

Test #4:

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

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:

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

result:

ok Correct

Test #5:

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

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:

1920 950 891 308 1771 1990 388 1346 2307 1874 1082 771 7 1147 1895 187 462 1212 2414 2453 1833 1444 919 1841 763 636 766 1027 856 312 892 2451 2161 2368 1861 1511 1498 3 2444 1591 539 1469 2337 43 1564 1217 1407 542 2355 1300 1304 330 2018 137 2353 103 11 331 2427 1549 1226 740 1994 929 1791 715 213...

result:

ok Correct

Test #6:

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

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:

1274 1054 243 1618 1445 123 1170 425 1032 312 626 391 1510 478 1385 1744 254 1031 571 1315 1329 1382 32 676 1270 798 147 1416 402 9 1070 1604 1186 436 358 965 304 8 1467 1499 1465 1650 1278 128 455 1620 1128 666 1502 979 1355 1573 1269 860 953 1507 881 1721 95 202 824 7 717 1564 1279 901 658 4 404 1...

result:

ok Correct

Test #7:

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

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

result:

ok Correct

Test #8:

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

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

result:

ok Correct

Test #9:

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

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

result:

ok Correct

Test #10:

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

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

result:

ok Correct

Test #11:

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

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

result:

ok Correct

Test #12:

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

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:

1965 3970 105 2092 1012 3628 3029 2224 3392 3247 2503 3475 278 1240 3268 3566 673 3563 3614 3206 1397 1718 2744 1666 409 429 65 1393 2207 1131 3743 241 2496 2741 3596 1249 1358 2500 585 3589 2298 2414 693 2338 2930 1486 1274 2308 1294 3512 883 417 172 786 2292 1738 3323 655 606 720 1832 2546 483 205...

result:

ok Correct

Test #13:

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

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:

2605 1475 3801 2075 1005 3667 3441 3583 639 3134 3492 2115 2481 3148 19 533 1849 3196 3556 1817 2112 3782 982 2739 3306 1635 1072 2801 1323 2866 2761 2234 997 3572 556 1520 1084 261 666 3308 3889 3377 3449 435 81 1404 338 220 2570 1103 2522 3894 2208 311 771 3821 1353 2339 423 2441 2537 3615 289 356...

result:

ok Correct

Test #14:

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

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:

2184 3716 1903 2791 226 983 2129 2773 2496 331 1052 258 413 2405 3089 1209 3982 627 3452 1388 1575 3796 1636 3816 807 1702 49 2780 797 1254 1164 3041 1229 2823 2728 1564 3470 2257 1121 1936 2176 3703 2672 2394 179 2324 735 3147 1658 3906 2568 2221 3483 3505 2505 663 3793 1637 360 2073 2529 1756 1783...

result:

ok Correct

Test #15:

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

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:

1641 3630 282 2374 178 2912 3899 390 2874 432 1055 3027 1814 27 2089 3192 1261 3425 418 1505 992 3532 3854 1581 3051 186 3749 2970 3393 986 3858 1286 3045 2342 1038 2866 1618 262 67 2641 438 2061 2516 1002 3884 2557 3405 648 2163 2277 1101 276 1601 2983 1066 2642 2347 2610 3241 3617 3542 454 1449 38...

result:

ok Correct

Test #16:

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

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:

2891 538 3772 1216 3941 2310 2103 1925 3861 606 1803 3926 2222 2951 1291 173 298 3319 901 751 2049 309 2602 2370 2916 918 1583 2073 3304 993 2631 1004 1073 1502 1739 3133 576 270 1385 40 3224 3809 308 1258 422 3233 819 1037 2593 3823 2839 2850 2774 2756 1847 2004 2990 2689 1197 2337 2942 3473 986 35...

result:

ok Correct

Test #17:

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

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:

1298 3372 3056 3447 3407 804 2570 3665 3517 3932 2229 2920 671 156 2089 2709 2454 3334 3780 3677 3650 3806 3720 3579 2169 135 1751 2381 1888 152 1087 1870 3189 2684 1738 3816 332 197 3965 3215 3734 2858 797 731 2649 3912 3600 2961 2808 2821 766 981 795 991 3058 3593 3067 3356 577 716 861 1262 1775 1...

result:

ok Correct

Test #18:

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

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:

1740 242 1420 1461 3799 1897 2461 1979 3482 120 2262 630 998 1307 3052 76 618 2707 2813 1768 559 693 2855 2105 993 3932 609 3817 3552 926 29 3055 2764 2615 1547 1320 3997 730 629 2812 539 3041 2513 2835 1377 3392 2572 3385 932 2489 2448 3200 409 1443 32 2639 537 772 1373 3040 488 2896 3326 3530 392 ...

result:

ok Correct

Test #19:

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

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:

2197 56 3372 2567 229 2494 2966 2977 3951 1823 38 1249 3310 1047 3173 2585 3704 1797 3269 1529 2687 3443 3561 1941 950 3653 3723 848 790 1553 1777 3971 1346 2564 1913 671 796 2264 3725 1562 2889 2709 1510 3752 377 1511 1570 1533 1669 2654 2559 3391 1588 843 1528 186 1370 1660 1247 1910 3254 675 129 ...

result:

ok Correct

Test #20:

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

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:

1681 1943 3850 97 3679 1002 925 3168 3986 3218 3650 1488 2481 3780 2943 2238 3781 3926 1701 188 1565 2235 2840 1455 963 2383 846 1128 924 2845 1703 3221 704 782 186 1029 2385 3639 3013 3493 3519 1013 997 248 1183 1138 662 589 3059 3694 2558 2501 2488 3177 1361 2056 3515 859 1186 2246 2698 1273 2571 ...

result:

ok Correct

Test #21:

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

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:

1935 752 3753 555 41 1981 2573 2851 1715 1123 1610 750 1828 1580 2693 1830 3658 3800 2526 1304 1603 3557 1352 217 292 2917 1831 3991 2354 1341 1607 433 2607 1187 3576 2330 1401 1247 2 762 3947 3661 1704 3540 144 360 3373 704 2778 2789 2959 169 2313 883 3831 2378 88 2649 969 132 3679 2887 1825 1807 1...

result:

ok Correct

Test #22:

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

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:

2214 1866 2419 2892 673 1833 429 3856 255 2116 620 1122 930 3187 2221 28 2403 2775 2483 369 1127 3798 3452 2470 152 1698 880 972 2092 842 1410 3747 1787 660 135 2211 3605 58 2622 2235 401 3819 1238 102 3766 2832 2631 532 1559 3043 2819 1386 3319 1457 352 2348 3904 3002 1247 3038 2801 1430 3288 1955 ...

result:

ok Correct

Test #23:

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

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:

1223 3134 979 1759 191 766 906 3302 2523 1712 39 628 3827 3461 2991 987 549 364 691 3013 1180 981 3140 988 718 995 1476 526 1363 1138 590 762 2272 296 3920 1881 3188 1263 27 939 1205 3597 1851 2394 1842 1204 2955 169 2534 1904 2367 693 3820 3877 2336 2047 2725 2859 3898 3930 2099 2965 1208 192 2342 ...

result:

ok Correct

Test #24:

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

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:

27 709 118 868 1922 3769 1345 2051 605 1603 2438 3064 461 3232 2067 1113 1053 3484 2806 2630 846 105 3386 2706 2612 3498 1437 3731 3668 3525 1735 2606 1399 2761 588 629 2708 3495 3291 3350 3215 1427 1173 2586 3545 3796 147 2555 3932 580 1656 1914 499 2159 3159 1770 1432 3374 2677 890 376 3427 23 926...

result:

ok Correct

Test #25:

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

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:

295 1892 232 922 3651 3459 188 2023 3236 2269 154 1108 1957 345 1736 3912 392 2774 4000 3710 711 2799 2547 2065 3404 644 3346 39 3126 3958 903 1979 1683 1474 41 2915 3308 3295 3570 75 2405 2584 1604 1335 905 59 907 3079 2678 101 924 1156 3681 834 1198 3666 363 621 2295 2136 3179 1595 3637 3646 3680 ...

result:

ok Correct

Test #26:

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

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:

3380 3837 918 294 1197 2782 3006 2290 3583 1437 1123 3982 1310 872 2269 908 1587 932 1957 1002 3046 3504 3175 1546 3966 676 1665 303 585 2683 586 2184 796 95 1054 983 2744 962 1125 329 194 3229 2353 628 3428 2991 3043 2234 3259 3732 2862 1111 3326 3918 2073 2753 1366 718 3325 1146 421 3753 719 2751 ...

result:

ok Correct

Test #27:

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

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:

1399 1107 1033 620 2199 1474 2050 2755 2954 398 711 2289 3238 2260 1155 2781 630 2948 3536 1098 695 2533 3779 638 1235 648 1454 1660 480 1106 2300 357 1276 2718 650 1402 1160 2684 3770 1630 873 1551 1440 2783 3871 2308 1165 2389 730 422 2299 2251 2632 1655 2677 3600 709 476 1778 3706 3953 1449 659 5...

result:

ok Correct

Test #28:

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

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:

3526 3168 12 3693 3752 154 1350 1045 2387 1954 1027 1980 3353 592 1257 3899 708 1516 1416 1934 2918 1490 3200 429 208 627 3727 3748 2556 733 887 520 3843 2333 620 832 3439 1432 439 2507 3240 2402 1587 2082 2386 3468 3853 2769 1122 253 214 2887 2873 2054 916 1866 1864 937 3215 2994 1662 2350 2261 549...

result:

ok Correct

Test #29:

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

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:

3054 459 2390 394 1385 2540 2624 2999 3204 393 646 3079 2619 3485 1461 3148 2749 495 956 1237 3973 132 2011 3641 1103 153 312 995 47 538 291 3403 3779 2728 3568 3022 906 2074 470 1991 891 2203 850 1189 3925 59 3810 1686 3626 1525 271 1602 1343 1454 484 3876 2865 1064 3501 3611 1446 2762 3023 3130 98...

result:

ok Correct

Test #30:

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

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:

3920 3110 1532 2489 3982 3211 3529 1142 2981 3349 1831 3915 3845 2748 1784 1629 2543 1368 1928 1357 1650 303 1371 2373 180 967 1860 547 3314 1264 31 48 314 3634 2410 3959 430 1430 3436 1892 3620 2420 2818 2902 3865 1247 470 77 692 583 3146 1711 198 351 2370 1138 2175 1765 1122 3023 1139 3515 1237 28...

result:

ok Correct

Test #31:

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

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:

3845 1365 1732 1384 464 2784 1488 2399 55 3610 2612 2143 3940 2930 1559 647 1750 1435 2008 3259 2594 2302 2001 729 1914 1044 2890 1869 46 1458 1142 319 2607 2680 3050 717 2801 3731 3805 1608 2586 1814 1246 3361 3553 1467 2948 749 908 2064 932 1540 509 899 508 1764 1776 2419 2427 2722 1744 3319 3924 ...

result:

ok Correct

Test #32:

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

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:

3104 2706 3350 1081 453 219 2587 1479 3922 3437 1782 2621 218 3686 3800 2499 774 954 215 753 3545 840 900 816 2222 2802 3025 1777 2504 2030 1078 2334 714 2404 2953 3873 899 3240 2422 3536 1537 2896 2046 2053 2204 2445 1540 2507 848 123 3916 1935 1133 3871 516 2218 3376 3319 3015 2549 3251 721 2633 6...

result:

ok Correct

Test #33:

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

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

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

result:

ok Correct

Test #35:

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

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

result:

ok Correct

Test #36:

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

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

result:

ok Correct

Test #37:

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

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

result:

ok Correct

Test #38:

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

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:

3993 3994 1334 1333 3992 1335 1336 3991 1337 1338 3990 3989 1340 3987 3988 1339 1342 3985 1341 3986 3983 1343 1344 3984 3982 3981 1345 1346 3980 1348 1347 3979 3977 1349 1350 3978 3975 1351 1352 3976 3973 1354 1353 3974 3971 3972 1356 1355 3970 1357 3969 1358 1359 3967 3968 1360 3965 1361 1362 3966 ...

result:

ok Correct

Test #39:

score: 0
Accepted
time: 387ms
memory: 4804kb

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: 195ms
memory: 4716kb

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:

1334 3994 1333 3993 1336 3992 1335 3991 1338 3990 1337 3989 1340 3987 3988 1339 3985 1342 1341 3986 1343 1344 3983 3984 3982 1345 1346 3981 3980 1347 3979 1348 1350 3978 1349 3977 3975 1351 1352 3976 3973 1353 1354 3974 1355 3971 1356 3972 1357 1358 3969 3970 1360 3968 3967 1359 1361 3966 3965 1362 ...

result:

ok Correct

Test #41:

score: 0
Accepted
time: 386ms
memory: 4700kb

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: 196ms
memory: 4960kb

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:

1333 1334 3994 3993 3992 1335 1336 3991 3990 1337 3989 1338 3988 1339 3987 1340 3985 3986 1342 1341 1344 1343 3984 3983 1346 3982 1345 3981 3980 1347 3979 1348 3977 1350 3978 1349 3975 1352 3976 1351 3973 1353 1354 3974 3971 3972 1355 1356 3970 3969 1358 1357 3967 1360 1359 3968 3965 1362 3966 1361 ...

result:

ok Correct

Test #43:

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

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: 3ms
memory: 4224kb

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:

1590 1134 341 1370 108 945 1462 533 126 1323 1396 1591 1093 1297 810 1711 790 508 1541 844 210 651 891 1007 274 914 788 119 423 331 1003 230 1598 371 417 1264 1151 1172 1121 1431 781 1089 767 1095 1197 1296 1670 1351 886 738 1519 1107 729 1231 1000 1613 1383 1290 1469 50 932 354 252 265 111 394 185 ...

result:

ok Correct

Test #45:

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

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:

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

result:

ok Correct

Test #46:

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

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:

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

result:

ok Correct

Test #47:

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

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:

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

result:

ok Correct

Test #48:

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

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:

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

result:

ok Correct

Test #49:

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

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:

2071 3159 2202 3498 2732 3841 306 2059 1722 1659 1958 1973 3860 830 932 2619 1926 2679 307 137 499 2049 2310 1997 741 3249 2472 249 2395 2387 1548 1770 390 3796 3888 3297 3600 1396 1879 2098 921 1746 1723 432 2110 3625 2555 3011 2238 2672 360 1664 513 1427 1718 276 263 3773 1112 2504 1001 3636 70 22...

result:

ok Correct

Test #50:

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

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:

476 255 3119 3302 1782 3205 1766 3786 698 742 1358 331 1906 2933 3378 1120 3479 1002 2214 1974 2765 2757 1642 861 1129 822 2089 575 3859 769 1877 1478 365 696 2694 745 3213 1891 23 2413 1289 1905 2934 1383 502 3116 209 1568 1367 934 1724 280 1560 3121 887 2251 1413 3189 836 2619 1017 2005 1272 763 9...

result:

ok Correct

Test #51:

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

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:

516 1128 2740 1750 181 3927 883 2286 1892 909 1888 3751 3708 77 1902 1702 1826 291 725 723 3701 2204 2490 322 3573 3710 2985 3034 3838 3449 2976 1184 2400 779 526 1900 3553 1845 3859 2874 6 1930 1654 822 1616 1824 1169 1424 2758 745 2394 1181 2789 2455 321 1865 3598 2826 336 2149 1439 755 1329 2369 ...

result:

ok Correct

Test #52:

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

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:

2200 2850 2921 947 2150 1989 166 540 2234 3081 1159 3712 2010 1857 1463 3391 2604 3279 1034 3254 2087 3451 2906 731 1310 1015 1131 2220 274 2550 2569 3671 3560 417 160 3623 443 2900 723 329 1926 1667 2948 1396 464 1468 2060 2170 3849 1434 185 2171 1574 1951 1477 1545 1114 1680 2767 1628 3009 2967 34...

result:

ok Correct

Test #53:

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

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:

2997 3308 3747 1036 2199 818 556 2144 3503 427 3786 1345 3943 1105 1848 1698 2317 2886 959 259 1882 984 627 3307 3913 2393 406 3223 2310 2932 3047 432 3383 1651 1824 770 830 2380 3045 2857 3633 1310 1047 841 1572 3453 3821 1375 2434 3600 3923 3479 1855 2705 3133 419 3094 69 1040 1059 163 932 2467 12...

result:

ok Correct

Test #54:

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

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:

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

result:

ok Correct

Test #55:

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

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

result:

ok Correct

Test #56:

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

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:

25 1 28 32 11 19 18 2 26 3 20 10 4 6 16 12 15 5 29 23 13 21 24 14 17 27 30 7 8 33 31 22 9
-1
14 1 8 9 11 3 19 4 2 16 18 5 6 15 10 13 17 7 12
7 19 5 3 16 9 18 17 15 10 14 11 4 13 8 1 2 12 6
54 25 5 33 75 49 22 11 63 59 43 47 24 55 46 62 12 61 2 45 72 42 16 76 73 57 9 39 71 36 34 3 66 58 53 65 19 77 8...

result:

ok Correct

Test #57:

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

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:

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

result:

ok Correct

Test #58:

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

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:

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

result:

ok Correct

Test #59:

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

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:

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

result:

ok Correct

Test #60:

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

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:

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

result:

ok Correct

Test #61:

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

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:

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

result:

ok Correct

Test #62:

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

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:

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

result:

ok Correct

Test #63:

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

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:

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

result:

ok Correct

Test #64:

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

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: 3752kb

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:

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

result:

ok Correct

Test #66:

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

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: 3684kb

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:

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

result:

ok Correct

Test #68:

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

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

result:

ok Correct

Test #69:

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

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:

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

result:

ok Correct

Test #70:

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

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:

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

result:

ok Correct

Test #71:

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

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:

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

result:

ok Correct

Test #72:

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

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

result:

ok Correct

Test #73:

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

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

result:

ok Correct

Test #74:

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

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

result:

ok Correct

Test #75:

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

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:

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

result:

ok Correct

Test #76:

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

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:

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

result:

ok Correct

Test #77:

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

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

result:

ok Correct

Extra Test:

score: 0
Extra Test Passed