QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#434249#8787. Unusual Caseucup-team112#AC ✓921ms25172kbC++2021.9kb2024-06-08 15:18:392024-06-08 15:18:41

Judging History

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

  • [2024-06-08 15:18:41]
  • 评测
  • 测评结果:AC
  • 用时:921ms
  • 内存:25172kb
  • [2024-06-08 15:18:39]
  • 提交

answer

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #define INTERACTIVE

#include <bits/stdc++.h>
using namespace std;

namespace templates {
// type
using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pil = pair<int, ll>;
using Pli = pair<ll, int>;
using Pll = pair<ll, ll>;
template <class T>
using pq = priority_queue<T>;
template <class T>
using qp = priority_queue<T, vector<T>, greater<T>>;
// clang-format off
#define vec(T, A, ...) vector<T> A(__VA_ARGS__);
#define vvec(T, A, h, ...) vector<vector<T>> A(h, vector<T>(__VA_ARGS__));
#define vvvec(T, A, h1, h2, ...) vector<vector<vector<T>>> A(h1, vector<vector<T>>(h2, vector<T>(__VA_ARGS__)));
// clang-format on

// for loop
#define fori1(a) for (ll _ = 0; _ < (a); _++)
#define fori2(i, a) for (ll i = 0; i < (a); i++)
#define fori3(i, a, b) for (ll i = (a); i < (b); i++)
#define fori4(i, a, b, c) for (ll i = (a); ((c) > 0 || i > (b)) && ((c) < 0 || i < (b)); i += (c))
#define overload4(a, b, c, d, e, ...) e
#define fori(...) overload4(__VA_ARGS__, fori4, fori3, fori2, fori1)(__VA_ARGS__)

// declare and input
// clang-format off
#define INT(...) int __VA_ARGS__; inp(__VA_ARGS__);
#define LL(...) ll __VA_ARGS__; inp(__VA_ARGS__);
#define STRING(...) string __VA_ARGS__; inp(__VA_ARGS__);
#define CHAR(...) char __VA_ARGS__; inp(__VA_ARGS__);
#define DOUBLE(...) double __VA_ARGS__; STRING(str___); __VA_ARGS__ = stod(str___);
#define VEC(T, A, n) vector<T> A(n); inp(A);
#define VVEC(T, A, n, m) vector<vector<T>> A(n, vector<T>(m)); inp(A);
// clang-format on

// const value
const ll MOD1   = 1000000007;
const ll MOD9   = 998244353;
const double PI = acos(-1);

// other macro
#if !defined(RIN__LOCAL) && !defined(INTERACTIVE)
#define endl "\n"
#endif
#define spa ' '
#define len(A) ll(A.size())
#define all(A) begin(A), end(A)

// function
vector<char> stoc(string &S) {
    int n = S.size();
    vector<char> ret(n);
    for (int i = 0; i < n; i++) ret[i] = S[i];
    return ret;
}
string ctos(vector<char> &S) {
    int n      = S.size();
    string ret = "";
    for (int i = 0; i < n; i++) ret += S[i];
    return ret;
}

template <class T>
auto min(const T &a) {
    return *min_element(all(a));
}
template <class T>
auto max(const T &a) {
    return *max_element(all(a));
}
template <class T, class S>
auto clamp(T &a, const S &l, const S &r) {
    return (a > r ? r : a < l ? l : a);
}
template <class T, class S>
inline bool chmax(T &a, const S &b) {
    return (a < b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chmin(T &a, const S &b) {
    return (a > b ? a = b, 1 : 0);
}
template <class T, class S>
inline bool chclamp(T &a, const S &l, const S &r) {
    auto b = clamp(a, l, r);
    return (a != b ? a = b, 1 : 0);
}

template <typename T>
T sum(vector<T> &A) {
    T tot = 0;
    for (auto a : A) tot += a;
    return tot;
}

template <typename T>
vector<T> compression(vector<T> X) {
    sort(all(X));
    X.erase(unique(all(X)), X.end());
    return X;
}

// input and output
namespace io {
// __int128_t
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
    std::ostream::sentry s(dest);
    if (s) {
        __uint128_t tmp = value < 0 ? -value : value;
        char buffer[128];
        char *d = std::end(buffer);
        do {
            --d;
            *d = "0123456789"[tmp % 10];
            tmp /= 10;
        } while (tmp != 0);
        if (value < 0) {
            --d;
            *d = '-';
        }
        int len = std::end(buffer) - d;
        if (dest.rdbuf()->sputn(d, len) != len) {
            dest.setstate(std::ios_base::badbit);
        }
    }
    return dest;
}

// vector<T>
template <typename T>
istream &operator>>(istream &is, vector<T> &A) {
    for (auto &a : A) is >> a;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << ' ';
    }
    return os;
}

// vector<vector<T>>
template <typename T>
istream &operator>>(istream &is, vector<vector<T>> &A) {
    for (auto &a : A) is >> a;
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<vector<T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << endl;
    }
    return os;
}

// pair<S, T>
template <typename S, typename T>
istream &operator>>(istream &is, pair<S, T> &A) {
    is >> A.first >> A.second;
    return is;
}
template <typename S, typename T>
ostream &operator<<(ostream &os, pair<S, T> &A) {
    os << A.first << ' ' << A.second;
    return os;
}

// vector<pair<S, T>>
template <typename S, typename T>
istream &operator>>(istream &is, vector<pair<S, T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        is >> A[i];
    }
    return is;
}
template <typename S, typename T>
ostream &operator<<(ostream &os, vector<pair<S, T>> &A) {
    for (size_t i = 0; i < A.size(); i++) {
        os << A[i];
        if (i != A.size() - 1) os << endl;
    }
    return os;
}

// tuple
template <typename T, size_t N>
struct TuplePrint {
    static ostream &print(ostream &os, const T &t) {
        TuplePrint<T, N - 1>::print(os, t);
        os << ' ' << get<N - 1>(t);
        return os;
    }
};
template <typename T>
struct TuplePrint<T, 1> {
    static ostream &print(ostream &os, const T &t) {
        os << get<0>(t);
        return os;
    }
};
template <typename... Args>
ostream &operator<<(ostream &os, const tuple<Args...> &t) {
    TuplePrint<decltype(t), sizeof...(Args)>::print(os, t);
    return os;
}

// io functions
void FLUSH() {
    cout << flush;
}

void print() {
    cout << endl;
}
template <class Head, class... Tail>
void print(Head &&head, Tail &&...tail) {
    cout << head;
    if (sizeof...(Tail)) cout << spa;
    print(std::forward<Tail>(tail)...);
}

template <typename T, typename S>
void prisep(vector<T> &A, S sep) {
    int n = A.size();
    for (int i = 0; i < n; i++) {
        cout << A[i];
        if (i != n - 1) cout << sep;
    }
    cout << endl;
}
template <typename T, typename S>
void priend(T A, S end) {
    cout << A << end;
}
template <typename T>
void prispa(T A) {
    priend(A, spa);
}
template <typename T, typename S>
bool printif(bool f, T A, S B) {
    if (f)
        print(A);
    else
        print(B);
    return f;
}

