QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#434005#8787. Unusual Caseucup-team159#AC ✓862ms28820kbC++2042.2kb2024-06-08 14:10:522024-06-08 14:10:55

Judging History

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

  • [2024-06-08 14:10:55]
  • 评测
  • 测评结果:AC
  • 用时:862ms
  • 内存:28820kb
  • [2024-06-08 14:10:52]
  • 提交

answer

#line 1 "G/main.cpp"
// #define NDEBUG

#include <unordered_set>
#include <random>

#line 2 "/home/vscode/yosupo-library/src/yosupo/hashmap.hpp"

#include <iterator>
#include <utility>
#include <vector>

#line 2 "/home/vscode/yosupo-library/src/yosupo/hash.hpp"

#include <array>
#include <cstdint>
#include <tuple>
#line 7 "/home/vscode/yosupo-library/src/yosupo/hash.hpp"
#include <set>
#include <map>

#line 2 "/home/vscode/yosupo-library/src/yosupo/internal_type_traits.hpp"

#include <cassert>
#include <type_traits>

namespace yosupo {

namespace internal {

template <class T>
using is_signed_int128 =
    typename std::conditional<std::is_same<T, __int128_t>::value ||
                                  std::is_same<T, __int128>::value,
                              std::true_type,
                              std::false_type>::type;

template <class T>
using is_unsigned_int128 =
    typename std::conditional<std::is_same<T, __uint128_t>::value ||
                                  std::is_same<T, unsigned __int128>::value,
                              std::true_type,
                              std::false_type>::type;

template <class T>
using make_unsigned_int128 =
    typename std::conditional<std::is_same<T, __int128_t>::value,
                              __uint128_t,
                              unsigned __int128>;

template <class T>
using is_integral =
    typename std::conditional<std::is_integral<T>::value ||
                                  internal::is_signed_int128<T>::value ||
                                  internal::is_unsigned_int128<T>::value,
                              std::true_type,
                              std::false_type>::type;

template <class T>
using is_signed_int = typename std::conditional<(is_integral<T>::value &&
                                                 std::is_signed<T>::value) ||
                                                    is_signed_int128<T>::value,
                                                std::true_type,
                                                std::false_type>::type;

template <class T>
using is_unsigned_int =
    typename std::conditional<(is_integral<T>::value &&
                               std::is_unsigned<T>::value) ||
                                  is_unsigned_int128<T>::value,
                              std::true_type,
                              std::false_type>::type;

template <class T>
using to_unsigned = typename std::conditional<
    is_signed_int128<T>::value,
    make_unsigned_int128<T>,
    typename std::conditional<std::is_signed<T>::value,
                              std::make_unsigned<T>,
                              std::common_type<T>>::type>::type;

template <class T>
using is_integral_t = std::enable_if_t<is_integral<T>::value>;

template <class T>
using is_signed_int_t = std::enable_if_t<is_signed_int<T>::value>;

template <class T>
using is_unsigned_int_t = std::enable_if_t<is_unsigned_int<T>::value>;

template <class T> using to_unsigned_t = typename to_unsigned<T>::type;

}  // namespace internal

}  // namespace yosupo
#line 2 "/home/vscode/yosupo-library/src/yosupo/random.hpp"

#line 4 "/home/vscode/yosupo-library/src/yosupo/random.hpp"
#include <bit>
#line 6 "/home/vscode/yosupo-library/src/yosupo/random.hpp"
#include <chrono>
#line 9 "/home/vscode/yosupo-library/src/yosupo/random.hpp"

namespace yosupo {

struct Xoshiro256StarStar {
  public:
    using result_type = uint64_t;
    Xoshiro256StarStar() : Xoshiro256StarStar(0) {}
    explicit Xoshiro256StarStar(uint64_t seed) {
        // use splitmix64
        // Reference: http://xoshiro.di.unimi.it/splitmix64.c
        for (int i = 0; i < 4; i++) {
            uint64_t z = (seed += 0x9e3779b97f4a7c15);
            z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;
            z = (z ^ (z >> 27)) * 0x94d049bb133111eb;
            s[i] = z ^ (z >> 31);
        }
    }

    static constexpr result_type min() { return 0; }
    static constexpr result_type max() { return -1; }

    result_type operator()() {
        const uint64_t result_starstar = rotl(s[1] * 5, 7) * 9;

        const uint64_t t = s[1] << 17;

        s[2] ^= s[0];
        s[3] ^= s[1];
        s[1] ^= s[2];
        s[0] ^= s[3];

        s[2] ^= t;

        s[3] = rotl(s[3], 45);

        return result_starstar;
    }

  private:
    // Use xoshiro256**
    // Refereces: http://xoshiro.di.unimi.it/xoshiro256starstar.c
    static uint64_t rotl(const uint64_t x, int k) {
        return (x << k) | (x >> (64 - k));
    }

    std::array<uint64_t, 4> s;
};

namespace internal {

// random choice from [0, upper]
template <class G> uint64_t uniform(uint64_t upper, G& gen) {
    static_assert(std::is_same<uint64_t, typename G::result_type>::value, "");
    static_assert(G::min() == 0, "");
    static_assert(G::max() == uint64_t(-1), "");
    if (!(upper & (upper + 1))) {
        // b = 00..0011..11
        return gen() & upper;
    }
    int log = 63 - std::countl_zero(upper);
    uint64_t mask = (log == 63) ? ~0ULL : (1ULL << (log + 1)) - 1;
    while (true) {
        uint64_t r = gen() & mask;
        if (r <= upper) return r;
    }
}

}  // namespace internal

inline Xoshiro256StarStar& global_gen() {
    static Xoshiro256StarStar gen(
        std::chrono::steady_clock::now().time_since_epoch().count());
    return gen;
}

template <class T, class G> T uniform(T lower, T upper, G& gen) {
    return T(lower + internal::uniform(uint64_t(upper) - uint64_t(lower), gen));
}
template <class T> T uniform(T lower, T upper) {
    return uniform(lower, upper, global_gen());
}

template <class G> bool uniform_bool(G& gen) {
    return internal::uniform(1, gen) == 1;
}
inline bool uniform_bool() { return uniform_bool(global_gen()); }

template <class T, class G>
std::pair<T, T> uniform_pair(T lower, T upper, G& gen) {
    assert(upper - lower >= 1);
    T a, b;
    do {
        a = uniform(lower, upper, gen);
        b = uniform(lower, upper, gen);
    } while (a == b);
    if (a > b) std::swap(a, b);
    return {a, b};
}
template <class T> std::pair<T, T> uniform_pair(T lower, T upper) {
    return uniform_pair(lower, upper, global_gen());
}

}  // namespace yosupo
#line 2 "/home/vscode/yosupo-library/src/yosupo/bitvector.hpp"

#line 5 "/home/vscode/yosupo-library/src/yosupo/bitvector.hpp"
#include <algorithm>
#line 7 "/home/vscode/yosupo-library/src/yosupo/bitvector.hpp"

namespace yosupo {

struct BitVec {
  public:
    BitVec() : BitVec(0) {}
    explicit BitVec(size_t _n) : n(_n), d((n + B - 1) / B) {}
    size_t size() const { return n; }

