QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#829098#9771. Guessing Gameucup-team5243AC ✓1578ms37692kbC++2342.1kb2024-12-24 02:17:212024-12-24 02:17:22

Judging History

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

  • [2024-12-24 02:17:22]
  • 评测
  • 测评结果:AC
  • 用时:1578ms
  • 内存:37692kb
  • [2024-12-24 02:17:21]
  • 提交

answer

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

// ★★★★★ いわゆるQCFium、おまじない的につけとくと速い
#ifndef LOCAL_TEST
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif // LOCAL_TEST

// ★★★★★ 型名を短くする、ちょっと嬉しい
using ll = long long;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using vi = vector<int>;  using vvi = vector<vi>; using vvvi = vector<vvi>;
using vl = vector<ll>;  using vvl = vector<vl>; using vvvl = vector<vvl>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vc = vector<char>; using vvc = vector<vc>; using vvvc = vector<vvc>;
using vd = vector<double>; using vvd = vector<vd>; using vvvd = vector<vvd>;
using vs = vector<string>; using vvs = vector<vector<string>>; using vvvs = vector<vector<vector<string>>>;

// ★★★ 多次元vector初期化用の関数、ちょっと癖があるけど短く書ける
// テンプレなし:vector dp(n+1, vector(m+1, vector<ll>(k+1, 0)));
// テンプレあり:auto dp = vvv<ll>(n+1, m+1, k+1, 0);
template<typename T> vector<vector<T>> vv(int h, int w, T val = T()) { return vector(h, vector<T>(w, val)); }
template<typename T> vector<vector<vector<T>>> vvv(int h1, int h2, int h3, T val = T()) { return vector(h1, vector(h2, vector<T>(h3, val))); }
template<typename T> vector<vector<vector<vector<T>>>> vvvv(int h1, int h2, int h3, int h4, T val = T()) { return vector(h1, vector(h2, vector(h3, vector<T>(h4, val)))); }

// ★★ いわゆるheapq、C++のデフォルトpriority_queueは大きい順(Python、Nimとは逆)に注意
template <class T> using priority_queue_min = priority_queue<T, vector<T>, greater<T>>;

// ★ 定数系、お好みで
constexpr double PI = 3.14159265358979323;
constexpr int INF = 100100111; constexpr ll INFL = 3300300300300300491LL;
float EPS = 1e-8; double EPSL = 1e-10;


// ★★★★ 入出力高速化、おまじない
struct Nyan { Nyan() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(18); } } nyan;

// マクロ類
// わりと全部使う
// all: sort(all(a)) とか lower_bount(all(a), x) とか
// rep: オーバーロードしているので、引数の個数で挙動が変わる、基本Pythonのrangeに近い感覚で使えるようにしてるはず
//      rep(5) -> 5回ループ(新たにループ変数は作らない)
//      rep(i, 5) -> i=0,1,...,4
//      rep(i, 5) -> i=0,1,...,4
//      rep(i, 1, 6) -> i=1,...,4
//      rep(i, 1, 6, 2) -> i=1,3,5
//      rep(i, 10, -1, -1) -> i=10,9,.., 0
// smod, sdiv: python-like mod, div
// uniq: 重複削除、ソートされるのに注意
// vl a = {1, 3, 2, 5, 2, 3}; uniq(a); // a = {1, 2, 3, 5}
#define all(a) (a).begin(), (a).end()
#define len(x) ((ll)(x).size())
#define sz(x) ((ll)(x).size())
#define rep1(n) for(ll dummy_iter = 0LL; dummy_iter < n; ++dummy_iter) // 0,1,...,n-1
#define rep2(i, n) for(ll i = 0LL, i##_counter = 0LL; i##_counter < ll(n); ++(i##_counter), (i) = i##_counter) // i=0,1,...,n-1
#define rep3(i, s, t) for(ll i = ll(s), i##_counter = ll(s); i##_counter < ll(t); ++(i##_counter), (i) = (i##_counter)) // i=s,s+1,...,t-1
#define rep4(i, s, t, step) for(ll i##_counter = step > 0 ? ll(s) : -ll(s), i##_end = step > 0 ? ll(t) : -ll(t), i##_step = abs(step), i = ll(s); i##_counter < i##_end; i##_counter += i##_step, i = step > 0 ? i##_counter : -i##_counter) // i=s,s+step,...,<t
#define overload4(a, b, c, d, e, ...) e
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define repe(a, v) for(auto& a : (v)) // iterate over all elements in v
#define smod(n, m) ((((n) % (m)) + (m)) % (m))
#define sdiv(n, m) (((n) - smod(n, m)) / (m))
#define uniq(a) {sort(all(a)); (a).erase(unique(all(a)), (a).end());}

// ★★ Yes, No なくても困らない
int Yes(bool b=true) { cout << (b ? "Yes\n" : "No\n"); return 0; };
int YES(bool b=true) { cout << (b ? "YES\n" : "NO\n"); return 0; };
int No(bool b=true) {return Yes(!b);};
int NO(bool b=true) {return YES(!b);};

// ★★★★ max, min, sum のvector向けオーバーロード、デフォルトがちょっと使いにくいので
template<typename T, size_t N> T max(array<T, N>& a) { return *max_element(all(a)); };
template<typename T, size_t N> T min(array<T, N>& a) { return *min_element(all(a)); };
template<typename T> T max(vector<T>& a) { return *max_element(all(a)); };
template<typename T> T min(vector<T>& a) { return *min_element(all(a)); };
template<typename T> vector<T> vec_slice(const vector<T>& a, int l, int r) { vector<T> rev; rep(i, l, r) rev.push_back(a[i]); return rev; };
template<typename T> T sum(vector<T>& a, T zero = T(0)) { T rev = zero; rep(i, sz(a)) rev += a[i]; return rev; };

// ★★★ vector の各要素を1増やす/減らす、グラフ系の入力受けでちょっと嬉しい
// vector<ll> a = {1, 2, 4}; ++a; // a = {2, 3, 5}
template <class T> inline vector<T>& operator--(vector<T>& v) { repe(x, v) --x; return v; }
template <class T> inline vector<T>& operator++(vector<T>& v) { repe(x, v) ++x; return v; }

// ★★★★ 整数pow/sqrt
ll powm(ll a, ll n, ll mod=INFL) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * a) % mod;
        if (n > 1) a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}
ll sqrtll(ll x) {
    assert(x >= 0);
    ll rev = sqrt(x);
    while(rev * rev > x) --rev;
    while((rev+1) * (rev+1)<=x) ++rev;
    return rev;
}

// ★★★★ chmax, chmin
template <class T> inline bool chmax(T& M, const T& x) { if (M < x) { M = x; return true; } return false; }
template <class T> inline bool chmin(T& m, const T& x) { if (m > x) { m = x; return true; } return false; }

// ★★★★★ vector を直接cinできるようにする
// map, set, multiset とかを直接 cout できるようにする
template <class T, class U> inline istream& operator>>(istream& is, pair<T, U>& p);
template <class T> inline istream& operator>>(istream& is, vector<T>& v);
template <class T, class U> inline ostream& operator<<(ostream& os, const pair<T, U>& p);
template <class T> inline ostream& operator<<(ostream& os, const vector<T>& v);
template <typename T, typename S> ostream &operator<<(ostream &os, const map<T, S> &mp);
template <typename T> ostream &operator<<(ostream &os, const set<T> &st);
template <typename T> ostream &operator<<(ostream &os, const multiset<T> &st);
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T> &st);
template <typename T> ostream &operator<<(ostream &os, deque<T> q);
template <class T, class Container, class Compare> ostream &operator<<(ostream &os, priority_queue<T, Container, Compare> pq);

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

#define read1(a) cin >> a;
#define read2(a, b) cin >> a >> b;
#define read3(a, b, c) cin >> a >> b >> c;
#define read4(a, b, c, d) cin >> a >> b >> c >> d;
#define read5(a, b, c, d, e) cin >> a >> b >> c >> d >> e;
#define read6(a, b, c, d, e, f) cin >> a >> b >> c >> d >> e >> f;
#define read7(a, b, c, d, e, f, g) cin >> a >> b >> c >> d >> e >> f >> g;
#define read8(a, b, c, d, e, f, g, h) cin >> a >> b >> c >> d >> e >> f >> g >> h;