template <class... T>
void inp(T &...a) {
    (cin >> ... >> a);
}

} // namespace io
using namespace io;

// read graph
vector<vector<int>> read_edges(int n, int m, bool direct = false, int indexed = 1) {
    vector<vector<int>> edges(n, vector<int>());
    for (int i = 0; i < m; i++) {
        INT(u, v);
        u -= indexed;
        v -= indexed;
        edges[u].push_back(v);
        if (!direct) edges[v].push_back(u);
    }
    return edges;
}
vector<vector<int>> read_tree(int n, int indexed = 1) {
    return read_edges(n, n - 1, false, indexed);
}

template <typename T = long long>
vector<vector<pair<int, T>>> read_wedges(int n, int m, bool direct = false, int indexed = 1) {
    vector<vector<pair<int, T>>> edges(n, vector<pair<int, T>>());
    for (int i = 0; i < m; i++) {
        INT(u, v);
        T w;
        inp(w);
        u -= indexed;
        v -= indexed;
        edges[u].push_back({v, w});
        if (!direct) edges[v].push_back({u, w});
    }
    return edges;
}
template <typename T = long long>
vector<vector<pair<int, T>>> read_wtree(int n, int indexed = 1) {
    return read_wedges<T>(n, n - 1, false, indexed);
}