    void reset() { fill(d.begin(), d.end(), 0); }
    void reset(size_t i) { set(i, false); }
    BitVec& set() {
        for (auto& x : d) {
            x = -1ULL;
        }
        erase_last();
        return *this;
    }
    BitVec& set(size_t i, bool f = true) {
        assert(i < n);
        if (f) {
            d[i / B] |= 1ULL << (i % B);
        } else {
            d[i / B] &= ~(1ULL << (i % B));
        }
        return *this;
    }
    bool test(size_t i) const {
        assert(i < n);
        return (d[i / B] >> (i % B) & 1) != 0;
    }

    size_t count() const {
        size_t sm = 0;
        for (auto x : d) sm += std::popcount(x);
        return sm;
    }
    bool any() const {
        for (auto& x : d)
            if (x) return true;
        return false;
    }
    int find_first() const {
        auto m = d.size();
        for (size_t i = 0; i < m; i++) {
            if (d[i]) return int(i * B + std::countr_zero(d[i]));
        }
        return int(size());
    }

    BitVec& flip() {
        op1(std::bit_not<unsigned long long>());
        if (n % B) d.back() &= ~(-1ULL << (n % B));
        return *this;
    }
    BitVec& flip(size_t i) {
        return set(i, !test(i));
    }

    // operators
    BitVec& operator~() const { return BitVec(*this).flip(); }
    BitVec& operator&=(const BitVec& r) {
        return op2(r, std::bit_and<unsigned long long>());
    }
    BitVec& operator|=(const BitVec& r) {
        return op2(r, std::bit_or<unsigned long long>());
    }
    BitVec& operator^=(const BitVec& r) {
        return op2(r, std::bit_xor<unsigned long long>());
    }
    BitVec& operator<<=(const size_t& s) {
        auto block = s / B, rem = s % B;
        if (d.size() <= block) {
            reset();
            return *this;
        }
        for (size_t i = d.size() - 1; i > block; i--) {
            if (rem == 0)
                d[i] = d[i - block];
            else
                d[i] = d[i - block] << rem | d[i - block - 1] >> (B - rem);
        }
        d[block] = d[0] << rem;
        erase_last();
        fill(d.begin(), d.begin() + block, 0ULL);
        return *this;
    }
    BitVec& operator>>=(const size_t& s) {
        auto block = s / B, rem = s % B;
        if (d.size() <= block) {
            reset();
            return *this;
        }
        for (size_t i = 0; i < d.size() - block - 1; i++) {
            if (rem == 0)
                d[i] = d[i + block];
            else
                d[i] = d[i + block + 1] << (B - rem) | d[i + block] >> rem;
        }
        d[d.size() - block - 1] = d.back() >> rem;
        fill(d.begin() + d.size() - block, d.end(), 0ULL);
        return *this;
    }
    BitVec operator&(const BitVec& r) const { return BitVec(*this) &= r; }
    BitVec operator|(const BitVec& r) const { return BitVec(*this) |= r; }
    BitVec operator^(const BitVec& r) const { return BitVec(*this) ^= r; }
    BitVec operator<<(const size_t& s) const { return BitVec(*this) <<= s; }
    BitVec operator>>(const size_t& s) const { return BitVec(*this) >>= s; }
    bool operator==(const BitVec& r) const { return d == r.d; }
    bool operator!=(const BitVec& r) const { return !(d == r.d); }

    void push_back(bool f) {
        if (n % B == 0) d.push_back(0);
        set(n, f);
        n++;
    }

    BitVec substr(size_t st, size_t le) const {
        assert(st + le <= n);
        BitVec res(le);
        size_t i = 0;
        while (i < le) {
            res.d[i / B] |= d[(st + i) / B] >> ((st + i) % B) << (i % B);
            i += std::min(B - i % B, B - (st + i) % B);
        }
        res.erase_last();
        return res;
    }
    bool substr_match(size_t st, const BitVec& pat) const {
        size_t le = pat.size();
        assert(st + le <= n);
        size_t i = 0;
        while (i < le) {
            size_t u = std::min({le - i, B - i % B, B - (st + i) % B});
            unsigned long long z = pat.d[i / B] >> (i % B) ^ d[(st + i) / B] >> ((st + i) % B);
            if (z << (B - u)) return false;
            i += u;
        }
        return true;
    }

    const std::vector<unsigned long long>& raw_data() const { return d; }

  private:
    static constexpr size_t B = 64;
    size_t n;
    std::vector<unsigned long long> d;
    void erase_last() {
        if (n % B) d.back() &= (unsigned long long)(-1) >> (B - n % B);
    }

    template <class OP> BitVec& op1(OP op) {
        for (auto& x : d) x = op(x);
        return *this;
    }

    template <class OP> BitVec& op2(const BitVec& r, OP op) {
        assert(n == r.n);
        for (size_t i = 0; i < d.size(); i++) d[i] = op(d[i], r.d[i]);
        return *this;
    }
};

namespace internal {

// bitvec
template <class H> auto update(const H& h, const BitVec& bs) {
    return update(h, bs.raw_data());
}

}  // namespace internal

}  // namespace yosupo
#line 13 "/home/vscode/yosupo-library/src/yosupo/hash.hpp"

namespace yosupo {

namespace internal {

constexpr int THRESHOLD_HASH = 100;

// Reference: Lemire, Daniel., and Owen, Kaser.
// Strongly Universal String Hashing Is Fast.
inline uint64_t get_seed(int i) {
    static std::array<uint64_t, THRESHOLD_HASH> seed = []() {
        std::array<uint64_t, THRESHOLD_HASH> _seed;
        for (auto& x : _seed) {
            x = yosupo::uniform(uint64_t(0), uint64_t(-1));
        }
        return _seed;
    }();
    static std::vector<uint64_t> long_seed;

    if (i < THRESHOLD_HASH) return seed[i];

    while (THRESHOLD_HASH + int(long_seed.size()) <= i) {
        long_seed.push_back(yosupo::uniform(uint64_t(0), uint64_t(-1)));
    }

    return long_seed[i - THRESHOLD_HASH];
}

struct DynHasher32 {
    int len = 0;
    uint64_t v = get_seed(0);

    DynHasher32 update32(uint32_t x) const {
        return DynHasher32{len + 1, v + x * get_seed(len)};
    }