#define overload_read(a, b, c, d, e, f, g, h, i, ...) i
#define read(...) overload_read(__VA_ARGS__,read8,read7,read6,read5,read4,read3,read2,read1)(__VA_ARGS__)

#ifdef LOCAL_TEST
#define inner_output1(a) cout << a << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << endl;
#define inner_output2(a, b) cout << a << " " << b << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " <<b << endl;
#define inner_output3(a, b, c) cout << a << " " << b << " " << c << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " << b << " " << c << endl;
#define inner_output4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " << b << " " << c << " " << d << endl;
#define inner_output5(a, b, c, d, e) cout << a << " " << b << " " << c << " " << d << " " << e << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " << b << " " << c << " " << d << " " << e << endl;
#define inner_output6(a, b, c, d, e, f) cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl;
#define inner_output7(a, b, c, d, e, f, g) cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << endl;
#define inner_output8(a, b, c, d, e, f, g, h) cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << endl;cerr << "[OUTPUT #" << __LINE__ << "] " << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << endl;

#else

#define inner_output1(a) cout << a << endl;
#define inner_output2(a, b) cout << a << " " << b << endl;
#define inner_output3(a, b, c) cout << a << " " << b << " " << c << endl;
#define inner_output4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl;
#define inner_output5(a, b, c, d, e) cout << a << " " << b << " " << c << " " << d << " " << e << endl;
#define inner_output6(a, b, c, d, e, f) cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << endl;
#define inner_output7(a, b, c, d, e, f, g) cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << endl;
#define inner_output8(a, b, c, d, e, f, g, h) cout << a << " " << b << " " << c << " " << d << " " << e << " " << f << " " << g << " " << h << endl;

#endif
#define overload_inner_output(a, b, c, d, e, f, g, h, i, ...) i
#define out(...) overload_inner_output(__VA_ARGS__,inner_output8,inner_output7,inner_output6,inner_output5,inner_output4,inner_output3,inner_output2,inner_output1)(__VA_ARGS__)

#define ii(...) ll __VA_ARGS__; read(__VA_ARGS__)
#define si(...) string __VA_ARGS__; read(__VA_ARGS__)
#define ci(...) char __VA_ARGS__; read(__VA_ARGS__)
#define di(...) double __VA_ARGS__; read(__VA_ARGS__)
#define li(name,size); vector<ll> name(size); read(name)
#define lli(name,H,W); vector name(H,vector<ll>(W));rep(i,H) cin >> name[i];


#ifdef LOCAL_TEST
#define inner_debug1(a) cerr << "[DEBUG#" << __LINE__ << "] " << #a << " = " << a << endl;
#define inner_debug2(a, b) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << endl;
#define inner_debug3(a, b, c) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << endl;
#define inner_debug4(a, b, c, d) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << ", " << #d << " = " << d << endl;
#define inner_debug5(a, b, c, d, e) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << ", " << #d << " = " << d << ", " << #e << " = " << e << endl;
#define inner_debug6(a, b, c, d, e, f) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << ", " << #d << " = " << d << ", " << #e << " = " << e << ", " << #f << " = " << f << endl;
#define inner_debug7(a, b, c, d, e, f, g) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << ", " << #d << " = " << d << ", " << #e << " = " << e << ", " << #f << " = " << f << ", " << #g << " = " << g << endl;
#define inner_debug8(a, b, c, d, e, f, g, h) cerr << "[DEBUG#" << __LINE__ << "] "<< #a << " = " << a << ", " << #b << " = " << b << ", " << #c << " = " << c << ", " << #d << " = " << d << ", " << #e << " = " << e << ", " << #f << " = " << f << ", " << #g << " = " << g << ", " << #h << " = " << h << endl;

#define overload_inner_debug(a, b, c, d, e, f, g, h, i, ...) i
#define debug(...) overload_inner_debug(__VA_ARGS__,inner_debug8,inner_debug7,inner_debug6,inner_debug5,inner_debug4,inner_debug3,inner_debug2,inner_debug1)(__VA_ARGS__)

#else
#define debug(...);
#endif // LOCAL_TEST


inline ll ctz(ll x) { return __builtin_ctzll(x);}
inline ll clz(ll x) { return __builtin_clzll(x);}
inline ll popcount(ll x) { return __builtin_popcountll(x);}
inline bool inrange(ll x, ll a, ll b) { return a <= x && x < b; }
template <typename T> inline ll findll(vector<T>& v, T x) { auto tmp = find(all(v), x);if(tmp == v.end()){return -1;}else{return distance(v.begin(),tmp); }}
inline ll findll(string& s, char x) { auto tmp = find(all(s), x);if(tmp == s.end()){return -1;}else{return distance(s.begin(),tmp); }}
#include <vector>
#include <utility>
#include <cassert>
#include <utility>
#include <vector>
#include <algorithm>

namespace nachia{

template<class Elem>
class CsrArray{
public:
    struct ListRange{
        using iterator = typename std::vector<Elem>::iterator;
        iterator begi, endi;
        iterator begin() const { return begi; }
        iterator end() const { return endi; }
        int size() const { return (int)std::distance(begi, endi); }
        Elem& operator[](int i) const { return begi[i]; }
    };
    struct ConstListRange{
        using iterator = typename std::vector<Elem>::const_iterator;
        iterator begi, endi;
        iterator begin() const { return begi; }
        iterator end() const { return endi; }
        int size() const { return (int)std::distance(begi, endi); }
        const Elem& operator[](int i) const { return begi[i]; }
    };
private:
    int m_n;
    std::vector<Elem> m_list;
    std::vector<int> m_pos;
public:
    CsrArray() : m_n(0), m_list(), m_pos() {}
    static CsrArray Construct(int n, std::vector<std::pair<int, Elem>> items){
        CsrArray res;
        res.m_n = n;
        std::vector<int> buf(n+1, 0);
        for(auto& [u,v] : items){ ++buf[u]; }
        for(int i=1; i<=n; i++) buf[i] += buf[i-1];
        res.m_list.resize(buf[n]);
        for(int i=(int)items.size()-1; i>=0; i--){
            res.m_list[--buf[items[i].first]] = std::move(items[i].second);
        }
        res.m_pos = std::move(buf);
        return res;
    }
    static CsrArray FromRaw(std::vector<Elem> list, std::vector<int> pos){
        CsrArray res;
        res.m_n = pos.size() - 1;
        res.m_list = std::move(list);
        res.m_pos = std::move(pos);
        return res;
    }
    ListRange operator[](int u) { return ListRange{ m_list.begin() + m_pos[u], m_list.begin() + m_pos[u+1] }; }
    ConstListRange operator[](int u) const { return ConstListRange{ m_list.begin() + m_pos[u], m_list.begin() + m_pos[u+1] }; }
    int size() const { return m_n; }
    int fullSize() const { return (int)m_list.size(); }
};

} // namespace nachia