// yes / no
namespace yesno {

// yes
inline bool yes(bool f = true) {
    cout << (f ? "yes" : "no") << endl;
    return f;
}
inline bool Yes(bool f = true) {
    cout << (f ? "Yes" : "No") << endl;
    return f;
}
inline bool YES(bool f = true) {
    cout << (f ? "YES" : "NO") << endl;
    return f;
}

// no
inline bool no(bool f = true) {
    cout << (!f ? "yes" : "no") << endl;
    return f;
}
inline bool No(bool f = true) {
    cout << (!f ? "Yes" : "No") << endl;
    return f;
}
inline bool NO(bool f = true) {
    cout << (!f ? "YES" : "NO") << endl;
    return f;
}

// possible
inline bool possible(bool f = true) {
    cout << (f ? "possible" : "impossible") << endl;
    return f;
}
inline bool Possible(bool f = true) {
    cout << (f ? "Possible" : "Impossible") << endl;
    return f;
}
inline bool POSSIBLE(bool f = true) {
    cout << (f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return f;
}

// impossible
inline bool impossible(bool f = true) {
    cout << (!f ? "possible" : "impossible") << endl;
    return f;
}
inline bool Impossible(bool f = true) {
    cout << (!f ? "Possible" : "Impossible") << endl;
    return f;
}
inline bool IMPOSSIBLE(bool f = true) {
    cout << (!f ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return f;
}

// Alice Bob
inline bool Alice(bool f = true) {
    cout << (f ? "Alice" : "Bob") << endl;
    return f;
}
inline bool Bob(bool f = true) {
    cout << (f ? "Bob" : "Alice") << endl;
    return f;
}

// Takahashi Aoki
inline bool Takahashi(bool f = true) {
    cout << (f ? "Takahashi" : "Aoki") << endl;
    return f;
}
inline bool Aoki(bool f = true) {
    cout << (f ? "Aoki" : "Takahashi") << endl;
    return f;
}

} // namespace yesno
using namespace yesno;

} // namespace templates
using namespace templates;

////////// https://codeforces.com/blog/entry/90513

namespace hamil {
template <typename T>
bool chkmax(T &x, T y) {
    return x < y ? x = y, true : false;
}
template <typename T>
bool chkmin(T &x, T y) {
    return x > y ? x = y, true : false;
}
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
#define ll long long
namespace LCT {
vector<vi> ch;
vi fa, rev;
void init(int n) {
    ch.resize(n + 1);
    fa.resize(n + 1);
    rev.resize(n + 1);
    for (int i = 0; i <= n; i++) ch[i].resize(2), ch[i][0] = ch[i][1] = fa[i] = rev[i] = 0;
}
bool isr(int a) {
    return !(ch[fa[a]][0] == a || ch[fa[a]][1] == a);
}
void pushdown(int a) {
    if (rev[a]) {
        rev[ch[a][0]] ^= 1, rev[ch[a][1]] ^= 1;
        swap(ch[a][0], ch[a][1]);
        rev[a] = 0;
    }
}
void push(int a) {
    if (!isr(a)) push(fa[a]);
    pushdown(a);
}
void rotate(int a) {
    int f = fa[a], gf = fa[f];
    int tp  = ch[f][1] == a;
    int son = ch[a][tp ^ 1];
    if (!isr(f)) ch[gf][ch[gf][1] == f] = a;
    fa[a] = gf;

    ch[f][tp] = son;
    if (son) fa[son] = f;

    ch[a][tp ^ 1] = f, fa[f] = a;
}
void splay(int a) {
    push(a);
    while (!isr(a)) {
        int f = fa[a], gf = fa[f];
        if (isr(f))
            rotate(a);
        else {
            int t1 = ch[gf][1] == f, t2 = ch[f][1] == a;
            if (t1 == t2)
                rotate(f), rotate(a);
            else
                rotate(a), rotate(a);
        }
    }
}
void access(int a) {
    int pr = a;
    splay(a);
    ch[a][1] = 0;
    while (1) {
        if (!fa[a]) break;
        int u = fa[a];
        splay(u);
        ch[u][1] = a;
        a        = u;
    }
    splay(pr);
}
void makeroot(int a) {
    access(a);
    rev[a] ^= 1;
}
void link(int a, int b) {
    makeroot(a);
    fa[a] = b;
}
void cut(int a, int b) {
    makeroot(a);
    access(b);
    fa[a] = 0, ch[b][0] = 0;
}
int fdr(int a) {
    access(a);
    while (1) {
        pushdown(a);
        if (ch[a][0])
            a = ch[a][0];
        else {
            splay(a);
            return a;
        }
    }
}
} // namespace LCT
vi out, in;
vi work(int n, vector<pi> eg, ll mx_ch = -1) {
    // mx_ch : max number of adding/replacing  default is (n + 100) * (n + 50)
    // n : number of vertices. 1-indexed.
    // eg: vector<pair<int, int> > storing all the edges.
    // return a vector<int> consists of all indices of vertices on the path. return empty list if
    // failed to find one.
    out.resize(n + 1), in.resize(n + 1);
    LCT::init(n);
    for (int i = 0; i <= n; i++) in[i] = out[i] = 0;
    if (mx_ch == -1) mx_ch = 1ll * (n + 100) * (n + 50); // default
    vector<vi> from(n + 1), to(n + 1);
    for (auto v : eg) from[v.fi].pb(v.se), to[v.se].pb(v.fi);
    unordered_set<int> canin, canout;
    for (int i = 1; i <= n; i++) canin.insert(i), canout.insert(i);
    mt19937 x(chrono::steady_clock::now().time_since_epoch().count());
    int tot = 0;
    while (mx_ch >= 0) {
        //    cout << tot << ' ' << mx_ch << endl;
        vector<pi> eg;
        for (auto v : canout)
            for (auto s : from[v])
                if (in[s] == 0) {
                    assert(canin.count(s));
                    continue;
                } else
                    eg.pb(mp(v, s));
        for (auto v : canin)
            for (auto s : to[v]) eg.pb(mp(s, v));
        shuffle(eg.begin(), eg.end(), x);
        if (eg.size() == 0) break;
        for (auto v : eg) {
            mx_ch--;
            if (in[v.se] && out[v.fi]) continue;
            if (LCT::fdr(v.fi) == LCT::fdr(v.se)) continue;
            if (in[v.se] || out[v.fi])
                if (x() & 1) continue;
            if (!in[v.se] && !out[v.fi]) tot++;
            if (in[v.se]) {
                LCT::cut(in[v.se], v.se);
                canin.insert(v.se);
                canout.insert(in[v.se]);
                out[in[v.se]] = 0;
                in[v.se]      = 0;
            }
            if (out[v.fi]) {
                LCT::cut(v.fi, out[v.fi]);
                canin.insert(out[v.fi]);
                canout.insert(v.fi);
                in[out[v.fi]] = 0;
                out[v.fi]     = 0;
            }
            LCT::link(v.fi, v.se);
            canin.erase(v.se);
            canout.erase(v.fi);
            in[v.se]  = v.fi;
            out[v.fi] = v.se;
        }
        if (tot == n - 1) {
            vi cur;
            for (int i = 1; i <= n; i++)
                if (!in[i]) {
                    int pl = i;
                    while (pl) {
                        cur.pb(pl), pl = out[pl];
                    }
                    break;
                }
            return cur;
        }
    }
    // failed to find a path
    return vi();
}
} // namespace hamil

void solve() {
    INT(n, m, k);
    VEC(Pii, edges, m);
    fori(i, m) {
        edges.push_back({edges[i].second, edges[i].first});
    }
    sort(all(edges));

    fori(k) {
        auto res = hamil::work(n, edges);
        print(res);

        vec(Pii, remove, 0);
        fori(i, n - 1) {
            remove.push_back({res[i], res[i + 1]});
            remove.push_back({res[i + 1], res[i]});
        }
        sort(all(remove));
        vec(Pii, new_edges, 0);
        int p = 0;
        for (auto e : edges) {
            if (p < remove.size() && e == remove[p]) {
                p++;
                continue;
            }
            new_edges.push_back(e);
        }
        edges = new_edges;
    }
}

int main() {
#ifndef INTERACTIVE
    cin.tie(0)->sync_with_stdio(0);
#endif
    // cout << fixed << setprecision(12);
    int t;
    t = 1;
    // cin >> t;
    while (t--) solve();
    return 0;
}

// // #pragma GCC target("avx2")
// // #pragma GCC optimize("O3")
// // #pragma GCC optimize("unroll-loops")
// // #define INTERACTIVE
//
// #include "kyopro-cpp/template.hpp"
//
// ////////// https://codeforces.com/blog/entry/90513
//
// namespace hamil {
// template <typename T>
// bool chkmax(T &x, T y) {
//     return x < y ? x = y, true : false;
// }
// template <typename T>
// bool chkmin(T &x, T y) {
//     return x > y ? x = y, true : false;
// }
// #define vi vector<int>
// #define pb push_back
// #define mp make_pair
// #define pi pair<int, int>
// #define fi first
// #define se second
// #define ll long long
// namespace LCT {
// vector<vi> ch;
// vi fa, rev;
// void init(int n) {
//     ch.resize(n + 1);
//     fa.resize(n + 1);
//     rev.resize(n + 1);
//     for (int i = 0; i <= n; i++) ch[i].resize(2), ch[i][0] = ch[i][1] = fa[i] = rev[i] = 0;
// }
// bool isr(int a) {
//     return !(ch[fa[a]][0] == a || ch[fa[a]][1] == a);
// }
// void pushdown(int a) {
//     if (rev[a]) {
//         rev[ch[a][0]] ^= 1, rev[ch[a][1]] ^= 1;
//         swap(ch[a][0], ch[a][1]);
//         rev[a] = 0;
//     }
// }
// void push(int a) {
//     if (!isr(a)) push(fa[a]);
//     pushdown(a);
// }
// void rotate(int a) {
//     int f = fa[a], gf = fa[f];
//     int tp  = ch[f][1] == a;
//     int son = ch[a][tp ^ 1];
//     if (!isr(f)) ch[gf][ch[gf][1] == f] = a;
//     fa[a] = gf;
//
//     ch[f][tp] = son;
//     if (son) fa[son] = f;
//
//     ch[a][tp ^ 1] = f, fa[f] = a;
// }
// void splay(int a) {
//     push(a);
//     while (!isr(a)) {
//         int f = fa[a], gf = fa[f];
//         if (isr(f))
//             rotate(a);
//         else {
//             int t1 = ch[gf][1] == f, t2 = ch[f][1] == a;
//             if (t1 == t2)
//                 rotate(f), rotate(a);
//             else
//                 rotate(a), rotate(a);
//         }
//     }
// }
// void access(int a) {
//     int pr = a;
//     splay(a);
//     ch[a][1] = 0;
//     while (1) {
//         if (!fa[a]) break;
//         int u = fa[a];
//         splay(u);
//         ch[u][1] = a;
//         a        = u;
//     }
//     splay(pr);
// }
// void makeroot(int a) {
//     access(a);
//     rev[a] ^= 1;
// }
// void link(int a, int b) {
//     makeroot(a);
//     fa[a] = b;
// }
// void cut(int a, int b) {
//     makeroot(a);
//     access(b);
//     fa[a] = 0, ch[b][0] = 0;
// }
// int fdr(int a) {
//     access(a);
//     while (1) {
//         pushdown(a);
//         if (ch[a][0])
//             a = ch[a][0];
//         else {
//             splay(a);
//             return a;
//         }
//     }
// }
// } // namespace LCT
// vi out, in;
// vi work(int n, vector<pi> eg, ll mx_ch = -1) {
//     // mx_ch : max number of adding/replacing  default is (n + 100) * (n + 50)
//     // n : number of vertices. 1-indexed.
//     // eg: vector<pair<int, int> > storing all the edges.
//     // return a vector<int> consists of all indices of vertices on the path. return empty list if
//     // failed to find one.
//     out.resize(n + 1), in.resize(n + 1);
//     LCT::init(n);
//     for (int i = 0; i <= n; i++) in[i] = out[i] = 0;
//     if (mx_ch == -1) mx_ch = 1ll * (n + 100) * (n + 50); // default
//     vector<vi> from(n + 1), to(n + 1);
//     for (auto v : eg) from[v.fi].pb(v.se), to[v.se].pb(v.fi);
//     unordered_set<int> canin, canout;
//     for (int i = 1; i <= n; i++) canin.insert(i), canout.insert(i);
//     mt19937 x(chrono::steady_clock::now().time_since_epoch().count());
//     int tot = 0;
//     while (mx_ch >= 0) {
//         //    cout << tot << ' ' << mx_ch << endl;
//         vector<pi> eg;
//         for (auto v : canout)
//             for (auto s : from[v])
//                 if (in[s] == 0) {
//                     assert(canin.count(s));
//                     continue;
//                 } else
//                     eg.pb(mp(v, s));
//         for (auto v : canin)
//             for (auto s : to[v]) eg.pb(mp(s, v));
//         shuffle(eg.begin(), eg.end(), x);
//         if (eg.size() == 0) break;
//         for (auto v : eg) {
//             mx_ch--;
//             if (in[v.se] && out[v.fi]) continue;
//             if (LCT::fdr(v.fi) == LCT::fdr(v.se)) continue;
//             if (in[v.se] || out[v.fi])
//                 if (x() & 1) continue;
//             if (!in[v.se] && !out[v.fi]) tot++;
//             if (in[v.se]) {
//                 LCT::cut(in[v.se], v.se);
//                 canin.insert(v.se);
//                 canout.insert(in[v.se]);
//                 out[in[v.se]] = 0;
//                 in[v.se]      = 0;
//             }
//             if (out[v.fi]) {
//                 LCT::cut(v.fi, out[v.fi]);
//                 canin.insert(out[v.fi]);
//                 canout.insert(v.fi);
//                 in[out[v.fi]] = 0;
//                 out[v.fi]     = 0;
//             }
//             LCT::link(v.fi, v.se);
//             canin.erase(v.se);
//             canout.erase(v.fi);
//             in[v.se]  = v.fi;
//             out[v.fi] = v.se;
//         }
//         if (tot == n - 1) {
//             vi cur;
//             for (int i = 1; i <= n; i++)
//                 if (!in[i]) {
//                     int pl = i;
//                     while (pl) {
//                         cur.pb(pl), pl = out[pl];
//                     }
//                     break;
//                 }
//             return cur;
//         }
//     }
//     // failed to find a path
//     return vi();
// }
// } // namespace hamil
//
// void solve() {
//     INT(n, m, k);
//     VEC(Pii, edges, m);
//     fori(i, m) {
//         edges.push_back({edges[i].second, edges[i].first});
//     }
//     sort(all(edges));
//
//     fori(k) {
//         auto res = hamil::work(n, edges);
//         print(res);
//
//         vec(Pii, remove, 0);
//         fori(i, n - 1) {
//             remove.push_back({res[i], res[i + 1]});
//             remove.push_back({res[i + 1], res[i]});
//         }
//         sort(all(remove));
//         vec(Pii, new_edges, 0);
//         int p = 0;
//         for (auto e : edges) {
//             if (p < remove.size() && e == remove[p]) {
//                 p++;
//                 continue;
//             }
//             new_edges.push_back(e);
//         }
//         edges = new_edges;
//     }
// }
//
// int main() {
// #ifndef INTERACTIVE
//     cin.tie(0)->sync_with_stdio(0);
// #endif
//     // cout << fixed << setprecision(12);
//     int t;
//     t = 1;
//     // cin >> t;
//     while (t--) solve();
//     return 0;
// }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5 9 2
1 3
1 4
1 5
2 3
2 4
2 5
3 5
4 3
5 4

output:

1 3 2 5 4
1 5 3 4 2

result:

ok OK (n = 5, m = 9)

Test #2:

score: 0
Accepted
time: 820ms
memory: 24424kb

input:

10000 200000 8
6318 9948
9588 8985
4252 4927
1146 9347
2276 7434
9612 4436
8319 1837
4428 1043
5976 2759
879 1564
7866 4849
2070 5310
8407 156
7306 7766
9100 1576
1181 6122
7790 7065
3235 8877
5661 9718
1555 743
5479 9755
2601 8190
3318 2067
4084 8193
1050 269
64 5504
3416 5041
7169 197
2158 2523
57...

output:

5618 1638 6410 3506 7988 8047 2916 8696 9733 8714 3792 1317 7275 2473 6939 2092 8151 3129 231 9263 3482 6958 2985 647 7162 4369 2044 9182 3693 4144 9724 483 9369 3643 438 8607 7952 9820 7169 7603 1509 8977 9735 2761 8874 5207 5839 7491 8228 3581 1218 4135 1493 2060 3465 9812 9554 2317 6291 61 3371 8...

result:

ok OK (n = 10000, m = 200000)

Test #3:

score: 0
Accepted
time: 903ms
memory: 24964kb

input:

10000 200000 8
7826 9720
8400 2487
6964 6011
4799 6032
3696 3691
7883 4350
9092 3892
3588 7409
6005 4538
4196 7873
4216 4505
6339 1269
2405 5423
9 7030
8193 7285
5782 2768
5646 4946
4483 6857
3431 9325
4243 488
2435 8371
3067 1462
8592 4932
8581 3147
1394 6751
2499 4977
4806 1190
9652 5059
4075 3454...

output:

8885 2338 3618 2309 4381 9 7937 9328 4025 3376 2200 996 933 5275 8045 4037 2321 2420 3194 9387 8410 2305 8507 3746 2774 2190 7395 7302 3541 4263 3409 1560 5183 5094 2211 3934 7250 522 3379 6784 1159 3650 4202 7162 4851 4189 7560 7093 2202 1032 9073 4468 4998 6942 4763 5231 8241 2290 3358 8610 3082 8...

result:

ok OK (n = 10000, m = 200000)

Test #4:

score: 0
Accepted
time: 774ms
memory: 24452kb

input:

10000 200000 8
6064 4200
2244 5165
648 6303
9246 8103
4187 7801
761 3539
6105 2254
4471 3158
6006 4452
3580 8120
9391 3711
8752 1014
2511 151
800 2285
5388 3282
4704 8712
5372 5509
6988 6976
9314 9056
2225 9256
8567 3853
4135 3386
9688 1467
7287 5856
8107 7114
2385 3663
2991 2969
3746 7352
8828 6735...

output:

6212 5455 1556 6438 8576 1896 363 8285 6095 2708 4878 9158 2483 1683 9882 5922 3953 1607 7720 9401 6672 5722 8204 498 7267 4604 7860 8930 8011 1883 1166 3890 7614 7578 5081 6677 7964 1957 7585 444 2011 1459 4836 4619 6264 5173 3595 8350 4463 2459 5626 565 9360 9081 9717 6396 1729 1718 3218 9124 6849...

result:

ok OK (n = 10000, m = 200000)

Test #5:

score: 0
Accepted
time: 841ms
memory: 24588kb

input:

10000 200000 8
1034 3387
1120 7020
5302 5802
4487 5560
3749 9763
8246 2002
9358 6922
7077 8289
5976 2501
9030 2306
3390 2468
9307 4546
8724 4342
9679 3531
684 9564
7946 3956
6968 8754
748 9234
3310 8909
5500 7046
3874 6201
5806 3962
6604 1672
203 6318
1189 1358
9723 1561
7970 380
9450 7078
6420 2366...

output:

8180 940 2377 3779 5313 4463 1437 4124 895 5163 1465 3736 4717 4508 9954 9024 7099 6322 6584 7 8460 4101 7427 5600 8414 11 2758 4590 5248 8423 8072 4018 5981 9387 3977 2699 1827 8274 1995 1451 4920 6777 7907 9250 7639 9036 478 8548 9089 205 7754 4129 1851 5613 9748 495 1378 4997 41 1822 5287 102 702...

result:

ok OK (n = 10000, m = 200000)

Test #6:

score: 0
Accepted
time: 828ms
memory: 24276kb

input:

10000 200000 8
2734 7281
5027 8050
927 4507
523 8404
2382 9578
337 9740
8851 7897
1407 2803
5918 8684
547 430
6215 775
8004 1864
1045 7995
6645 767
4082 6133
5510 8499
433 4681
5763 3631
5419 8885
4068 3859
8356 5416
8078 3190
9342 5547
7329 4533
639 9483
4511 8673
9744 3422
6765 4236
6849 346
2288 ...

output:

1002 2296 8207 4347 3056 1727 4537 806 552 7037 4894 7213 5552 4275 5982 8551 559 7852 821 8119 7736 4138 7144 9735 6104 5709 7853 3432 5098 7893 370 5183 2777 3592 818 9320 881 2644 1413 3552 3719 555 3148 3927 5880 2473 1983 1726 8140 5558 6078 6615 5616 6966 3115 270 1405 6315 8938 6489 6135 8223...

result:

ok OK (n = 10000, m = 200000)

Test #7:

score: 0
Accepted
time: 829ms
memory: 24724kb

input:

10000 200000 8
1166 5882
3966 8257
7523 2420
7353 6633
87 7247
7035 6751
4585 5179
7460 6699
5829 3002
8131 2493
7864 8632
4845 2969
9472 1110
1698 3993
5582 2988
7395 2341
5768 3290
2034 167
5642 8983
7929 9694
2014 1497
952 1069
7900 3092
8663 502
6458 1489
6751 4998
8312 2094
5690 8825
115 676
62...

output:

8737 5698 8062 3031 1340 223 3525 1490 3513 1515 5065 5987 2759 4760 2148 9759 3743 9053 5980 5225 9989 6714 9344 8183 5587 3234 9990 205 8396 3457 9586 6202 4056 2269 3902 4659 6051 9727 9173 1694 104 1292 9551 8844 7002 580 1336 2109 7098 2703 904 8008 9924 2022 7717 6399 2911 1001 676 1425 1057 7...

result:

ok OK (n = 10000, m = 200000)

Test #8:

score: 0
Accepted
time: 854ms
memory: 24404kb

input:

10000 200000 8
6328 9191
7937 7640
5090 9539
4977 248
6863 2768
8341 3037
6559 8768
5237 9978
5712 5454
1782 8494
8338 6040
9828 7861
4008 3687
4839 3210
5183 130
3601 5482
2972 4581
9560 8842
3978 9205
7084 4551
4847 4445
4428 7601
2280 4306
4207 4225
8646 7376
6443 536
3674 6398
6226 847
6219 3356...

output:

6671 8088 1377 5332 9521 8035 43 3768 8401 6471 9054 6195 9430 7035 938 8589 1178 9840 4775 5474 6129 4974 8617 8955 1069 1789 1689 4235 4066 8022 2088 912 1810 1584 2536 5018 1229 1106 7338 943 7520 9185 2464 7351 4906 1232 3049 4870 9298 140 5707 4973 8404 4507 6294 2063 2807 9454 2183 9337 6190 8...

result:

ok OK (n = 10000, m = 200000)

Test #9:

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

input:

10000 200000 8
8222 7206
6939 6199
3627 5866
3396 9250
2710 6141
4253 8597
4773 8663
4738 2640
5564 6042
1500 8433
7637 2998
2954 6540
4650 5727
6068 8417
2885 7557
4129 7922
2046 8554
8343 9655
428 9550
1531 8431
6855 4259
8506 2784
2481 9190
3961 5701
7203 7144
3585 5286
5830 6332
8372 300
5160 83...

output:

736 8844 8310 6853 381 3737 3301 7197 7256 9567 8099 7325 8035 8552 1671 7435 911 8860 1588 1026 6154 7102 8148 6699 7093 6920 7463 2781 3820 908 8036 5127 5301 5192 1 1202 126 5509 4950 8918 8046 8670 893 3576 8599 8525 2671 1432 579 592 5888 6280 4065 7965 1751 9929 2979 461 6677 3774 1958 4371 75...

result:

ok OK (n = 10000, m = 200000)

Test #10:

score: 0
Accepted
time: 810ms
memory: 24276kb

input:

10000 200000 8
6846 9929
974 3935
3136 1399
2610 3637
7628 7368
4772 3431
9227 4865
5962 4684
5388 4763
7285 2311
5760 9506
4223 9005
1401 7229
5384 9615
8690 5272
8977 9661
2990 5210
8380 2608
4990 18
1272 1334
8039 940
3186 6620
8503 7744
7924 4930
2128 794
8179 9250
4781 1898
2129 7185
6939 5764
...

output:

6352 3500 9484 9954 9176 7802 3577 8479 1202 303 5919 3225 968 3073 4797 5722 2530 7486 1114 9788 8958 9218 4812 3171 6721 7767 8453 575 5568 9957 1422 7761 1477 1309 4153 5808 9733 6543 5618 9468 2119 2127 3425 5978 9233 1412 3920 6197 4542 8458 5042 7319 84 5130 1680 2786 4272 8773 5559 3724 1712 ...

result:

ok OK (n = 10000, m = 200000)

Test #11:

score: 0
Accepted
time: 855ms
memory: 24564kb

input:

10000 200000 8
2202 7359
40 846
3615 6140
2618 3411
1618 6447
9897 7539
9921 7374
8909 6111
5182 1620
9136 127
2709 5565
3635 5257
4258 8192
2787 6804
2596 3272
8146 700
5803 4547
9673 7699
7666 608
6306 3259
8398 4487
8468 9107
347 9968
6096 1913
3422 8324
225 2426
526 3095
7496 1502
1556 5493
1173...

output:

490 8199 789 1707 7108 3238 9425 2625 3841 4979 183 6984 1910 1256 471 8142 4382 6642 1941 3947 6683 1025 3506 7552 9692 5552 5997 7297 6222 8284 3479 9916 9757 2399 363 7595 524 5790 1900 662 4475 5261 6188 4312 6728 6018 5250 3908 4645 5927 6648 6159 3777 8324 4188 705 4893 8918 7636 6384 9611 305...

result:

ok OK (n = 10000, m = 200000)

Test #12:

score: 0
Accepted
time: 847ms
memory: 24496kb

input:

10000 200000 8
4288 9496
4137 6934
5065 87
3420 8570
4679 3379
9630 921
6856 6189
3580 6921
4946 6611
7054 1882
8482 1173
1189 5296
3223 8618
8278 9983
4603 1559
1637 1037
487 6567
2222 4930
8456 1322
6633 4206
7932 4900
4352 246
8011 5862
8478 6650
1085 9736
9721 4816
3066 9922
4474 3251
9010 7571
...

output:

1798 2599 5082 845 6433 7747 5919 2220 2438 1261 4977 7014 5243 5619 2545 2610 9206 2602 6205 5050 6882 7579 8469 7854 1702 2894 900 4921 2836 4292 3246 5753 4035 7259 4339 2325 9637 8339 3215 6901 4886 1235 3834 4655 5016 1559 5603 3836 5500 525 1451 5674 4072 8957 5036 6250 5790 5865 9043 3916 182...

result:

ok OK (n = 10000, m = 200000)

Test #13:

score: 0
Accepted
time: 828ms
memory: 24352kb

input:

10000 200000 8
3105 6341
3267 2198
7486 3241
5017 9116
6811 8164
3970 3578
30 1311
9975 7113
4681 9737
1039 7576
3081 6333
6886 9121
8295 8507
1857 9152
4712 132
9449 674
7039 1268
6027 4299
7358 2158
2254 4176
6642 2180
838 38
1497 5426
5069 9140
5117 5029
6669 6418
2399 2381
3063 2432
9302 1999
61...

output:

8064 9161 8376 1835 2460 8164 875 3230 1106 8588 8429 2435 2488 9471 2396 6782 4092 5471 5724 7894 6561 5511 3849 3186 1660 4865 785 6084 2839 2256 3632 2050 6754 5111 9218 3607 2476 4422 7633 4032 2582 6545 7590 3123 623 6342 6439 8120 3775 781 6836 5615 5962 121 2400 1129 35 2257 4660 5711 8151 41...

result:

ok OK (n = 10000, m = 200000)

Test #14:

score: 0
Accepted
time: 874ms
memory: 24216kb

input:

10000 200000 8
8654 7892
7428 6639
878 5603
7408 5048
8014 802
2916 5509
9445 2740
8092 6688
4386 998
1091 7207
6504 1042
726 6733
9475 7857
3523 4312
2923 8991
1582 9609
5462 8652
1087 5808
4374 3117
3167 3169
4526 6326
7925 8481
804 8660
5869 9384
5517 4202
1069 7233
8527 470
3262 9045
2431 8777
5...

output:

4281 9029 3391 908 4117 176 2565 8170 627 5357 6109 3746 6389 8713 5299 1571 3505 9163 5895 6494 6633 7954 9613 362 1317 3102 5140 8295 6956 7752 8937 3857 4288 6657 6068 3415 7661 1115 9275 2280 5749 9831 5972 3683 5899 4095 5416 9474 7056 8493 9477 5445 7400 9480 4222 5128 4526 2063 851 9392 1282 ...

result:

ok OK (n = 10000, m = 200000)

Test #15:

score: 0
Accepted
time: 815ms
memory: 25072kb

input:

10000 200000 8
933 4151
6621 255
5240 7171
594 6365
8289 1293
6469 6714
5100 476
7934 5646
4062 393
7210 778
8752 5302
2709 8132
6762 6670
3277 5462
9235 8137
8036 7844
5754 8718
7402 9455
9503 4199
9374 1184
1587 7339
5615 5576
5932 5563
879 7381
2286 7257
2919 7262
1450 4191
5071 3090
8398 7904
28...

output:

2736 4971 188 6383 3899 6664 9743 2577 6876 2543 3255 2232 3416 3918 3928 8708 6623 3865 835 7020 5419 1593 1508 3401 3035 6042 8005 4884 479 6985 8921 7427 5408 1572 9030 6340 1166 8178 9296 756 4510 9354 6995 9210 3314 9562 2116 9488 7845 6020 6592 4814 8053 4074 7416 9436 2930 7584 3418 5116 569 ...

result:

ok OK (n = 10000, m = 200000)

Test #16:

score: 0
Accepted
time: 833ms
memory: 25152kb

input:

10000 200000 8
9943 5117
846 3048
573 7946
4574 3069
7634 9636
4629 7193
6995 4518
9499 3986
3709 7923
9395 8286
9824 9113
2834 3317
156 4944
1118 2603
3649 7569
8811 5378
7915 1466
4973 5241
2746 5405
874 8222
7822 5218
3907 1322
6881 6137
98 3131
5423 4193
2221 6503
1167 3542
8491 4566
7202 9381
8...

output:

5164 3750 3910 2791 8371 7566 8218 9540 2249 7989 8574 6051 1832 4721 8894 5312 6422 1608 3164 413 6972 6735 7577 3444 924 5146 5841 4382 104 7341 4060 8555 8086 1129 5718 6783 3931 8440 195 4111 7810 7767 1981 3581 796 5775 3909 1786 6473 8929 9368 7751 2064 9631 4513 7303 1472 6525 6726 9288 9737 ...

result:

ok OK (n = 10000, m = 200000)

Test #17:

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

input:

10000 200000 8
5685 790
102 5017
6877 7928
9348 5159
6051 5832
7396 6946
5130 4867
2787 1709
3325 3587
7648 9733
9722 2473
1102 2289
9658 2681
7046 5735
6164 7288
3907 2211
1947 6896
3800 3166
4102 6733
7667 4282
3233 9964
2800 5721
3651 380
3526 6635
4930 5010
8974 4957
7678 8525
3522 3474
8844 320...

output:

4351 7753 8809 2776 3348 4090 7159 4042 3514 80 3531 6679 2489 9600 7964 5193 1982 7362 8813 9139 9419 2624 1853 8921 4069 3854 6611 3721 8471 1077 3835 1803 3014 440 4795 6292 6309 6034 5456 2572 348 9155 8357 1804 2207 5420 2662 2755 6020 1819 167 1609 1856 3436 8004 5848 5548 1608 9057 101 9103 1...

result:

ok OK (n = 10000, m = 200000)

Test #18:

score: 0
Accepted
time: 865ms
memory: 24236kb

input:

10000 200000 8
8157 1170
4391 6162
4152 7117
4917 2635
3540 9882
4770 5974
9506 1523
7799 8814
2913 7387
1967 5119
8444 5384
7513 5048
5267 9880
1062 4857
6781 7292
3324 8343
7848 5008
3882 3230
3571 8184
9753 9364
7819 1576
2296 8772
6243 8293
1164 7893
805 9708
3179 2624
983 9138
163 9815
3323 938...

output:

4960 603 1312 3984 9549 1536 6639 1172 9924 7956 9777 4602 7500 8701 5057 9578 3030 3598 5993 6138 9747 3575 3855 2963 6082 5777 5091 1983 6489 7368 2097 9337 4048 7875 2543 2286 3351 9598 721 4816 4877 897 1685 9249 1639 294 6497 3964 9142 3640 829 1480 2754 6172 9823 4997 7350 8282 5331 129 4785 7...

result:

ok OK (n = 10000, m = 200000)

Test #19:

score: 0
Accepted
time: 828ms
memory: 24704kb

input:

10000 200000 8
7360 6258
3711 6484
2398 5513
1280 5497
99 1783
6751 4276
121 4485
4535 5302
2471 9321
2353 4443
5992 7845
2067 1594
6983 6541
3166 9969
5499 7584
7063 3774
5618 5802
5220 5433
1153 9758
7132 3469
1580 55
2393 474
4655 9876
3012 6904
3048 8287
4835 9504
1083 5383
8414 3587
640 7909
12...

output:

5949 2075 5236 3778 9651 6326 5902 9477 9071 5820 640 2485 8306 1100 9786 4867 3691 3598 6342 9513 3042 5699 8012 6957 4222 3060 1186 4055 4112 229 534 1784 5085 4377 3154 6122 3786 1650 973 5149 6466 8555 2527 9855 7047 2557 4378 1386 45 3022 8443 386 9722 3063 7464 2631 7507 6236 12 7037 6599 3269...

result:

ok OK (n = 10000, m = 200000)

Test #20:

score: 0
Accepted
time: 827ms
memory: 24216kb

input:

10000 200000 8
3294 6053
8062 5981
1615 3116
8438 3745
5730 1538
3338 1852
6977 3755
2994 1173
1999 9389
8805 7705
2364 9857
4763 1926
4807 2665
3357 1072
2320 8161
5122 8504
5259 9278
7813 9775
6849 1454
9805 6597
4517 5400
3093 829
8889 5129
9068 3669
1661 747
3942 5597
7977 7258
8276 4791
794 878...

output:

7728 5833 2040 6775 5107 8296 9344 9070 9095 7320 4981 7254 1489 6209 8931 3776 3891 896 4614 5090 275 4078 7686 8706 5309 9257 9959 8693 9814 4812 9180 7411 6203 2492 342 4350 2244 7951 7676 8612 3454 9438 4674 4765 8473 4892 6561 9721 5999 9766 3308 1990 1525 6206 5650 6622 684 2247 4148 8391 5523...

result:

ok OK (n = 10000, m = 200000)

Test #21:

score: 0
Accepted
time: 829ms
memory: 25172kb

input:

10000 200000 8
5960 554
7446 4655
1802 9926
6390 7380
432 9145
4532 8702
73 9330
3176 6426
1498 7593
1325 4906
7561 1419
5603 6045
8738 8250
1636 8165
7241 9025
7503 2533
6769 5436
1662 6255
658 3274
7771 8747
6629 7611
4394 9835
8944 4052
9334 8187
6642 7088
500 903
1665 4765
9749 3427
3786 2010
29...

output:

466 608 463 5928 3990 1605 2541 3876 5735 6974 445 8550 2050 3188 4249 7635 9304 4465 78 3371 1722 5561 2597 2882 6333 5364 8495 2555 8166 7405 2325 9606 5052 908 3216 9584 8753 7012 7517 3606 7575 5963 4126 1663 5810 2989 8645 1123 2712 3899 6683 1400 7286 3498 5568 3419 6307 3790 5146 4110 6326 82...

result:

ok OK (n = 10000, m = 200000)

Test #22:

score: 0
Accepted
time: 781ms
memory: 24224kb

input:

10000 200000 8
5356 9763
1861 2505
2960 5943
5137 6400
4205 4606
334 4826
9409 1213
5082 1062
968 3931
9911 6045
1583 2531
4585 3950
8777 3298
8002 1249
265 175
4205 5862
148 4277
6766 4875
2580 5217
1030 9919
7916 6689
6297 7493
4820 6644
3810 458
7992 7311
4510 5422
2148 7902
2832 9495
9616 7585
5...

output:

9652 1141 1092 9723 5425 3146 421 8093 9916 2126 1109 8319 6151 6185 8630 9569 5848 860 4067 4068 4273 8261 3587 8025 7791 2750 5367 6902 4591 7358 3271 3653 4560 5474 21 1668 2936 1047 3978 4672 2048 7620 8011 9700 4203 1259 573 5194 2350 4849 7336 6922 4683 2738 2787 5143 9687 3984 2252 6945 1295 ...

result:

ok OK (n = 10000, m = 200000)

Test #23:

score: 0
Accepted
time: 884ms
memory: 24756kb

input:

10000 200000 8
1483 3680
1308 9532
5089 1166
4678 806
7049 7919
742 225
4985 9402
8711 5081
408 8403
4565 1123
4429 3193
1709 5643
4923 7808
2456 324
1389 1611
5228 8489
5397 5799
3126 5633
2616 7282
9582 114
8379 2634
8802 3804
6517 2907
2495 483
5711 1414
5972 9154
9425 6671
7526 2994
8283 5509
64...

output:

6728 8975 4244 765 4963 9166 225 5973 7219 6314 550 9623 3386 5410 9391 5754 3080 8529 3879 1712 9889 5437 4089 5261 678 2124 2853 2205 9543 4792 6702 1144 9430 8000 7086 52 5714 7670 2683 7856 2136 6537 1723 6990 9976 3705 7774 8957 703 5659 90 2450 9397 5678 5992 5065 8065 8672 1793 2865 9700 2259...

result:

ok OK (n = 10000, m = 200000)

Test #24:

score: 0
Accepted
time: 864ms
memory: 24188kb

input:

10000 200000 8
4341 2303
5786 5734
8189 5597
5013 599
8965 9085
5757 4898
6801 3898
4064 8482
9819 1010
5285 139
6101 3406
6977 1121
7176 1780
4997 5389
616 3334
572 416
2516 4
742 8531
765 9471
3427 9332
8017 5445
1909 8766
4035 2839
5389 8262
9798 9399
4884 2098
3496 1070
3830 3926
9787 5783
4993 ...

output:

7920 7063 4614 3616 2338 4774 2157 4443 8860 6919 8538 2537 347 4983 8061 3764 4418 390 3424 6865 7242 7509 1503 5921 188 6621 6088 5235 8650 9598 2413 2958 8369 2774 901 6555 3604 636 9214 21 1890 543 6268 9697 9353 8314 130 6895 8459 1615 588 6491 6228 7369 500 7257 5708 8034 6393 1845 1650 1420 3...

result:

ok OK (n = 10000, m = 200000)

Test #25:

score: 0
Accepted
time: 803ms
memory: 24352kb

input:

10000 200000 8
3930 5634
5297 1113
2260 9235
6143 5777
9951 8103
5378 8844
4858 4701
1141 1266
9200 1752
2072 3094
6597 3169
5537 5214
5626 6444
7944 5343
237 1641
1505 6890
9613 3567
7027 1782
2566 7572
6830 5122
5618 2380
7375 6441
2493 3794
254 1264
1248 4256
4362 1100
1744 2290
4130 8407
1501 86...

output:

1297 7463 1237 6538 8652 2129 5399 3614 7091 1166 193 9315 2448 8015 4341 2664 3740 116 7966 8089 5294 6878 5218 1723 4020 6695 3897 4138 8786 4034 1768 7548 5812 9663 4424 1805 6488 9355 5928 6285 2588 8099 7139 170 6882 8715 2281 8396 3720 8855 7511 88 7960 838 4327 8085 6845 9839 1906 3034 5942 7...

result:

ok OK (n = 10000, m = 200000)

Test #26:

score: 0
Accepted
time: 920ms
memory: 24500kb

input:

10000 200000 8
250 3672
9839 5668
7301 2079
8067 6342
9 4975
9607 2066
9155 1811
9941 3432
8551 629
4925 9987
5919 2483
1940 3439
5 8111
4342 3490
3374 7638
4223 2166
2363 6459
9739 743
1402 4217
6997 4834
4819 1666
9929 4646
6536 3713
3806 7080
7079 7011
5063 5627
2022 6762
1269 8085
1309 3380
5929...

output:

798 7220 2185 6581 8920 1879 2728 5307 7792 3715 3290 8785 5373 4843 7592 1808 5162 8687 5698 376 1101 6834 6564 4858 538 5191 9212 8267 7444 3286 8362 3171 7694 7283 6266 2941 6748 7045 5788 6304 5258 3452 3530 1711 1934 7836 8886 1790 8152 7671 6417 3267 7597 9714 2110 8426 9552 3626 7887 4907 302...

result:

ok OK (n = 10000, m = 200000)

Test #27:

score: 0
Accepted
time: 835ms
memory: 24516kb

input:

10000 200000 8
3302 6417
9413 9399
3313 4131
786 2293
9139 9699
8443 4561
9691 5227
464 4981
7873 7640
3846 819
4065 1347
1636 278
581 470
1146 6526
6905 220
2531 1990
5091 8710
1122 57
3891 6774
6722 1119
1982 5076
4842 5563
1517 4655
9328 8119
273 6638
6329 6210
6476 8054
2405 1312
1326 703
8278 3...

output:

7398 171 3490 2929 6124 7346 2817 267 7867 2932 6961 6355 4977 295 5830 6131 774 7625 5831 8334 3401 2889 6032 2218 6315 5151 7856 5931 8977 3189 1485 7696 2681 9042 9144 7 8318 6745 9297 5150 6476 4640 7595 8741 6768 7627 3772 8630 7695 9480 5711 7639 4065 1347 9633 1475 3516 924 1540 2289 1148 598...

result:

ok OK (n = 10000, m = 200000)

Test #28:

score: 0
Accepted
time: 858ms
memory: 24652kb

input:

10000 200000 8
3084 3869
4018 2306
296 5389
4299 3629
7339 2276
1885 6331
6469 4950
2711 5913
7166 2786
8833 5589
1036 9761
9475 904
7264 2290
6037 5553
8538 3088
5159 1113
9688 3643
3759 1510
4493 9454
1740 6427
8322 5352
357 5133
2320 9267
9060 6912
9835 147
5047 6007
7724 4978
5151 1971
4181 376
...

output:

6535 7079 2797 4502 8076 8168 9437 471 829 4747 225 256 1922 7032 3293 6638 4332 5725 651 2372 4315 8111 1631 5664 8453 8379 2362 3317 8592 4191 4858 629 2241 381 8534 7312 7403 3361 8809 3155 1389 8268 4935 5548 2464 506 9274 8613 210 8764 3211 2905 745 9874 7560 3670 5216 3424 5327 8108 4590 6882 ...

result:

ok OK (n = 10000, m = 200000)

Test #29:

score: 0
Accepted
time: 863ms
memory: 24176kb

input:

10000 200000 8
9597 6028
3656 4390
8250 5855
8607 352
4611 2706
9934 7374
9486 979
6681 6227
6429 6067
9887 4297
6831 7725
5456 5316
54 3573
9016 570
8272 6242
2109 9535
6155 1258
7653 5102
3208 2257
2051 757
3836 2495
6474 3355
8945 7549
3001 3458
5766 7537
1216 5016
5767 7532
9508 62
9873 2398
673...

output:

1286 8668 5737 5446 1410 8587 8449 8470 3338 63 4454 8053 8438 6219 951 6207 5489 8562 3003 4525 6871 7216 9850 5708 3570 5516 8821 9891 7667 3143 8026 5120 8720 7923 1894 1929 8941 1848 7123 1611 1679 7929 4170 7891 9796 5043 6902 6335 6737 5309 5238 3539 5483 8785 8154 6616 8908 8582 5534 3914 388...

result:

ok OK (n = 10000, m = 200000)

Test #30:

score: 0
Accepted
time: 851ms
memory: 24380kb

input:

10000 200000 8
2841 2895
8325 5650
7175 5527
3709 2461
954 989
2590 7692
8743 3316
2375 5924
5663 7482
7008 6944
1452 5240
9580 3515
8952 4318
82 1578
6108 9683
3380 7256
4492 1555
2801 833
37 5183
7656 4109
8526 6505
3193 228
1390 9500
1152 7758
8065 8808
4837 3239
605 5717
5475 5585
8403 6770
2849...

output:

1223 9749 5494 3864 5875 3007 98 1870 109 9757 1789 2375 5924 3324 5724 2106 5295 7444 6048 9615 5000 8078 7752 882 8594 3548 9273 4714 8168 8878 8733 5909 2686 8286 9286 8548 9316 2788 8688 7460 4215 3603 4914 9519 4182 8304 1183 8179 3470 3023 4124 7739 1337 7081 6591 6084 4084 255 9370 3169 9431 ...

result:

ok OK (n = 10000, m = 200000)

Test #31:

score: 0
Accepted
time: 841ms
memory: 25032kb

input:

10000 200000 8
2816 4469
8026 6086
7071 4407
9605 9956
6368 7125
9853 7284
4241 1959
9793 5004
4867 7032
196 3530
4897 2305
1847 5501
3957 4526
9236 8577
2046 3410
8972 4276
4699 4534
9206 8703
4979 8232
8553 6484
2391 7381
513 5754
9656 5122
3511 9811
6734 3960
5908 674
2236 9534
3053 8540
9771 349...

output:

3686 4645 3348 7309 8635 1906 6467 6637 9305 5712 9362 2732 9689 3831 2805 2458 3812 5525 1484 4875 1363 82 2713 9198 1903 7267 3750 3086 6112 6675 6735 694 9549 5675 6784 6492 7615 3216 4301 7568 8544 4284 1337 6315 2181 1473 3894 5125 7486 2518 310 3735 9341 8989 6653 5338 6274 3006 3368 6567 9140...

result:

ok OK (n = 10000, m = 200000)

Extra Test:

score: 0
Extra Test Passed