    DynHasher32 to_dyn() const { return *this; }
    uint32_t digest() const { return uint32_t(v >> 32); }
};

template <int I = 1> struct Hasher32 {
    uint64_t v = get_seed(0);

    Hasher32<I + 1> update32(uint32_t x) const {
        return Hasher32<I + 1>{v + x * get_seed(I)};
    }

    DynHasher32 to_dyn() const { return DynHasher32{I, v}; }
    uint32_t digest() const { return uint32_t(v >> 32); }
};

// integer
template <class H,
          class T,
          is_integral_t<T>* = nullptr,
          std::enable_if_t<4 >= sizeof(T)>* = nullptr>
auto update(const H& h, const T& x) {
    return h.update32(uint32_t(x));
}
template <class H,
          class T,
          is_integral_t<T>* = nullptr,
          std::enable_if_t<sizeof(T) == 8>* = nullptr>
auto update(const H& h, const T& x) {
    return update(update(h, uint32_t(x)), uint32_t(uint64_t(x) >> 32));
}
template <class H,
          class T,
          is_integral_t<T>* = nullptr,
          std::enable_if_t<sizeof(T) == 16>* = nullptr>
auto update(const H& h, const T& x) {
    return update(update(h, uint64_t(x)), uint64_t((__uint128_t)(x) >> 64));
}

// pair
template <class H, class S, class T>
auto update(const H& h, const std::pair<S, T>& x) {
    return update(update(h, x.first), x.second);
}

// tuple
template <int I,
          class H,
          class T,
          std::enable_if_t<(I == std::tuple_size<T>::value)>* = nullptr>
auto update(const H& h, const T&) {
    return h;
}
template <int I = 0,
          class H,
          class T,
          std::enable_if_t<(I != std::tuple_size<T>::value)>* = nullptr>
auto update(const H& h, const T& x) {
    return update<I + 1>(update(h, std::get<I>(x)), x);
}

// array
template <int I = 0,
          class H,
          class T,
          int N>
auto update(const H& h, const std::array<T, N>& x) {
    return I == N ? h : update<I + 1>(update(h, x[I]), x);
}

// vector
template <class H, class T> auto update(const H& h, const std::vector<T>& v) {
    auto h2 = update(h, v.size()).to_dyn();
    for (const auto& x : v) {
        h2 = update(h2, x);
    }
    return h2;
}

// set
template <class H, class T> auto update(const H& h, const std::set<T>& s) {
    auto h2 = update(h, s.size()).to_dyn();
    for (const auto& x : s) {
        h2 = update(h2, x);
    }
    return h2;
}

// map
template <class H, class T, class U> auto update(const H& h, const std::map<T, U>& m) {
    auto h2 = update(h, m.size()).to_dyn();
    for (const auto& x : m) {
        h2 = update(h2, x);
    }
    return h2;
}

}  // namespace internal

template <class T> struct UniversalHash32 {
    uint32_t operator()(const T& x) {
        return internal::update(internal::Hasher32<>{}, x).digest();
    }
};

}  // namespace yosupo
#line 8 "/home/vscode/yosupo-library/src/yosupo/hashmap.hpp"

namespace yosupo {

template <class K, class D, class H = UniversalHash32<K>>
struct IncrementalHashMap {
  public:
    using Data = std::pair<K, D>;

  private:
    struct Iterator {
      public:
        using difference_type = int;
        using value_type = Data;
        using pointer = Data*;
        using reference = Data&;
        using iterator_category = std::forward_iterator_tag;

        IncrementalHashMap& _mp;
        unsigned int _pos;
        Iterator(IncrementalHashMap& mp, unsigned int pos)
            : _mp(mp), _pos(pos) {}

        std::pair<K, D>& operator*() const { return _mp.data[_pos]; }
        std::pair<K, D>* operator->() const { return &_mp.data[_pos]; }

        Iterator& operator++() {
            _pos = _mp.next_bucket(_pos + 1);
            return *this;
        }
        Iterator operator++(int) {
            auto result = *this;
            ++*this;
            return result;
        }

        bool operator==(const Iterator& rhs) const { return _pos == rhs._pos; }
        bool operator!=(const Iterator& rhs) const { return !(*this == rhs); }
    };

  public:
    IncrementalHashMap(size_t s)
        : mask((1 << s) - 1), filled(0), used(mask + 1), data(mask + 1) {}
    IncrementalHashMap() : IncrementalHashMap(2) {}

    Iterator begin() { return Iterator(*this, next_bucket(0)); }
    Iterator end() { return Iterator(*this, mask + 1); }
    using iterator = Iterator;

    D& operator[](const K& k) {
        unsigned int i = H()(k) & mask;
        while (used[i] && data[i].first != k) {
            i = (i + 1) & mask;
        }
        if (!used[i]) {
            if (filled * 2 > mask) {
                rehash();
                return (*this)[k];
            }
            filled++;
            used[i] = true;
            data[i] = {k, D()};
        }
        return data[i].second;
    }

    Iterator find(const K& k) {
        unsigned int i = H()(k) & mask;
        while (used[i] && data[i].first != k) {
            i = (i + 1) & mask;
        }
        if (!used[i]) return end();
        return Iterator(*this, i);
    }

    size_t count(const K& k) {
        return find(k) == end() ? 0 : 1;
    }

    size_t size() const { return filled; }

  private:
    unsigned int mask, filled;  // data.size() == 1 << s

    std::vector<bool> used;
    std::vector<Data> data;

    void rehash() {
        unsigned int pmask = mask;
        mask = mask * 2 + 1;
        filled = 0;
        auto pused = std::exchange(used, std::vector<bool>(mask + 1));
        auto pdata = std::exchange(data, std::vector<Data>(mask + 1));
        for (unsigned int i = 0; i <= pmask; i++) {
            if (pused[i]) {
                (*this)[pdata[i].first] = pdata[i].second;
            }
        }
    }

    unsigned int next_bucket(unsigned int i) const {
        while (i <= mask && !used[i]) i++;
        return i;
    }
};

}  // namespace yosupo
#line 7 "G/main.cpp"
#define YOSUPO_AVX2_PRAGMA
// #undef YOSUPO_LOCAL

#line 1 "/home/vscode/ac-library/atcoder/dsu.hpp"



#line 7 "/home/vscode/ac-library/atcoder/dsu.hpp"

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems
struct dsu {
  public:
    dsu() : _n(0) {}
    explicit dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder


#line 2 "/home/vscode/yosupo-library/src/yosupo/fastio.hpp"

#include <unistd.h>
#line 8 "/home/vscode/yosupo-library/src/yosupo/fastio.hpp"
#include <cctype>
#line 10 "/home/vscode/yosupo-library/src/yosupo/fastio.hpp"
#include <cstring>
#include <sstream>
#include <string>
#line 15 "/home/vscode/yosupo-library/src/yosupo/fastio.hpp"

#line 17 "/home/vscode/yosupo-library/src/yosupo/fastio.hpp"

namespace yosupo {

struct Scanner {
  public:
    Scanner(const Scanner&) = delete;
    Scanner& operator=(const Scanner&) = delete;

    Scanner(FILE* fp) : fd(fileno(fp)) { line[0] = 127; }

    void read() {}
    template <class H, class... T> void read(H& h, T&... t) {
        bool f = read_single(h);
        assert(f);
        read(t...);
    }

    int read_unsafe() { return 0; }
    template <class H, class... T> int read_unsafe(H& h, T&... t) {
        bool f = read_single(h);
        if (!f) return 0;
        return 1 + read_unsafe(t...);
    }

    int close() { return ::close(fd); }

  private:
    static constexpr int SIZE = 1 << 15;

    int fd = -1;
    std::array<char, SIZE + 1> line;
    int st = 0, ed = 0;
    bool eof = false;

    bool read_single(std::string& ref) {
        if (!skip_space()) return false;
        ref = "";
        while (true) {
            char c = top();
            if (c <= ' ') break;
            ref += c;
            st++;
        }
        return true;
    }
    bool read_single(double& ref) {
        std::string s;
        if (!read_single(s)) return false;
        ref = std::stod(s);
        return true;
    }