namespace nachia{


struct Graph {
public:
    struct Edge{
        int from, to;
        void reverse(){ std::swap(from, to); }
        int xorval() const { return from ^ to; }
    };
    Graph(int n = 0, bool undirected = false, int m = 0) : m_n(n), m_e(m), m_isUndir(undirected) {}
    Graph(int n, const std::vector<std::pair<int, int>>& edges, bool undirected = false) : m_n(n), m_isUndir(undirected){
        m_e.resize(edges.size());
        for(std::size_t i=0; i<edges.size(); i++) m_e[i] = { edges[i].first, edges[i].second };
    }
    template<class Cin>
    static Graph Input(Cin& cin, int n, bool undirected, int m, int offset = 0){
        Graph res(n, undirected, m);
        for(int i=0; i<m; i++){
            int u, v; cin >> u >> v;
            res[i].from = u - offset;
            res[i].to = v - offset;
        }
        return res;
    }
    int numVertices() const noexcept { return m_n; }
    int numEdges() const noexcept { return int(m_e.size()); }
    int addNode() noexcept { return m_n++; }
    int addEdge(int from, int to){ m_e.push_back({ from, to }); return numEdges() - 1; }
    Edge& operator[](int ei) noexcept { return m_e[ei]; }
    const Edge& operator[](int ei) const noexcept { return m_e[ei]; }
    Edge& at(int ei) { return m_e.at(ei); }
    const Edge& at(int ei) const { return m_e.at(ei); }
    auto begin(){ return m_e.begin(); }
    auto end(){ return m_e.end(); }
    auto begin() const { return m_e.begin(); }
    auto end() const { return m_e.end(); }
    bool isUndirected() const noexcept { return m_isUndir; }
    void reverseEdges() noexcept { for(auto& e : m_e) e.reverse(); }
    void contract(int newV, const std::vector<int>& mapping){
        assert(numVertices() == int(mapping.size()));
        for(int i=0; i<numVertices(); i++) assert(0 <= mapping[i] && mapping[i] < newV);
        for(auto& e : m_e){ e.from = mapping[e.from]; e.to = mapping[e.to]; }
        m_n = newV;
    }
    std::vector<Graph> induce(int num, const std::vector<int>& mapping) const {
        int n = numVertices();
        assert(n == int(mapping.size()));
        for(int i=0; i<n; i++) assert(-1 <= mapping[i] && mapping[i] < num);
        std::vector<int> indexV(n), newV(num);
        for(int i=0; i<n; i++) if(mapping[i] >= 0) indexV[i] = newV[mapping[i]]++;
        std::vector<Graph> res; res.reserve(num);
        for(int i=0; i<num; i++) res.emplace_back(newV[i], isUndirected());
        for(auto e : m_e) if(mapping[e.from] == mapping[e.to] && mapping[e.to] >= 0) res[mapping[e.to]].addEdge(indexV[e.from], indexV[e.to]);
        return res;
    }
    CsrArray<int> getEdgeIndexArray(bool undirected) const {
        std::vector<std::pair<int, int>> src;
        src.reserve(numEdges() * (undirected ? 2 : 1));
        for(int i=0; i<numEdges(); i++){
            auto e = operator[](i);
            src.emplace_back(e.from, i);
            if(undirected) src.emplace_back(e.to, i);
        }
        return CsrArray<int>::Construct(numVertices(), src);
    }
    CsrArray<int> getEdgeIndexArray() const { return getEdgeIndexArray(isUndirected()); }
    CsrArray<int> getAdjacencyArray(bool undirected) const {
        std::vector<std::pair<int, int>> src;
        src.reserve(numEdges() * (undirected ? 2 : 1));
        for(auto e : m_e){
            src.emplace_back(e.from, e.to);
            if(undirected) src.emplace_back(e.to, e.from);
        }
        return CsrArray<int>::Construct(numVertices(), src);
    }
    CsrArray<int> getAdjacencyArray() const { return getAdjacencyArray(isUndirected()); }
private:
    int m_n;
    std::vector<Edge> m_e;
    bool m_isUndir;
};

} // namespace nachia
#include <vector>
#include <algorithm>

namespace nachia{

struct HeavyLightDecomposition{
private:

    int N;
    std::vector<int> P;
    std::vector<int> PP;
    std::vector<int> PD;
    std::vector<int> D;
    std::vector<int> I;

    std::vector<int> rangeL;
    std::vector<int> rangeR;

public:

    HeavyLightDecomposition(const CsrArray<int>& E = CsrArray<int>::Construct(1, {}), int root = 0){
        N = E.size();
        P.assign(N, -1);
        I = {root};
        I.reserve(N);
        for(int i=0; i<(int)I.size(); i++){
            int p = I[i];
            for(int e : E[p]) if(P[p] != e){
                I.push_back(e);
                P[e] = p;
            }
        }
        std::vector<int> Z(N, 1);
        std::vector<int> nx(N, -1);
        PP.resize(N);
        for(int i=0; i<N; i++) PP[i] = i;
        for(int i=N-1; i>=1; i--){
            int p = I[i];
            Z[P[p]] += Z[p];
            if(nx[P[p]] == -1) nx[P[p]] = p;
            if(Z[nx[P[p]]] < Z[p]) nx[P[p]] = p;
        }

        for(int p : I) if(nx[p] != -1) PP[nx[p]] = p;

        PD.assign(N,N);
        PD[root] = 0;
        D.assign(N,0);
        for(int p : I) if(p != root){
            PP[p] = PP[PP[p]];
            PD[p] = std::min(PD[PP[p]], PD[P[p]]+1);
            D[p] = D[P[p]]+1;
        }
        
        rangeL.assign(N,0);
        rangeR.assign(N,0);
        
        for(int p : I){
            rangeR[p] = rangeL[p] + Z[p];
            int ir = rangeR[p];
            for(int e : E[p]) if(P[p] != e) if(e != nx[p]){
                rangeL[e] = (ir -= Z[e]);
            }
            if(nx[p] != -1){
                rangeL[nx[p]] = rangeL[p] + 1;
            }
        }

        I.resize(N);
        for(int i=0; i<N; i++) I[rangeL[i]] = i;
    }
    
    HeavyLightDecomposition(const Graph& tree, int root = 0)
        : HeavyLightDecomposition(tree.getAdjacencyArray(true), root) {}

    int numVertices() const { return N; }
    int depth(int p) const { return D[p]; }
    int toSeq(int vtx) const { return rangeL[vtx]; }
    int toVtx(int seqidx) const { return I[seqidx]; }
    int toSeq2In(int vtx) const { return rangeL[vtx] * 2 - D[vtx]; }
    int toSeq2Out(int vtx) const { return rangeR[vtx] * 2 - D[vtx] - 1; }
    int parentOf(int v) const { return P[v]; }
    int heavyRootOf(int v) const { return PP[v]; }
    int heavyChildOf(int v) const {
        if(toSeq(v) == N-1) return -1;
        int cand = toVtx(toSeq(v) + 1);
        if(PP[v] == PP[cand]) return cand;
        return -1;
    }

    int lca(int u, int v) const {
        if(PD[u] < PD[v]) std::swap(u, v);
        while(PD[u] > PD[v]) u = P[PP[u]];
        while(PP[u] != PP[v]){ u = P[PP[u]]; v = P[PP[v]]; }
        return (D[u] > D[v]) ? v : u;
    }

    int dist(int u, int v) const {
        return depth(u) + depth(v) - depth(lca(u,v)) * 2;
    }

    struct Range{
        int l; int r;
        int size() const { return r-l; }
        bool includes(int x) const { return l <= x && x < r; }
    };

    std::vector<Range> path(int r, int c, bool include_root = true, bool reverse_path = false) const {
        if(PD[c] < PD[r]) return {};
        std::vector<Range> res(PD[c]-PD[r]+1);
        for(int i=0; i<(int)res.size()-1; i++){
            res[i] = { rangeL[PP[c]], rangeL[c]+1 };
            c = P[PP[c]];
        }
        if(PP[r] != PP[c] || D[r] > D[c]) return {};
        res.back() = { rangeL[r]+(include_root?0:1), rangeL[c]+1 };
        if(res.back().l == res.back().r) res.pop_back();
        if(!reverse_path) std::reverse(res.begin(),res.end());
        else for(auto& a : res) a = { N - a.r, N - a.l };
        return res;
    }

    Range subtree(int p) const { return { rangeL[p], rangeR[p] }; }

    int median(int x, int y, int z) const {
        return lca(x,y) ^ lca(y,z) ^ lca(x,z);
    }

    int la(int from, int to, int d) const {
        if(d < 0) return -1;
        int g = lca(from,to);
        int dist0 = D[from] - D[g] * 2 + D[to];
        if(dist0 < d) return -1;
        int p = from;
        if(D[from] - D[g] < d){ p = to; d = dist0 - d; }
        while(D[p] - D[PP[p]] < d){
            d -= D[p] - D[PP[p]] + 1;
            p = P[PP[p]];
        }
        return I[rangeL[p] - d];
    }

    struct ChildrenIterRange {
    struct Iter {
        const HeavyLightDecomposition& hld; int s;
        int operator*() const { return hld.toVtx(s); }
        Iter& operator++(){
            s += hld.subtree(hld.I[s]).size();
            return *this;
        }
        Iter operator++(int) const { auto a = *this; return ++a; }
        bool operator==(Iter& r) const { return s == r.s; }
        bool operator!=(Iter& r) const { return s != r.s; }
    };
        const HeavyLightDecomposition& hld; int v;
        Iter begin() const { return { hld, hld.rangeL[v] + 1 }; }
        Iter end() const { return { hld, hld.rangeR[v] }; }
    };
    ChildrenIterRange children(int v) const {
        return ChildrenIterRange{ *this, v };
    }
};

} // namespace nachia

#include <algorithm>
#include <cassert>
#include <vector>

namespace atcoder {

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;
    std::vector<int> parent_or_size;
};

}  // namespace atcoder


#include <algorithm>
#include <cassert>
#include <functional>
#include <vector>


#ifdef _MSC_VER
#include <intrin.h>
#endif

#if __cplusplus >= 202002L
#include <bit>
#endif

namespace atcoder {

namespace internal {

#if __cplusplus >= 202002L

using std::bit_ceil;

#else

unsigned int bit_ceil(unsigned int n) {
    unsigned int x = 1;
    while (x < (unsigned int)(n)) x *= 2;
    return x;
}

#endif

int countr_zero(unsigned int n) {
#ifdef _MSC_VER
    unsigned long index;
    _BitScanForward(&index, n);
    return index;
#else
    return __builtin_ctz(n);
#endif
}

constexpr int countr_zero_constexpr(unsigned int n) {
    int x = 0;
    while (!(n & (1 << x))) x++;
    return x;
}

}  // namespace internal

}  // namespace atcoder


namespace atcoder {

#if __cplusplus >= 201703L

template <class S,
          auto op,
          auto e,
          class F,
          auto mapping,
          auto composition,
          auto id>
struct lazy_segtree {
    static_assert(std::is_convertible_v<decltype(op), std::function<S(S, S)>>,
                  "op must work as S(S, S)");
    static_assert(std::is_convertible_v<decltype(e), std::function<S()>>,
                  "e must work as S()");
    static_assert(
        std::is_convertible_v<decltype(mapping), std::function<S(F, S)>>,
        "mapping must work as F(F, S)");
    static_assert(
        std::is_convertible_v<decltype(composition), std::function<F(F, F)>>,
        "compostiion must work as F(F, F)");
    static_assert(std::is_convertible_v<decltype(id), std::function<F()>>,
                  "id must work as F()");

#else

template <class S,
          S (*op)(S, S),
          S (*e)(),
          class F,
          S (*mapping)(F, S),
          F (*composition)(F, F),
          F (*id)()>
struct lazy_segtree {

#endif

  public:
    lazy_segtree() : lazy_segtree(0) {}
    explicit lazy_segtree(int n) : lazy_segtree(std::vector<S>(n, e())) {}
    explicit lazy_segtree(const std::vector<S>& v) : _n(int(v.size())) {
        size = (int)internal::bit_ceil((unsigned int)(_n));
        log = internal::countr_zero((unsigned int)size);
        d = std::vector<S>(2 * size, e());
        lz = std::vector<F>(size, id());
        for (int i = 0; i < _n; i++) d[size + i] = v[i];
        for (int i = size - 1; i >= 1; i--) {
            update(i);
        }
    }

    void set(int p, S x) {
        assert(0 <= p && p < _n);
        p += size;
        for (int i = log; i >= 1; i--) push(p >> i);
        d[p] = x;
        for (int i = 1; i <= log; i++) update(p >> i);
    }

    S get(int p) {
        assert(0 <= p && p < _n);
        p += size;
        for (int i = log; i >= 1; i--) push(p >> i);
        return d[p];
    }

    S prod(int l, int r) {
        assert(0 <= l && l <= r && r <= _n);
        if (l == r) return e();

        l += size;
        r += size;

        for (int i = log; i >= 1; i--) {
            if (((l >> i) << i) != l) push(l >> i);
            if (((r >> i) << i) != r) push((r - 1) >> i);
        }

        S sml = e(), smr = e();
        while (l < r) {
            if (l & 1) sml = op(sml, d[l++]);
            if (r & 1) smr = op(d[--r], smr);
            l >>= 1;
            r >>= 1;
        }

        return op(sml, smr);
    }

    S all_prod() { return d[1]; }

    void apply(int p, F f) {
        assert(0 <= p && p < _n);
        p += size;
        for (int i = log; i >= 1; i--) push(p >> i);
        d[p] = mapping(f, d[p]);
        for (int i = 1; i <= log; i++) update(p >> i);
    }
    void apply(int l, int r, F f) {
        assert(0 <= l && l <= r && r <= _n);
        if (l == r) return;

        l += size;
        r += size;

        for (int i = log; i >= 1; i--) {
            if (((l >> i) << i) != l) push(l >> i);
            if (((r >> i) << i) != r) push((r - 1) >> i);
        }

        {
            int l2 = l, r2 = r;
            while (l < r) {
                if (l & 1) all_apply(l++, f);
                if (r & 1) all_apply(--r, f);
                l >>= 1;
                r >>= 1;
            }
            l = l2;
            r = r2;
        }

        for (int i = 1; i <= log; i++) {
            if (((l >> i) << i) != l) update(l >> i);
            if (((r >> i) << i) != r) update((r - 1) >> i);
        }
    }

    template <bool (*g)(S)> int max_right(int l) {
        return max_right(l, [](S x) { return g(x); });
    }
    template <class G> int max_right(int l, G g) {
        assert(0 <= l && l <= _n);
        assert(g(e()));
        if (l == _n) return _n;
        l += size;
        for (int i = log; i >= 1; i--) push(l >> i);
        S sm = e();
        do {
            while (l % 2 == 0) l >>= 1;
            if (!g(op(sm, d[l]))) {
                while (l < size) {
                    push(l);
                    l = (2 * l);
                    if (g(op(sm, d[l]))) {
                        sm = op(sm, d[l]);
                        l++;
                    }
                }
                return l - size;
            }
            sm = op(sm, d[l]);
            l++;
        } while ((l & -l) != l);
        return _n;
    }

    template <bool (*g)(S)> int min_left(int r) {
        return min_left(r, [](S x) { return g(x); });
    }
    template <class G> int min_left(int r, G g) {
        assert(0 <= r && r <= _n);
        assert(g(e()));
        if (r == 0) return 0;
        r += size;
        for (int i = log; i >= 1; i--) push((r - 1) >> i);
        S sm = e();
        do {
            r--;
            while (r > 1 && (r % 2)) r >>= 1;
            if (!g(op(d[r], sm))) {
                while (r < size) {
                    push(r);
                    r = (2 * r + 1);
                    if (g(op(d[r], sm))) {
                        sm = op(d[r], sm);
                        r--;
                    }
                }
                return r + 1 - size;
            }
            sm = op(d[r], sm);
        } while ((r & -r) != r);
        return 0;
    }

  private:
    int _n, size, log;
    std::vector<S> d;
    std::vector<F> lz;