    template <class T,
              std::enable_if_t<std::is_same<T, char>::value>* = nullptr>
    bool read_single(T& ref) {
        if (!skip_space<50>()) return false;
        ref = top();
        st++;
        return true;
    }

    template <class T,
              internal::is_signed_int_t<T>* = nullptr,
              std::enable_if_t<!std::is_same<T, char>::value>* = nullptr>
    bool read_single(T& sref) {
        using U = internal::to_unsigned_t<T>;
        if (!skip_space<50>()) return false;
        bool neg = false;
        if (line[st] == '-') {
            neg = true;
            st++;
        }
        U ref = 0;
        do {
            ref = 10 * ref + (line[st++] & 0x0f);
        } while (line[st] >= '0');
        sref = neg ? -ref : ref;
        return true;
    }
    template <class U,
              internal::is_unsigned_int_t<U>* = nullptr,
              std::enable_if_t<!std::is_same<U, char>::value>* = nullptr>
    bool read_single(U& ref) {
        if (!skip_space<50>()) return false;
        ref = 0;
        do {
            ref = 10 * ref + (line[st++] & 0x0f);
        } while (line[st] >= '0');
        return true;
    }

    bool reread() {
        if (ed - st >= 50) return true;
        if (st > SIZE / 2) {
            std::memmove(line.data(), line.data() + st, ed - st);
            ed -= st;
            st = 0;
        }
        if (eof) return false;
        auto u = ::read(fd, line.data() + ed, SIZE - ed);
        if (u == 0) {
            eof = true;
            line[ed] = '\0';
            u = 1;
        }
        ed += int(u);
        line[ed] = char(127);
        return true;
    }

    char top() {
        if (st == ed) {
            bool f = reread();
            assert(f);
        }
        return line[st];
    }

    template <int TOKEN_LEN = 0> bool skip_space() {
        while (true) {
            while (line[st] <= ' ') st++;
            if (ed - st > TOKEN_LEN) return true;
            if (st > ed) st = ed;
            for (auto i = st; i < ed; i++) {
                if (line[i] <= ' ') return true;
            }
            if (!reread()) return false;
        }
    }
};

struct Printer {
  public:
    template <char sep = ' ', bool F = false> void write() {}
    template <char sep = ' ', bool F = false, class H, class... T>
    void write(const H& h, const T&... t) {
        if (F) write_single(sep);
        write_single(h);
        write<true>(t...);
    }
    template <char sep = ' ', class... T> void writeln(const T&... t) {
        write<sep>(t...);
        write_single('\n');
    }

    Printer(FILE* _fp) : fd(fileno(_fp)) {}
    ~Printer() { flush(); }

    int close() {
        flush();
        return ::close(fd);
    }

    void flush() {
        if (pos) {
            auto res = ::write(fd, line.data(), pos);
            assert(res != -1);
            pos = 0;
        }
    }

  private:
    static std::array<std::array<char, 2>, 100> small;
    static std::array<unsigned long long, 20> tens;

    static constexpr size_t SIZE = 1 << 15;
    int fd;
    std::array<char, SIZE> line;
    size_t pos = 0;
    std::stringstream ss;

    template <class T,
              std::enable_if_t<std::is_same<char, T>::value>* = nullptr>
    void write_single(const T& val) {
        if (pos == SIZE) flush();
        line[pos++] = val;
    }

    template <class T,
              internal::is_signed_int_t<T>* = nullptr,
              std::enable_if_t<!std::is_same<char, T>::value>* = nullptr>
    void write_single(const T& val) {
        using U = internal::to_unsigned_t<T>;
        if (val == 0) {
            write_single('0');
            return;
        }
        if (pos > SIZE - 50) flush();
        U uval = val;
        if (val < 0) {
            write_single('-');
            uval = -uval;
        }
        write_unsigned(uval);
    }

    template <class U, internal::is_unsigned_int_t<U>* = nullptr>
    void write_single(U uval) {
        if (uval == 0) {
            write_single('0');
            return;
        }
        if (pos > SIZE - 50) flush();

        write_unsigned(uval);
    }

    static int calc_len(uint64_t x) {
        int i = ((63 - std::countl_zero(x)) * 3 + 3) / 10;
        if (x < tens[i])
            return i;
        else
            return i + 1;
    }

    template <class U,
              internal::is_unsigned_int_t<U>* = nullptr,
              std::enable_if_t<2 >= sizeof(U)>* = nullptr>
    void write_unsigned(U uval) {
        size_t len = calc_len(uval);
        pos += len;

        char* ptr = line.data() + pos;
        while (uval >= 100) {
            ptr -= 2;
            memcpy(ptr, small[uval % 100].data(), 2);
            uval /= 100;
        }
        if (uval >= 10) {
            memcpy(ptr - 2, small[uval].data(), 2);
        } else {
            *(ptr - 1) = char('0' + uval);
        }
    }

    template <class U,
              internal::is_unsigned_int_t<U>* = nullptr,
              std::enable_if_t<4 == sizeof(U)>* = nullptr>
    void write_unsigned(U uval) {
        std::array<char, 8> buf;
        memcpy(buf.data() + 6, small[uval % 100].data(), 2);
        memcpy(buf.data() + 4, small[uval / 100 % 100].data(), 2);
        memcpy(buf.data() + 2, small[uval / 10000 % 100].data(), 2);
        memcpy(buf.data() + 0, small[uval / 1000000 % 100].data(), 2);

        if (uval >= 100000000) {
            if (uval >= 1000000000) {
                memcpy(line.data() + pos, small[uval / 100000000 % 100].data(),
                       2);
                pos += 2;
            } else {
                line[pos] = char('0' + uval / 100000000);
                pos++;
            }
            memcpy(line.data() + pos, buf.data(), 8);
            pos += 8;
        } else {
            size_t len = calc_len(uval);
            memcpy(line.data() + pos, buf.data() + (8 - len), len);
            pos += len;
        }
    }

    template <class U,
              internal::is_unsigned_int_t<U>* = nullptr,
              std::enable_if_t<8 == sizeof(U)>* = nullptr>
    void write_unsigned(U uval) {
        size_t len = calc_len(uval);
        pos += len;

        char* ptr = line.data() + pos;
        while (uval >= 100) {
            ptr -= 2;
            memcpy(ptr, small[uval % 100].data(), 2);
            uval /= 100;
        }
        if (uval >= 10) {
            memcpy(ptr - 2, small[uval].data(), 2);
        } else {
            *(ptr - 1) = char('0' + uval);
        }
    }

    template <
        class U,
        std::enable_if_t<internal::is_unsigned_int128<U>::value>* = nullptr>
    void write_unsigned(U uval) {
        static std::array<char, 50> buf;
        size_t len = 0;
        while (uval > 0) {
            buf[len++] = char((uval % 10) + '0');
            uval /= 10;
        }
        std::reverse(buf.begin(), buf.begin() + len);
        memcpy(line.data() + pos, buf.data(), len);
        pos += len;
    }

    void write_single(const std::string& s) {
        for (char c : s) write_single(c);
    }
    void write_single(const char* s) {
        size_t len = strlen(s);
        for (size_t i = 0; i < len; i++) write_single(s[i]);
    }
    template <class T> void write_single(const std::vector<T>& val) {
        auto n = val.size();
        for (size_t i = 0; i < n; i++) {
            if (i) write_single(' ');
            write_single(val[i]);
        }
    }
};

inline std::array<std::array<char, 2>, 100> Printer::small = [] {
    std::array<std::array<char, 2>, 100> table;
    for (int i = 0; i <= 99; i++) {
        table[i][1] = char('0' + (i % 10));
        table[i][0] = char('0' + (i / 10 % 10));
    }
    return table;
}();
inline std::array<unsigned long long, 20> Printer::tens = [] {
    std::array<unsigned long long, 20> table;
    for (int i = 0; i < 20; i++) {
        table[i] = 1;
        for (int j = 0; j < i; j++) {
            table[i] *= 10;
        }
    }
    return table;
}();

}  // namespace yosupo
#line 2 "/home/vscode/yosupo-library/src/yosupo/hashset.hpp"

#line 6 "/home/vscode/yosupo-library/src/yosupo/hashset.hpp"

#line 8 "/home/vscode/yosupo-library/src/yosupo/hashset.hpp"

namespace yosupo {

template <class K, class H = UniversalHash32<K>>
struct IncrementalHashSet {
  private:
    struct Iterator {
      public:
        using difference_type = int;
        using value_type = K;
        using pointer = K*;
        using reference = K&;
        using iterator_category = std::forward_iterator_tag;

        IncrementalHashSet& _mp;
        unsigned int _pos;
        Iterator(IncrementalHashSet& mp, unsigned int pos) : _mp(mp), _pos(pos) {}

        K operator*() const { return _mp.keys[_pos]; }

        Iterator& operator++() {
            _pos = _mp.next_bucket(_pos + 1);
            return *this;
        }
        Iterator operator++(int) {
            auto result = *this;
            ++*this;
            return result;
        }

        bool operator==(const Iterator& rhs) const { return _pos == rhs._pos; }
        bool operator!=(const Iterator& rhs) const { return !(*this == rhs); }
    };

  public:
    IncrementalHashSet(size_t s) : mask((1 << s) - 1), filled(0), used(mask + 1), keys(mask + 1) {}
    IncrementalHashSet() : IncrementalHashSet(2) {}

    Iterator begin() { return Iterator(*this, next_bucket(0)); }
    Iterator end() { return Iterator(*this, mask + 1); }
    using iterator = Iterator;

    void insert(const K& k) {
        unsigned int i = H()(k) & mask;
        while (used[i] && keys[i] != k) {
            i = (i + 1) & mask;
        }
        if (!used[i]) {
            if (filled * 2 > mask) {
                rehash();
                return this->insert(k);
            }
            filled++;
            used[i] = true;
            keys[i] = k;
        }
    }

    Iterator find(const K& k) {
        unsigned int i = H()(k) & mask;
        while (used[i] && keys[i] != k) {
            i = (i + 1) & mask;
        }
        if (!used[i]) return end();
        return Iterator(*this, i);
    }

  private:
    unsigned int mask, filled;  // data.size() == 1 << s

    std::vector<bool> used;
    std::vector<K> keys;

    void rehash() {
        unsigned int pmask = mask;
        mask = mask * 2 + 1;
        filled = 0;
        auto pused = std::exchange(used, std::vector<bool>(mask + 1));
        auto pkeys = std::exchange(keys, std::vector<K>(mask + 1));
        for (unsigned int i = 0; i <= pmask; i++) {
            if (pused[i]) {
                this->insert(pkeys[i]);
            }
        }
    }

    unsigned int next_bucket(unsigned int i) const {
        while (i <= mask && !used[i]) i++;
        return i;
    }
};

}  // namespace yosupo
#line 14 "G/main.cpp"
using namespace yosupo;

#line 2 "G/template.hpp"

#ifdef YOSUPO_AVX2_PRAGMA
#line 5 "G/template.hpp"
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#endif

#line 11 "G/template.hpp"
#include <bitset>
#line 13 "G/template.hpp"
#include <cmath>
#include <cstdio>
#line 16 "G/template.hpp"
#include <iostream>
#line 18 "G/template.hpp"
#include <queue>
#include <ranges>
#line 24 "G/template.hpp"

using std::abs, std::pow, std::sqrt;
using std::array, std::vector, std::string, std::queue, std::deque;
using std::countl_zero, std::countl_one, std::countr_zero, std::countr_one;
using std::istream, std::ostream, std::cerr, std::endl;
using std::min, std::max;
using std::pair, std::tuple, std::bitset;
using std::popcount;
using std::priority_queue, std::set, std::multiset, std::map;
using std::views::iota, std::views::reverse;

namespace ranges = std::ranges;
using ranges::sort, ranges::copy_n;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef YOSUPO_LOCAL

inline ostream& operator<<(ostream& os, __int128_t x) {
    if (x < 0) {
        os << "-";
        x *= -1;
    }
    if (x == 0) {
        return os << "0";
    }
    string s;
    while (x) {
        s += char(x % 10 + '0');
        x /= 10;
    }
    ranges::reverse(s);
    return os << s;
}
inline ostream& operator<<(ostream& os, __uint128_t x) {
    if (x == 0) {
        return os << "0";
    }
    string s;
    while (x) {
        s += char(x % 10 + '0');
        x /= 10;
    }
    ranges::reverse(s);
    return os << s;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p);
template <class T> ostream& operator<<(ostream& os, const V<T>& v);
template <class T> ostream& operator<<(ostream& os, const deque<T>& v);
template <class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N>& a);
template <class T> ostream& operator<<(ostream& os, const set<T>& s);
template <class T, class U>
ostream& operator<<(ostream& os, const map<T, U>& m);

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    bool f = false;
    for (auto d : v) {
        if (f) os << ", ";
        f = true;
        os << d;
    }
    return os << "]";
}

template <class T> ostream& operator<<(ostream& os, const deque<T>& v) {
    os << "[";
    bool f = false;
    for (auto d : v) {
        if (f) os << ", ";
        f = true;
        os << d;
    }
    return os << "]";
}
template <class T, size_t N>
ostream& operator<<(ostream& os, const array<T, N>& a) {
    os << "[";
    bool f = false;
    for (auto d : a) {
        if (f) os << ", ";
        f = true;
        os << d;
    }
    return os << "]";
}

template <class T> ostream& operator<<(ostream& os, const set<T>& s) {
    os << "{";
    bool f = false;
    for (auto d : s) {
        if (f) os << ", ";
        f = true;
        os << d;
    }
    return os << "}";
}
template <class T> ostream& operator<<(ostream& os, const multiset<T>& s) {
    os << "{";
    bool f = false;
    for (auto d : s) {
        if (f) os << ", ";
        f = true;
        os << d;
    }
    return os << "}";
}

template <class T, class U>
ostream& operator<<(ostream& os, const map<T, U>& s) {
    os << "{";
    bool f = false;
    for (auto p : s) {
        if (f) os << ", ";
        f = true;
        os << p.first << ": " << p.second;
    }
    return os << "}";
}