    void update(int k) { d[k] = op(d[2 * k], d[2 * k + 1]); }
    void all_apply(int k, F f) {
        d[k] = mapping(f, d[k]);
        if (k < size) lz[k] = composition(f, lz[k]);
    }
    void push(int k) {
        all_apply(2 * k, lz[k]);
        all_apply(2 * k + 1, lz[k]);
        lz[k] = id();
    }
};

}  // namespace atcoder

using namespace atcoder;
using namespace nachia;

pair<int,int> op(pair<int,int> a,pair<int,int> b){
    return {a.first+b.first,a.second+b.second};
}

pair<int,int> e(){
    return {0,0};
}

pair<int,int> mapping(int f,pair<int,int> x){
    if(f !=INF ) return {f,f};
    return x;
}

int composition(int f,int g){
    if(f != INF) return f;
    return g;
}

int id(){
    return INF;
}



int main(){
    std::cin.tie(0)->sync_with_stdio(0);
    ii(Q);
    dsu uf(200000);
    vector<pair<int,int>> edges;
    vector<int> first(200000,-1);
    vector<int> time(200000,INF);
    vector<pair<int,int>> querys;
    querys.reserve(Q);
    edges.reserve(Q);
    int cnt = 200000;
    rep(i,Q){
        ii(a,b);
        a--;b--;
        b+=100000;
        querys.emplace_back(a,b);
        if(uf.same(a,b)){
            if(first[uf.leader(a)] == -1){
                first[uf.leader(a)] = a;
                time[uf.leader(a)] = i;
            }
        }else{
            int t;
            int f;
            if((first[uf.leader(a)] != -1)&&(first[uf.leader(b)] != -1)){
                a = first[uf.leader(a)];
                b = first[uf.leader(b)];
            }
            if(time[uf.leader(a)] < time[uf.leader(b)]){
                t = time[uf.leader(a)];
                f = first[uf.leader(a)];
            }else{
                t = time[uf.leader(b)];
                f = first[uf.leader(b)];
            }
            uf.merge(a,b);
            cnt--;
            edges.emplace_back(a,b);
            first[uf.leader(a)] = f;
            time[uf.leader(a)] = t; 
        }
    }
    Graph g(200001,true,0);
    vector<bool> alr(200000,false);
    //ll debug_cnt = 0;
    rep(i,len(edges)){
        g.addEdge(edges[i].first,edges[i].second);
        debug(edges[i].first,edges[i].second);
        //debug_cnt++;
    }
    rep(i,200000){
        if(alr[uf.leader(i)]) continue;
        alr[uf.leader(i)] = true;
        if (first[uf.leader(i)] != -1){
            g.addEdge(first[uf.leader(i)],200000);
            //debug_cnt++;
        }else{
            g.addEdge(i,200000);
            //debug_cnt++;
        }
    }
    debug(edges.size()+cnt);
    debug(debug_cnt);
    HeavyLightDecomposition hld(g,200000);
    dsu uf2(200000);
    int A = 0;
    int B = 0;

    vector<int> akiyo(200000,0);
    vector<int> bkiyo(200000,0);
    vector<int> acnt(200000,0);
    vector<int> bcnt(200000,0);
    vb iscycle(200000,false);
    vector<int> X(200000,-1);
    vector<int> Y(200000,-1);
    vector<int> first2(200000,-1);
    vector<int> time2(200000,INF);
    lazy_segtree<pair<int,int>,op,e,int,mapping,composition,id> seg(200001);
    rep(i,100000){
        acnt[i] = 1;
        seg.set(hld.toSeq(i),{1,0});
        X[i] = i;
        Y[i] = i;
        bcnt[i+100000] = 1;
        seg.set(hld.toSeq(i+100000),{0,1});
        X[i+100000] = i+100000;
        Y[i+100000] = i+100000;
    }

    debug("end_init");
    


    rep(i,Q){
        auto [a,b] = querys[i];
        if(uf2.same(a,b)){
            int l = uf2.leader(a);
            if(first2[uf2.leader(a)] == -1){
                first2[uf2.leader(a)] = a;
                time2[uf2.leader(a)] = i;
            }
            debug(iscycle[l]);
            if(!iscycle[uf2.leader(a)]){
                iscycle[l] = true;
                A -= akiyo[l];
                B -= bkiyo[l];
                akiyo[l] = acnt[l];
                bkiyo[l] = bcnt[l];
                A += akiyo[l];
                B += bkiyo[l];
            }
            int lca = hld.lca(a,b);
            debug(a,b,lca,first2[l]);
            repe(R,hld.path(first2[l],a,true,false)){
                debug(A,B);
                auto [a,b] = seg.prod(R.l,R.r);
                debug(R.l,R.r,tmp,hld.toVtx(R.l),hld.toVtx(R.r));
                akiyo[l] -= a;
                A -= a;
                if(a+b != 0) seg.apply(R.l,R.r,0);
                bkiyo[l] -= b;
                B -= b;
            }
            repe(R,hld.path(lca,b,false,false)){
                auto [a,b] = seg.prod(R.l,R.r);
                debug(R.l,R.r,tmp);
                akiyo[l] -= a;
                A -= a;
                if(a+b != 0) seg.apply(R.l,R.r,0);
                bkiyo[l] -= b;
                B -= b;
            }
            
        }else{
            
            int la = uf2.leader(a);
            int lb = uf2.leader(b);
            debug(i,la,lb);
            int fa = first2[uf2.leader(a)];
            int fb = first2[uf2.leader(b)];
            int ta = time2[uf2.leader(a)];
            int tb = time2[uf2.leader(b)];

            int t;
            int f;
            if(time2[uf2.leader(a)] < time2[uf2.leader(b)]){
                t = time2[uf2.leader(a)];
                f = first2[uf2.leader(a)];
            }else{
                t = time2[uf2.leader(b)];
                f = first2[uf2.leader(b)];
            }
            uf2.merge(a,b);
            first2[uf2.leader(a)] = f;
            time2[uf2.leader(a)] = t; 
            int newl = uf2.leader(a);


            if((!iscycle[la]) && (!iscycle[lb])){
                debug(i,la,lb);
                A -= akiyo[la];
                B -= bkiyo[la];
                A -= akiyo[lb];
                B -= bkiyo[lb];
                acnt[newl] = acnt[la] + acnt[lb];
                bcnt[newl] = bcnt[la] + bcnt[lb];

                int x = -1;
                int y = -1;
                int v = -1;
                vector<int> tmp = {X[la],X[lb],Y[la],Y[lb]};
                repe(l,tmp){
                    repe(r,tmp){
                        if (chmax(v,(int)hld.dist(l,r))){
                            x = l;
                            y = r;
                        }   
                    }
                }
                X[newl] = x;
                Y[newl] = y;
                
                if ((x < 100000) && (y < 100000)){
                    //同じ色の場合
                    //必ず長さが偶数のはず。
                    assert(v%2 == 0);
                    if((v/2)%2 == 0){
                        akiyo[newl] = acnt[newl] - 1;
                        bkiyo[newl] = bcnt[newl];
                    }else{
                        akiyo[newl] = acnt[newl];
                        bkiyo[newl] = bcnt[newl] - 1;
                    }
                }else{
                    if(!((x >= 100000) && (y >= 100000))){
                        v--;
                    }
                    assert(v%2 == 0);
                    if((v/2)%2 == 0){
                        akiyo[newl] = acnt[newl];
                        bkiyo[newl] = bcnt[newl] - 1;
                    }else{
                        akiyo[newl] = acnt[newl] - 1;
                        bkiyo[newl] = bcnt[newl];
                    }

                }
                A += akiyo[newl];
                B += bkiyo[newl];

            }else if(iscycle[la] && iscycle[lb]){
                // faとfbをつなげる
                // aと根、bと根をつなげる
                akiyo[newl] = akiyo[la] + akiyo[lb];
                bkiyo[newl] = bkiyo[la] + bkiyo[lb];
                acnt[newl] = acnt[la] + acnt[lb];
                bcnt[newl] = bcnt[la] + bcnt[lb];

                int lca = hld.lca(a,b);
                repe(R,hld.path(first2[newl],a,true,false)){
                    auto [a,b] = seg.prod(R.l,R.r);
                    akiyo[newl] -= a;
                    A -= a;
                    if(a+b != 0) seg.apply(R.l,R.r,0);
                    bkiyo[newl] -= b;
                    B -= b;
                }
                repe(R,hld.path(lca,b,false,false)){
                    auto [a,b] = seg.prod(R.l,R.r);
                    akiyo[newl] -= a;
                    A -= a;
                    if(a+b != 0){
                        seg.apply(R.l,R.r,0);
                    }
                    
                    bkiyo[newl] -= b;
                    B -= b;
                }

            }else{
                if(!iscycle[la]){
                    swap(la,lb);
                    swap(fa,fb);
                    swap(ta,tb);
                }

                // laがサイクル
                A -= akiyo[lb];
                B -= bkiyo[lb];
                akiyo[newl] = akiyo[la] + acnt[lb];
                bkiyo[newl] = bkiyo[la] + bcnt[lb];
                A += acnt[lb];
                B += bcnt[lb];
                acnt[newl] = acnt[la] + acnt[lb];
                bcnt[newl] = bcnt[la] + bcnt[lb];
                iscycle[newl] = true;
            }   
            
        }
        cout << A << " " << B << '\n';
    }

}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 15ms
memory: 26528kb

input:

4
1 1
1 2
2 1
2 2

output:

1 0
0 2
1 2
0 0

result:

ok 8 numbers

Test #2:

score: 0
Accepted
time: 184ms
memory: 28988kb

input:

250000
49324 49323
44443 44445
92513 92513
69591 69591
52085 52082
95024 95025
21004 21005
34373 34371
60771 60772
17131 17134
34885 34882
6011 6015
56103 56105
21055 21054
71592 71593
14894 14895
25774 25771
96225 96224
16444 16442
48432 48432
86954 86952
7202 7202
38661 38665
20063 20063
85383 853...

output:

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

result:

ok 500000 numbers

Test #3:

score: 0
Accepted
time: 336ms
memory: 32480kb

input:

500000
94699 94691
39066 39061
70924 70923
55402 55402
88622 88624
207 205
90609 90603
45892 45892
78872 78873
2321 2323
44788 44785
45517 45515
46316 46315
31599 31594
75478 75473
54876 54872
68947 68941
56371 56375
95794 95791
52971 52975
9094 9095
38174 38174
72230 72221
75527 75523
45981 45984
2...

output:

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

result:

ok 1000000 numbers

Test #4:

score: 0
Accepted
time: 344ms
memory: 32808kb

input:

500000
24924 24924
68134 68136
60184 60190
30242 30246
4652 4654
41325 41326
51273 51277
14181 14190
52941 52947
12605 12602
62014 62013
25274 25272
28923 28926
22913 22918
82081 82081
84712 84715
13824 13828
39794 39798
4625 4630
69325 69325
87294 87297
56584 56586
16534 16536
47811 47817
71493 714...

output:

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

result:

ok 1000000 numbers

Test #5:

score: 0
Accepted
time: 711ms
memory: 36424kb

input:

1000000
41061 41062
81529 81527
59603 59610
62143 62144
30555 30554
5734 5739
72323 72326
9181 9182
81989 81981
97599 97598
58337 58334
76316 76314
43062 43065
61562 61570
54986 54981
41125 41126
62797 62792
27930 27928
31425 31423
63331 63334
56781 56785
14300 14300
85147 85147
11465 11461
6465 646...

output:

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

result:

ok 2000000 numbers

Test #6:

score: 0
Accepted
time: 977ms
memory: 34176kb

input:

1000000
1925 271
992 320
1726 916
358 199
512 1789
1533 802
395 254
1300 1197
695 1727
842 1084
574 155
884 115
1103 1073
555 156
1885 1990
571 1685
958 417
38 1439
253 766
1423 1280
1049 1788
1088 1490
468 1663
260 290
20 110
733 1682
1925 1062
1263 1287
1972 1893
147 1659
1302 880
101 1084
1647 26...

output:

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

result:

ok 2000000 numbers

Test #7:

score: 0
Accepted
time: 1057ms
memory: 34168kb

input:

1000000
2003 3287
1503 4809
2504 3209
2096 1631
3667 2309
2751 4519
4200 2858
3675 675
2178 1530
2616 318
2190 2155
1078 731
3629 4217
1471 4060
2599 1298
4997 3291
211 3328
4217 980
3960 995
4637 1089
1624 1181
1196 4493
3303 1476
3684 4938
2504 3163
4707 995
2608 1441
231 322
3145 3696
269 4899
42...

output:

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

result:

ok 2000000 numbers

Test #8:

score: 0
Accepted
time: 1087ms
memory: 34444kb

input:

1000000
1837 4376
1052 9648
4335 9271
4840 4084
6502 4239
9550 3715
1066 9096
96 6657
1750 1698
182 9908
4366 5772
5609 1370
5379 7902
3417 2784
4192 3296
72 4923
2625 7408
3613 4083
967 4849
6242 3011
4725 678
1399 8507
3606 6251
1324 5150
8789 9677
203 3812
6450 796
6219 6601
9892 7312
8958 5068
8...

output:

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

result:

ok 2000000 numbers

Test #9:

score: 0
Accepted
time: 1206ms
memory: 34480kb

input:

1000000
19985 17625
13035 937
10440 15619
15423 12700
18030 12495
1481 208
19158 3975
8791 19836
872 7918
16427 7401
992 1111
2745 10390
11693 19020
11948 9495
10995 13064
9665 8370
9545 6877
19657 5152
3452 7024
9548 17042
12522 792
12033 13610
328 5602
13463 16157
11325 19152
1776 17848
6212 8501
...

output:

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

result:

ok 2000000 numbers

Test #10:

score: 0
Accepted
time: 1357ms
memory: 34948kb

input:

1000000
49837 28460
5880 13988
19553 42648
23669 24757
13700 49966
14572 10903
23434 46724
38797 13564
20940 44690
49481 150
46550 24152
19960 42861
12249 47093
32531 7325
33290 15073
6826 37493
35841 44068
19806 25656
16716 23548
2168 39136
21593 14652
12849 47830
15903 35143
10968 33371
16630 4648...

output:

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

result:

ok 2000000 numbers

Test #11:

score: 0
Accepted
time: 1477ms
memory: 37224kb

input:

1000000
93180 5157
3929 22274
74152 19408
64555 3032
41026 64997
69695 59638
98521 45486
74944 59183
42898 94439
93452 13289
30434 73216
98067 65121
25303 6111
79419 78019
37424 22267
85407 95730
9888 61570
26155 53254
79695 73268
36130 89833
19257 84229
38585 40889
58221 66271
99481 65514
92655 754...

output:

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

result:

ok 2000000 numbers

Test #12:

score: 0
Accepted
time: 583ms
memory: 36836kb

input:

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

output:

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

result:

ok 2000000 numbers

Test #13:

score: 0
Accepted
time: 555ms
memory: 35656kb

input:

1000000
72537 72537
24287 24288
90338 90339
93483 93483
79093 79094
37762 37762
2402 2402
97691 97692
30103 30103
84693 84693
14780 14780
13944 13944
21709 21709
66332 66332
67757 67758
96675 96676
88163 88164
26681 26682
38766 38766
71263 71264
55687 55688
13519 13519
74277 74278
88640 88641
40042 ...

output:

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

result:

ok 2000000 numbers

Test #14:

score: 0
Accepted
time: 573ms
memory: 35664kb

input:

1000000
88413 88413
69498 69498
14848 14848
29505 29506
14963 14963
87473 87473
81305 81306
12346 12347
81591 81591
49414 49415
25900 25901
72701 72701
18812 18813
51843 51844
21296 21297
50813 50814
9582 9583
69914 69915
34496 34497
68109 68109
88808 88809
5657 5657
64045 64045
65774 65775
5090 509...

output:

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

result:

ok 2000000 numbers

Test #15:

score: 0
Accepted
time: 578ms
memory: 37356kb

input:

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

output:

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

result:

ok 2000000 numbers

Test #16:

score: 0
Accepted
time: 528ms
memory: 37340kb

input:

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

output:

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

result:

ok 2000000 numbers

Test #17:

score: 0
Accepted
time: 1484ms
memory: 37532kb

input:

1000000
90588 66293
725 91260
90356 3697
82335 52425
59273 23756
40056 5920
45675 56936
82692 74876
71617 46252
82257 39139
98218 90053
64598 54614
62449 90425
89590 73510
25287 39304
30996 22654
2711 42041
83802 34315
16053 20747
61314 80082
71913 17740
68122 21340
51955 53672
90645 88625
96772 342...

output:

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

result:

ok 2000000 numbers

Test #18:

score: 0
Accepted
time: 1465ms
memory: 36560kb

input:

1000000
46318 56427
44929 56427
46318 42579
44929 54986
16923 54986
59497 56427
86789 42579
33704 56427
22718 42579
16923 76139
16923 16007
62354 56427
36507 54986
13608 54986
46318 88131
84781 56427
44929 34955
24945 42579
62354 25938
29094 16007
36507 48736
23913 42579
83443 48736
81702 56427
2099...

output:

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

result:

ok 2000000 numbers

Test #19:

score: 0
Accepted
time: 1185ms
memory: 36604kb

input:

1000000
73941 19832
72307 19832
73941 89340
96301 19832
26908 19832
37712 19832
73941 31965
73941 87085
13300 19832
50005 19832
59829 19832
73941 13437
58931 19832
16874 19832
42640 19832
52326 19832
1681 19832
33993 19832
82323 19832
24896 19832
73941 22926
72307 75289
88535 19832
26908 31849
36391...

output:

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

result:

ok 2000000 numbers

Test #20:

score: 0
Accepted
time: 1517ms
memory: 37576kb

input:

1000000
21538 16901
21538 34334
16774 34334
16774 67916
16774 17230
16774 34915
16774 9069
16774 95512
91230 95512
91230 72552
34402 72552
34402 43132
34402 89250
34402 75611
48165 75611
48165 15572
48165 57871
71903 57871
71903 84127
50919 57871
96830 57871
97319 84127
96830 5595
67146 5595
85915 8...

output:

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

result:

ok 2000000 numbers

Test #21:

score: 0
Accepted
time: 1492ms
memory: 35608kb

input:

1000000
42504 29373
42842 87506
92260 33933
35527 10153
23565 74017
15909 58397
5315 27775
36395 15083
47200 8830
54609 95134
24963 25194
75354 40875
3600 72362
66003 33772
26344 84095
7980 613
44906 45834
90566 58678
25351 45264
27659 56752
2606 43753
72188 82550
36137 95577
80536 12013
22587 10937...

output:

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

result:

ok 2000000 numbers

Test #22:

score: 0
Accepted
time: 1267ms
memory: 37348kb

input:

1000000
38909 45877
83037 86054
98990 74890
29840 18595
62695 93680
37960 40644
37121 39175
2505 92782
30063 88751
7795 41529
82025 83577
10520 16374
68466 53501
99670 89516
31411 60737
80545 29128
97652 26601
17894 82405
72162 97461
1386 25080
32874 8471
27009 61014
41792 70148
76296 94529
87542 51...

output:

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

result:

ok 2000000 numbers

Test #23:

score: 0
Accepted
time: 1578ms
memory: 37612kb

input:

1000000
74498 1517
81023 11792
99146 85168
5171 23864
89563 82520
91379 84667
28725 97475
17075 76815
46693 77520
9762 2120
86779 74307
19052 15362
44193 80241
75261 24969
82832 53196
75461 73716
69198 56935
49941 34244
26706 97659
52217 22837
73972 83328
85813 11252
10799 42715
58981 52841
77067 46...

output:

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

result:

ok 2000000 numbers

Test #24:

score: 0
Accepted
time: 1524ms
memory: 36532kb

input:

1000000
16264 78276
46101 60908
51624 46936
95576 39400
38886 37430
70584 99994
54224 12917
42090 29882
86159 75829
62760 79229
14259 74316
91392 25721
16537 16076
35883 84110
58355 39968
67642 6718
41067 51634
3972 35716
6400 36176
82227 28355
55331 15852
75181 88388
1598 58931
73668 41245
8916 894...

output:

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

result:

ok 2000000 numbers

Test #25:

score: 0
Accepted
time: 1439ms
memory: 35724kb

input:

1000000
32362 39944
47100 541
22133 77590
28535 42865
48906 17865
6079 60729
7699 69851
10386 86211
77433 75992
84343 80058
12618 696
51964 39591
49003 85238
84157 43184
77768 17032
4479 39863
54408 75035
79969 93727
49009 90530
98025 9482
7752 28736
81450 30535
96673 65188
5308 5993
30279 60942
325...

output:

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

result:

ok 2000000 numbers

Test #26:

score: 0
Accepted
time: 1520ms
memory: 37364kb

input:

1000000
16961 21846
94019 16546
26262 28610
27545 35023
93911 14390
23879 89614
4094 24522
58006 845
22770 97743
37661 14389
29055 40427
28383 18818
83216 21432
60406 4145
33821 84950
72993 69813
39682 22176
99574 49967
84516 1081
76863 39957
89005 8899
29458 58402
82240 37169
47538 10834
29888 7921...

output:

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

result:

ok 2000000 numbers

Test #27:

score: 0
Accepted
time: 1480ms
memory: 36552kb

input:

1000000
62757 40934
22810 41676
65676 49865
93564 49449
15160 27584
76073 29530
27340 88638
92720 94610
3399 58273
88006 38093
15548 75053
4057 18969
53631 83386
84633 63892
51602 72158
30221 1367
15130 78787
34023 95475
79971 25345
52370 65648
65731 79281
38548 9433
78236 93708
16415 85259
64333 56...

output:

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

result:

ok 2000000 numbers

Test #28:

score: 0
Accepted
time: 1179ms
memory: 37104kb

input:

1000000
88968 21523
46041 55196
55126 77851
3838 16650
41850 3996
47552 11608
98065 49525
26725 60621
91553 66558
44770 79289
30828 69223
53744 60299
41786 73074
28844 16640
46977 72106
68390 1925
13159 19923
71526 17674
18778 7364
11124 94107
52551 72248
4323 69780
49334 21487
94876 38529
85973 690...

output:

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

result:

ok 2000000 numbers

Test #29:

score: 0
Accepted
time: 1515ms
memory: 35716kb

input:

1000000
89867 20102
82721 50081
12915 62607
88094 42308
80731 77971
59879 25583
77635 95450
91597 58468
25292 68907
65307 62023
62679 64787
11006 95228
52954 73489
18468 44567
61257 15047
46572 35350
9985 34231
76938 36923
32639 47860
35584 57385
48136 84800
20645 72765
2321 5312
45499 63575
87711 4...

output:

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

result:

ok 2000000 numbers

Test #30:

score: 0
Accepted
time: 1209ms
memory: 35716kb

input:

1000000
66244 40209
76176 84516
21550 82837
77773 5582
5559 95761
84032 20168
22620 65282
21464 49653
3007 26391
36760 54868
61234 80379
56679 60083
93631 12906
39366 43516
31577 11754
79224 45528
17316 85897
24088 11352
67319 95594
31267 3523
77393 73672
60900 57981
10301 35113
90240 90167
86392 86...

output:

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

result:

ok 2000000 numbers

Test #31:

score: 0
Accepted
time: 1456ms
memory: 37384kb

input:

1000000
33716 86333
78082 49530
21474 47668
73205 73180
88059 33666
43674 81833
28095 83430
52914 94539
10801 84023
52109 55635
55383 16814
32050 72345
23821 44034
3934 47744
23001 78805
35243 35895
69526 48836
18859 29324
92772 5704
34571 69413
71725 5410
39569 15712
22932 43802
15094 16745
16652 1...

output:

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

result:

ok 2000000 numbers

Test #32:

score: 0
Accepted
time: 1175ms
memory: 37656kb

input:

1000000
12384 84496
8042 90565
43763 79033
82386 6923
93934 8195
80923 58872
93939 64253
7398 36352
16469 63767
76143 37052
12419 65210
61917 94071
86972 24218
46978 58100
18217 19275
84204 25951
4961 19766
96754 1609
44063 88544
45622 20585
24882 34363
83617 26248
71764 10471
79667 55898
45380 1614...

output:

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

result:

ok 2000000 numbers

Test #33:

score: 0
Accepted
time: 1411ms
memory: 37692kb

input:

1000000
84862 59467
19427 25109
76511 31863
36483 24696
47587 29382
85817 16947
83729 85476
52372 64991
21415 23673
50163 55527
43484 93931
258 39015
92058 53493
21686 9860
26889 17824
49213 29264
40502 48135
48083 47712
57889 38970
37119 10819
16629 54982
8194 67876
17850 43833
709 38520
52184 6360...

output:

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

result:

ok 2000000 numbers

Test #34:

score: 0
Accepted
time: 1203ms
memory: 37240kb

input:

1000000
30743 11659
29452 64652
8681 95991
66433 19466
46428 82981
83967 57926
98402 97433
66202 65615
7134 47323
66441 53862
74519 55412
59872 92150
86793 96380
18093 85035
10317 48090
84294 85951
11264 25913
80392 64843
61313 78626
40158 10487
74243 70801
62000 50645
76256 44139
84611 27334
58313 ...

output:

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

result:

ok 2000000 numbers

Test #35:

score: 0
Accepted
time: 1404ms
memory: 35820kb

input:

1000000
81694 1842
24985 90222
58881 35158
26260 34329
37775 43086
33944 76122
49180 20581
84739 56357
94278 14692
30735 81315
40357 18697
34839 99519
18915 87635
44233 54467
68181 75949
50638 79422
803 39786
86348 67372
43588 16600
66442 19559
14870 83010
73396 55170
79609 70687
19483 28377
3954 76...

output:

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

result:

ok 2000000 numbers

Test #36:

score: 0
Accepted
time: 1227ms
memory: 36312kb

input:

1000000
54054 76724
52570 98015
35313 64563
45252 39817
55255 55197
73603 60020
33173 84770
85451 35121
68670 92844
38670 48228
27888 83273
30669 97347
84484 28510
16578 62289
14140 20709
32166 87977
60146 52961
63632 14294
33443 28563
1450 48080
62376 91022
30678 25240
33330 4848
65406 97009
55486 ...

output:

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

result:

ok 2000000 numbers

Test #37:

score: 0
Accepted
time: 1414ms
memory: 35688kb

input:

1000000
96301 11230
22366 4596
17682 99663
2760 61593
84190 90413
922 76623
58232 42987
71299 73460
75950 24549
9147 88735
59423 57231
24913 7088
69597 57430
32529 80409
47221 88142
16323 73359
40461 26153
10343 19150
7287 30136
77000 15932
3917 44492
75272 35611
20759 55178
1523 27705
45903 91607
3...

output:

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

result:

ok 2000000 numbers

Test #38:

score: 0
Accepted
time: 1287ms
memory: 35832kb

input:

1000000
7723 62582
76419 30434
5755 5732
82923 62804
68012 87887
28190 70377
32992 43427
54320 28833
43986 88423
91495 23491
27970 53397
58284 3020
11845 71588
82677 34387
79196 86076
65088 3195
68630 94699
82388 5505
82164 55798
4385 43252
7828 7164
39958 97610
13390 2007
85079 63753
1964 72110
161...

output:

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

result:

ok 2000000 numbers

Test #39:

score: 0
Accepted
time: 1420ms
memory: 36660kb

input:

1000000
97428 40768
64212 54813
68856 94505
85921 94191
12455 75604
34811 77271
67049 98514
20056 55685
99604 1472
65773 74359
29643 68755
79175 29978
31946 23704
33988 56184
61829 79450
95704 67406
19795 47752
8837 93423
81310 49200
27360 24804
75153 32467
43656 9194
71073 64341
11648 52919
57921 4...

output:

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

result:

ok 2000000 numbers

Test #40:

score: 0
Accepted
time: 1248ms
memory: 36460kb

input:

1000000
90404 31965
28526 48484
95066 72417
41108 40061
10717 2938
37594 58098
67464 98006
60293 40526
85805 11677
33825 52309
82059 38043
67244 80575
11493 7498
65572 18977
13346 36892
4187 86479
20354 84669
70929 94283
31692 29306
79682 85473
33687 87684
53183 84007
2828 89244
35504 31478
36094 66...

output:

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

result:

ok 2000000 numbers

Test #41:

score: 0
Accepted
time: 1427ms
memory: 36300kb

input:

1000000
87946 4172
13459 56863
78684 39454
60234 78748
58190 76248
23635 27789
35774 95185
52634 24056
60502 77059
24964 81121
88122 80621
16930 24848
36668 23060
3732 68054
90257 69229
46249 4468
98024 44992
94684 85600
95590 17666
15955 46247
42801 57332
14936 17648
13467 83994
33333 51273
56494 8...

output:

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

result:

ok 2000000 numbers

Test #42:

score: 0
Accepted
time: 1337ms
memory: 36552kb

input:

1000000
48814 54954
53539 46038
20211 68458
71478 38521
80311 49344
83826 33361
11656 53873
38662 61597
54380 11045
44697 87626
65296 87623
36005 37546
15458 33068
75005 48444
15816 19774
92373 67198
90651 41206
89163 65726
68317 7843
80560 79224
61402 88490
65026 47195
39694 93734
88297 24953
11789...

output:

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

result:

ok 2000000 numbers

Test #43:

score: 0
Accepted
time: 1478ms
memory: 37660kb

input:

1000000
42029 13819
75724 39564
14806 49871
41430 37831
30373 62983
89264 63089
58399 25780
34377 46622
89141 43961
18559 92752
95266 93008
13445 22281
17122 52697
43443 28256
52662 95551
47139 52916
81243 38021
16932 43417
29091 79786
66669 91954
13551 2187
69569 63368
40140 50105
28642 65552
36968...

output:

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

result:

ok 2000000 numbers

Test #44:

score: 0
Accepted
time: 1342ms
memory: 37308kb

input:

1000000
72481 73285
7531 11798
87316 36735
73941 21281
16793 80419
5446 38881
23092 80998
4300 72132
66386 32079
68873 34498
71680 90654
12791 94163
86525 46768
306 45767
54123 33991
22032 65582
13248 5076
98804 79834
3404 57160
17838 37186
76629 33228
26605 48756
80954 58550
32008 89071
51230 34343...

output:

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

result:

ok 2000000 numbers

Test #45:

score: 0
Accepted
time: 1523ms
memory: 37412kb

input:

1000000
46978 53097
85942 34754
67377 58728
1894 71565
32330 44917
795 79862
48985 10364
64206 45449
68511 34449
76278 11535
80501 2573
1539 34781
17582 69142
51898 18539
85179 54455
79276 98215
81099 67615
51698 52297
68128 54677
3134 79100
70347 58489
75129 55154
49897 87956
98372 29892
26166 2166...

output:

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

result:

ok 2000000 numbers

Test #46:

score: 0
Accepted
time: 1418ms
memory: 37144kb

input:

1000000
78141 27171
58173 5345
1437 11812
55478 93244
12109 16865
87470 16280
29246 94101
44963 58281
47053 30185
31518 88402
40141 4241
85472 84659
16416 33554
49679 69473
52200 84026
44351 55048
53494 83177
98932 22059
22553 85175
38545 51507
51819 38563
7534 95439
63139 58095
74138 88993
771 5650...

output:

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

result:

ok 2000000 numbers

Test #47:

score: 0
Accepted
time: 1462ms
memory: 36924kb

input:

1000000
54879 45761
85244 62000
3068 80052
39175 80487
32953 94277
46029 80275
26360 19879
92920 573
5125 59810
40988 34463
94794 58724
31724 63878
20395 56221
17273 73746
26053 79809
69423 18331
91590 66707
3175 83240
29596 27232
63837 93206
87629 68236
25577 88728
7926 77298
1612 95865
75058 79265...

output:

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

result:

ok 2000000 numbers

Test #48:

score: 0
Accepted
time: 24ms
memory: 26280kb

input:

1
100000 100000

output:

1 0

result:

ok 2 number(s): "1 0"

Extra Test:

score: 0
Extra Test Passed