struct PrettyOS {
    ostream& os;
    bool first;

    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif
#line 17 "G/main.cpp"

using namespace std;
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
vector<vi> used;
unordered_set<int> caneg;
void cut(int a, int b) {
    LCT::cut(a, b);
    for (int s = 0; s < 2; s++) {
        for (int i = 0; i < used[a].size(); i++)
            if (used[a][i] == b) {
                used[a].erase(used[a].begin() + i);
                break;
            }
        if (used[a].size() == 1) caneg.insert(a);
        swap(a, b);
    }
}
void link(int a, int b) {
    LCT::link(a, b);
    for (int s = 0; s < 2; s++) {
        used[a].pb(b);
        if (used[a].size() == 2) caneg.erase(a);
        swap(a, b);
    }
}
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.

    LCT::init(n);
    if (mx_ch == -1) mx_ch = 1ll * (n + 100) * (n + 50);  // default
    used.resize(n + 1);
    caneg.clear();
    for (int i = 1; i <= n; i++) used[i].clear();

    vector<vi> edges(n + 1);
    for (auto v : eg) edges[v.fi].pb(v.se), edges[v.se].pb(v.fi);

    for (int i = 1; i <= n; i++) caneg.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 : caneg)
            for (auto s : edges[v]) eg.pb(mp(v, s));

        shuffle(eg.begin(), eg.end(), x);
        if (eg.size() == 0) break;
        for (auto v : eg) {
            mx_ch--;
            int a = v.fi, b = v.se;
            if (used[a].size() < used[b].size()) swap(a, b);
            if (used[b].size() >= 2) continue;
            if (x() & 1) continue;
            if (LCT::fdr(a) == LCT::fdr(b)) continue;
            if (used[a].size() < 2 && used[b].size() < 2) tot++;
            if (used[a].size() == 2) {
                int p = used[a][x() % 2];
                cut(a, p);
            }
            link(a, b);
        }
        if (tot == n - 1) {
            vi cur;
            for (int i = 1; i <= n; i++)
                if (used[i].size() <= 1) {
                    int pl = i, ls = 0;
                    while (pl) {
                        cur.pb(pl);
                        int flag = 0;
                        for (auto v : used[pl])
                            if (v != ls) {
                                ls = pl;
                                pl = v;
                                flag = 1;
                                break;
                            }
                        if (!flag) break;
                    }
                    break;
                }
            return cur;
        }
    }
    // failed to find a path
    return vi();
}
}  // namespace hamil


// const int N = 10000;
// const int M = 200000;
// const int K = 8;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    using P = pair<int, int>;
    int N, M, K;
    cin >> N >> M >> K;
    set<P> es;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        if (a > b) swap(a, b);
        es.insert({a - 1, b - 1});
    }

    // for (int _ = 0; _ < M; _++) {
    //     int a, b;
    //     while (true) {
    //         a = uniform(0, N - 1);
    //         b = uniform(0, N - 1);
    //         if (a == b) continue;
    //         if (a > b) std::swap(a, b);
    //         if (es.count({a, b})) continue;
    //         break;
    //     }
    //     es.insert({a, b});
    //     if (uniform_bool()) {
    //         std::swap(a, b);
    //     }
    // }

    for (int i = 0; i < K; i++) {
        V<P> edges;
        for (auto [a, b] : es) {
            edges.push_back({a + 1, b + 1});
        }
        auto path = hamil::work(N, edges);
        assert(int(path.size()) == N);
        for (int j = 0; j < N - 1; j++) {
            int a = path[j] - 1, b = path[j + 1] - 1;
            if (a > b) swap(a, b);
            assert(es.count({a, b}));
            es.erase({a, b});
        }
        for (int j = 0; j < N; j++) {
            if (j) cout << " ";
            cout << path[j];
        }
        cout << endl;
    }

    return 0;
}

详细

Test #1:

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

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

result:

ok OK (n = 5, m = 9)

Test #2:

score: 0
Accepted
time: 814ms
memory: 27492kb

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:

8925 1140 7225 2770 3511 257 6784 5097 4164 8671 9207 7355 3980 2683 432 9440 5121 5316 3574 8234 178 2414 7118 4132 2822 4400 8452 6442 2740 9814 295 3773 4805 4409 199 5918 3480 1670 7654 1329 6976 1546 131 8866 2654 433 6827 876 8 8100 1982 563 7286 1480 2408 6093 7511 6829 7298 1003 9939 9551 98...

result:

ok OK (n = 10000, m = 200000)

Test #3:

score: 0
Accepted
time: 795ms
memory: 28576kb

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:

2409 5328 8375 5366 1453 1366 4405 1172 8009 1839 5463 4235 6806 6442 5078 1123 1463 3480 9600 7183 2660 9895 9198 6714 8745 3894 101 6641 9905 7746 8494 1042 3802 2402 746 721 7821 8982 4513 9053 9273 6306 2082 3985 3096 4860 8140 4308 8948 4689 1628 3917 1079 6860 9102 5674 3134 3933 1104 352 3760...

result:

ok OK (n = 10000, m = 200000)

Test #4:

score: 0
Accepted
time: 805ms
memory: 27452kb

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:

4065 7156 9422 2904 8708 3453 5978 3088 1138 7152 8846 1073 5187 7525 7467 5208 4 7284 6064 9211 4693 3308 23 1525 872 6524 279 4918 8789 6825 8444 3132 6297 6540 3419 2963 8623 2703 2897 4005 1660 6091 5320 9908 6307 3875 9294 1442 7158 1048 5930 7836 1876 8334 2628 764 7517 1080 6044 5661 246 4514...

result:

ok OK (n = 10000, m = 200000)

Test #5:

score: 0
Accepted
time: 789ms
memory: 28604kb

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:

927 6476 4546 8086 8581 3670 8133 8862 609 8899 2788 3603 3928 8770 3402 3322 1553 7244 2310 4741 768 9832 1186 9026 7067 6041 2133 4377 7140 7531 555 6484 2651 4315 2654 2553 2162 3971 3761 5337 1895 3705 2485 7437 1476 6398 2688 2473 4307 9010 3714 8594 4653 6231 8130 9275 7877 2043 7066 3712 1457...

result:

ok OK (n = 10000, m = 200000)

Test #6:

score: 0
Accepted
time: 776ms
memory: 27924kb

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:

6523 7013 5535 4890 7677 4848 8101 4080 763 8559 3774 4440 5593 5329 7852 4411 4860 4640 9168 492 7600 7961 7960 1433 8715 2659 3881 7095 535 1322 3653 1313 4989 1353 2293 7249 7683 8948 8197 6923 2252 1140 7636 7214 5789 5801 2816 2828 7348 1253 4869 241 5424 1896 5940 9584 2870 8633 4416 1230 9453...

result:

ok OK (n = 10000, m = 200000)

Test #7:

score: 0
Accepted
time: 767ms
memory: 27472kb

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:

3059 1488 6345 6374 6144 5787 797 832 4413 7770 3281 2502 6994 8047 8942 9369 2981 5619 175 1707 7985 7760 8171 9172 8403 3181 2205 1190 8036 430 9059 7160 4974 7581 4754 6789 4923 1733 659 7107 6641 2395 971 7742 3397 8016 3071 3850 6547 3406 2083 7636 5330 8409 6079 86 8759 4953 3263 4345 4120 119...

result:

ok OK (n = 10000, m = 200000)

Test #8:

score: 0
Accepted
time: 719ms
memory: 28420kb

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:

2462 2656 9628 4525 6979 9046 1311 6974 6894 8846 8230 6517 9431 4922 2992 5352 8689 4011 7315 6943 9820 2695 939 1358 8955 2458 1121 8245 8709 1169 7414 2980 700 8581 4935 7614 7369 6428 4691 6156 6772 7997 898 4286 5849 8502 2537 3539 3987 1861 2023 9363 3351 8480 4034 4692 4340 9923 6378 1451 265...

result:

ok OK (n = 10000, m = 200000)

Test #9:

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

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:

5670 42 9422 8025 3849 3795 2810 741 7524 3344 7947 1800 3426 3099 7474 583 9857 5351 1063 284 1393 6697 6813 7642 6614 7592 5927 3885 3530 805 3511 1465 4626 9810 8702 1898 5575 8322 3319 245 2147 7518 1123 732 8784 2059 6638 4215 1319 1748 3988 9011 2301 9116 1420 3822 5140 303 8663 4200 8462 8165...

result:

ok OK (n = 10000, m = 200000)

Test #10:

score: 0
Accepted
time: 753ms
memory: 27728kb

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:

3074 2467 7809 7316 5698 3362 7869 3642 367 2034 9379 3621 4333 4870 9282 8539 2915 4708 7338 5373 4847 2155 8234 8913 8729 6655 232 9397 7227 5579 6012 8747 1313 3979 3303 495 8546 3876 5656 4300 3451 9699 6783 8624 4621 2923 753 3449 6167 1357 418 2246 4548 3537 3701 5240 9124 7115 2829 7841 7493 ...

result:

ok OK (n = 10000, m = 200000)

Test #11:

score: 0
Accepted
time: 785ms
memory: 27312kb

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:

3785 7375 5198 4432 3092 7595 9891 1728 2818 6520 2464 9012 1922 340 3722 2881 696 8685 1693 3758 1540 1873 8830 5387 5641 6595 9016 2141 534 9933 6527 5822 9942 843 7879 9397 5958 4665 5670 1148 4339 7255 5997 99 2025 838 8948 2124 8157 2666 7605 9470 3798 821 9134 2759 460 5028 2543 4220 7843 2139...

result:

ok OK (n = 10000, m = 200000)

Test #12:

score: 0
Accepted
time: 789ms
memory: 28076kb

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:

4166 4079 6232 4722 97 9082 134 2983 2478 8613 1842 241 8725 9717 7323 8830 2033 8928 4695 7027 7891 8169 4666 850 8181 9635 6718 889 9491 8244 8247 6734 8464 5779 1861 3422 1915 6464 1488 8641 488 1498 8889 2042 4752 6662 3290 9475 175 5460 1266 7834 9275 6061 2778 6441 3683 8142 4289 2827 645 1536...

result:

ok OK (n = 10000, m = 200000)

Test #13:

score: 0
Accepted
time: 799ms
memory: 28732kb

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:

7499 91 7775 2112 4056 5227 5436 7742 6298 3729 4665 2208 3455 8653 649 9548 3913 5483 6784 258 9895 5889 8027 5277 199 935 9686 5821 2143 6427 7656 2202 225 6795 7110 9657 9511 7466 3503 7510 905 7125 7840 4428 6768 6818 9257 6395 3558 9725 1275 6236 5610 1430 7463 8508 2472 1979 6732 8814 5913 830...

result:

ok OK (n = 10000, m = 200000)

Test #14:

score: 0
Accepted
time: 753ms
memory: 28820kb

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:

786 1597 3038 8473 5918 8569 6057 3185 9149 2657 6672 660 882 3865 3126 3656 8363 7670 1130 1121 243 9258 2008 1393 6300 2257 3605 3437 31 9935 1707 4861 2170 4657 3022 6822 4623 3382 2748 1163 2917 4870 5436 6250 4912 2219 2548 4795 6903 3820 3486 4869 4000 712 4681 2699 1747 5995 1739 4692 8993 63...

result:

ok OK (n = 10000, m = 200000)

Test #15:

score: 0
Accepted
time: 795ms
memory: 27952kb

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:

2806 5182 3536 8385 4094 9140 5343 3047 5319 473 4647 4568 5166 5753 9509 6408 8229 8122 8243 6138 6350 7213 3133 3958 3038 225 4202 3865 2979 7383 2610 4962 1377 144 8092 9618 637 866 8491 7382 7175 7291 4809 3829 1742 2044 441 6173 1124 5196 8335 1231 5482 3431 6860 9429 2488 2661 607 5783 7414 86...

result:

ok OK (n = 10000, m = 200000)

Test #16:

score: 0
Accepted
time: 742ms
memory: 27620kb

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:

1955 427 184 8975 7859 7030 6728 4305 9125 979 149 9111 2384 6419 4461 4460 1393 2203 7521 4394 4029 6331 3162 1770 7628 6323 6674 3337 4114 2657 6410 2603 6874 3977 2185 9690 764 2839 7380 1841 8534 4707 8393 647 2572 8939 1838 8447 5349 2835 6662 9621 6844 4584 6179 5659 8356 7979 1924 3784 9520 3...

result:

ok OK (n = 10000, m = 200000)

Test #17:

score: 0
Accepted
time: 794ms
memory: 27964kb

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:

6807 689 4325 6579 7179 4451 2562 6360 9793 9951 9212 9672 4262 179 2287 1795 8891 7328 1202 839 881 5668 1365 9426 3646 8994 3448 668 1814 3392 3059 4304 1432 9786 1886 4665 7891 8370 7278 5567 5595 6240 4343 6190 7837 5293 2354 1481 9197 9763 1541 1390 7818 1341 4159 2822 8263 4200 4109 3568 6661 ...

result:

ok OK (n = 10000, m = 200000)

Test #18:

score: 0
Accepted
time: 862ms
memory: 27184kb

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:

7251 9533 9412 282 7533 2196 286 8989 5626 6680 1096 3753 1394 2473 8157 8125 6045 8760 7395 4716 3661 7024 2960 131 7485 6679 3326 6673 4505 6094 5477 3651 8158 1215 2418 2785 3876 8105 7250 6346 3667 9398 7473 3760 6228 8490 5581 2987 4062 5231 8202 7192 3141 5019 5985 5299 3603 9770 4667 668 1956...

result:

ok OK (n = 10000, m = 200000)

Test #19:

score: 0
Accepted
time: 806ms
memory: 27228kb

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:

4116 2764 8774 4464 9497 3502 2806 5118 3950 1419 6170 4195 61 9787 5189 7041 8749 7960 2652 6814 6995 1742 420 8850 4550 6575 5332 6478 1610 5371 2805 9694 3401 2501 5784 6305 4486 787 8936 2131 6740 6277 3718 3545 5741 5675 6532 4022 6401 225 3463 7846 3178 277 594 3593 597 2027 7514 687 6454 7928...

result:

ok OK (n = 10000, m = 200000)

Test #20:

score: 0
Accepted
time: 795ms
memory: 27588kb

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:

452 8106 5994 2632 2188 296 4505 355 8392 7889 8025 3310 2656 8835 9896 8600 3843 14 8211 2434 8473 6198 6611 3904 3892 2761 5665 4734 3931 6859 2527 4322 2079 948 6377 1489 276 7930 3730 8524 6074 6151 7107 6281 422 1961 6299 5757 825 7129 7490 662 5716 7648 7034 4098 6515 4937 6615 558 6177 9871 6...

result:

ok OK (n = 10000, m = 200000)

Test #21:

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

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:

5369 6890 4940 428 928 7010 8858 1452 3979 7619 2035 3738 2335 8925 1469 7497 3377 5961 3639 7070 1620 2496 4830 7699 2869 399 1676 2893 5472 9110 1711 9577 6301 8627 3605 9727 7692 815 5605 2848 2453 2011 3438 246 9848 7170 136 6436 454 1342 6053 4666 360 8215 7035 9669 6394 7957 3714 7866 5867 525...

result:

ok OK (n = 10000, m = 200000)

Test #22:

score: 0
Accepted
time: 821ms
memory: 27468kb

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:

9773 444 2188 8608 8520 8800 5216 5311 1703 1707 1766 1374 2198 9176 4445 9824 5510 3722 5293 5787 1490 6503 8650 75 8874 4402 9920 1894 6839 6513 8986 7569 7941 5385 2912 4895 9839 6216 2583 5324 1974 1175 8180 7237 3122 3286 1891 5639 3513 4642 2144 6558 4016 7722 5322 6642 7529 2989 1492 727 9616...

result:

ok OK (n = 10000, m = 200000)

Test #23:

score: 0
Accepted
time: 843ms
memory: 28496kb

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:

2924 4193 5221 743 6047 1172 6056 4353 8281 1600 4558 7310 6138 8695 6632 5253 1013 4205 4043 3364 4309 3942 2164 8838 3022 4089 3964 1031 1962 1672 5862 3782 171 3979 2129 3917 1271 8589 2635 4957 4968 1604 7959 9881 8574 7707 7998 4671 571 4674 6867 4901 8876 271 3654 292 9850 3939 807 2585 2011 5...

result:

ok OK (n = 10000, m = 200000)

Test #24:

score: 0
Accepted
time: 807ms
memory: 28244kb

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:

2795 639 6185 8115 6472 6843 1336 9051 3 2519 1966 5950 7512 4246 8712 1392 9888 7192 3129 4199 7583 2697 6355 658 9334 7911 3312 5430 4975 6146 9367 4255 6849 4856 5313 3512 2703 3583 9193 409 2244 3277 3572 4082 4991 2753 1247 9085 9403 4034 5359 339 97 1039 4548 7621 746 8032 1362 4322 2030 573 7...

result:

ok OK (n = 10000, m = 200000)

Test #25:

score: 0
Accepted
time: 801ms
memory: 27116kb

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:

4331 4907 6354 3988 6053 7786 8943 4046 8232 1408 7782 2151 2671 7159 8861 432 3793 8193 4230 1541 3217 8384 2279 6648 291 8885 9223 5671 8495 3165 3026 3059 603 8845 5240 3327 2907 3632 2874 3739 4205 24 843 2589 9831 8821 6143 777 8068 5567 8320 4719 4131 3605 9455 5045 6636 5080 6731 1545 7043 10...

result:

ok OK (n = 10000, m = 200000)

Test #26:

score: 0
Accepted
time: 769ms
memory: 27508kb

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:

125 4971 8927 558 8865 4061 6643 9156 2212 6948 4568 5002 9028 2230 1530 925 8510 9137 6253 155 4149 1256 3459 2758 3 5065 7973 55 470 6134 1389 501 5859 5638 755 3456 8926 193 2915 1700 6176 7675 6282 1275 519 2652 8788 9445 1392 3645 232 1166 9957 4540 9562 9485 7650 8178 1380 5849 7339 3476 3647 ...

result:

ok OK (n = 10000, m = 200000)

Test #27:

score: 0
Accepted
time: 785ms
memory: 27424kb

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:

4150 3346 4508 7569 710 6047 5249 2366 2886 5028 907 814 7805 9490 4362 2673 3772 4917 4294 8019 2579 2738 820 8863 1222 8368 946 6693 3086 3719 7634 2312 7529 3410 8459 2489 183 6038 6754 2506 1722 7289 1546 4515 5095 2038 1451 5996 3894 6277 167 1254 5968 8086 6590 1943 1539 7673 5909 7442 4507 28...

result:

ok OK (n = 10000, m = 200000)

Test #28:

score: 0
Accepted
time: 795ms
memory: 28252kb

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:

6510 2245 9163 6667 3594 1617 4500 8997 8214 5403 8115 2867 1167 4635 1959 2335 6763 2160 3007 6666 4777 3499 4075 6287 3393 8152 7235 166 757 3033 2590 3687 6934 9346 2844 8290 886 5432 8763 3468 8677 5541 3875 6777 6502 3199 5328 9436 2646 41 7538 6882 6982 3788 5053 5205 5075 7783 8277 7894 3082 ...

result:

ok OK (n = 10000, m = 200000)

Test #29:

score: 0
Accepted
time: 853ms
memory: 27424kb

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:

5029 8334 3432 633 8075 9006 1761 216 8615 8401 1149 5228 7850 9482 1260 3194 9230 318 1221 2139 3858 6172 4836 3578 4003 806 9618 1509 263 1511 1259 2935 1665 3666 8072 5208 740 8119 2031 421 7583 5749 6674 5912 6381 9759 254 8699 3102 6031 663 8371 8183 5681 7950 708 2573 2901 6005 2885 7534 9028 ...

result:

ok OK (n = 10000, m = 200000)

Test #30:

score: 0
Accepted
time: 765ms
memory: 28344kb

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:

292 6312 8249 9148 4644 436 1181 9675 6473 4875 2345 4914 6693 7427 3920 4036 2929 3366 8154 579 9107 8544 3277 79 6793 7946 2959 8012 7415 3321 6618 3663 3924 904 4034 9920 9958 6068 4899 7093 6756 9086 4667 7377 5515 9429 6165 2786 7668 9344 8504 1394 8511 9084 7761 2346 1632 7992 1586 5517 2289 4...

result:

ok OK (n = 10000, m = 200000)

Test #31:

score: 0
Accepted
time: 816ms
memory: 27508kb

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:

2982 712 9197 5129 1726 8554 6378 6904 913 2443 62 4391 1784 7545 4283 6180 6602 6940 5250 7996 1715 5817 6224 6519 3786 4427 9223 7896 1654 2189 1276 2498 7621 5467 9 7684 8943 4829 4244 779 237 9529 2725 7863 9547 5678 2958 2769 2111 515 7013 4198 7001 9632 2712 3975 4117 7065 2043 2361 5836 7455 ...

result:

ok OK (n = 10000, m = 200000)

Extra Test:

score: 0
Extra Test Passed