QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#79583#5523. Graph Problem With Small $n$noimiAC ✓1470ms204280kbC++2026.6kb2023-02-20 14:20:202023-02-20 14:20:24

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-20 14:20:24]
  • 评测
  • 测评结果:AC
  • 用时:1470ms
  • 内存:204280kb
  • [2023-02-20 14:20:20]
  • 提交

answer

#pragma region Macros
#ifdef noimi
#include "my_template.hpp"
#else
// #pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <immintrin.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfenv>
#include <cfloat>
#include <chrono>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <immintrin.h>
#include <initializer_list>
#include <iomanip>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <streambuf>
#include <string>
#include <tuple>
#include <type_traits>
#include <variant>

#ifdef noimi
#define oj_local(a, b) b
#else
#define oj_local(a, b) a
#endif

#define LOCAL if(oj_local(0, 1))
#define OJ if(oj_local(1, 0))

using namespace std;
using ll = long long;
using ull = unsigned long long int;
using i128 = __int128_t;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vc<T>>;
template <typename T> using vvvc = vector<vvc<T>>;
using vi = vc<int>;
using vl = vc<ll>;
using vpi = vc<pii>;
using vpl = vc<pll>;
template <class T> using pq = priority_queue<T>;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template <typename T> int si(const T &x) { return x.size(); }
template <class T, class S> inline bool chmax(T &a, const S &b) { return (a < b ? a = b, 1 : 0); }
template <class T, class S> inline bool chmin(T &a, const S &b) { return (a > b ? a = b, 1 : 0); }
vi iota(int n) {
    vi a(n);
    return iota(a.begin(), a.end(), 0), a;
}
template <typename T> vi iota(const vector<T> &a, bool greater = false) {
    vi res(a.size());
    iota(res.begin(), res.end(), 0);
    sort(res.begin(), res.end(), [&](int i, int j) {
        if(greater) return a[i] > a[j];
        return a[i] < a[j];
    });
    return res;
}

// macros
#define overload5(a, b, c, d, e, name, ...) name
#define overload4(a, b, c, d, name, ...) name
#define endl '\n'
#define REP0(n) for(ll jidlsjf = 0; jidlsjf < n; ++jidlsjf)
#define REP1(i, n) for(ll i = 0; i < (n); ++i)
#define REP2(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP3(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__)
#define per0(n) for(int jidlsjf = 0; jidlsjf < (n); ++jidlsjf)
#define per1(i, n) for(ll i = (n)-1; i >= 0; --i)
#define per2(i, a, b) for(ll i = (a)-1; i >= b; --i)
#define per3(i, a, b, c) for(ll i = (a)-1; i >= (b); i -= (c))
#define per(...) overload4(__VA_ARGS__, per3, per2, per1, per0)(__VA_ARGS__)
#define fore0(a) rep(a.size())
#define fore1(i, a) for(auto &&i : a)
#define fore2(a, b, v) for(auto &&[a, b] : v)
#define fore3(a, b, c, v) for(auto &&[a, b, c] : v)
#define fore4(a, b, c, d, v) for(auto &&[a, b, c, d] : v)
#define fore(...) overload5(__VA_ARGS__, fore4, fore3, fore2, fore1, fore0)(__VA_ARGS__)
#define perm(v) for(bool flag = true; (flag ? exchange(flag, false) : next_permutation(all(v)));)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define drop(s) cout << #s << endl, exit(0)
#define si(c) (int)(c).size()
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define lbg(c, x) distance((c).begin(), lower_bound(all(c), (x), greater{}))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define ubg(c, x) distance((c).begin(), upper_bound(all(c), (x), greater{}))
#define rng(v, l, r) v.begin() + (l), v.begin() + (r)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define SORT(v) sort(all(v))
#define REV(v) reverse(all(v))
#define UNIQUE(x) SORT(x), x.erase(unique(all(x)), x.end())
template <typename T = ll, typename S> T SUM(const S &v) { return accumulate(all(v), T(0)); }
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define overload2(_1, _2, name, ...) name
#define vec(type, name, ...) vector<type> name(__VA_ARGS__)
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
#define vvvv(type, name, a, b, c, ...)                                                                                                                         \
    vector<vector<vector<vector<type>>>> name(a, vector<vector<vector<type>>>(b, vector<vector<type>>(c, vector<type>(__VA_ARGS__))))
constexpr pii dx4[4] = {pii{1, 0}, pii{0, 1}, pii{-1, 0}, pii{0, -1}};
constexpr pii dx8[8] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

namespace yesno_impl {
const string YESNO[2] = {"NO", "YES"};
const string YesNo[2] = {"No", "Yes"};
const string yesno[2] = {"no", "yes"};
const string firstsecond[2] = {"second", "first"};
const string FirstSecond[2] = {"Second", "First"};
const string possiblestr[2] = {"impossible", "possible"};
const string Possiblestr[2] = {"Impossible", "Possible"};
void YES(bool t = 1) { cout << YESNO[t] << endl; }
void NO(bool t = 1) { YES(!t); }
void Yes(bool t = 1) { cout << YesNo[t] << endl; }
void No(bool t = 1) { Yes(!t); }
void yes(bool t = 1) { cout << yesno[t] << endl; }
void no(bool t = 1) { yes(!t); }
void first(bool t = 1) { cout << firstsecond[t] << endl; }
void First(bool t = 1) { cout << FirstSecond[t] << endl; }
void possible(bool t = 1) { cout << possiblestr[t] << endl; }
void Possible(bool t = 1) { cout << Possiblestr[t] << endl; }
}; // namespace yesno_impl
using namespace yesno_impl;

#define INT(...)                                                                                                                                               \
    int __VA_ARGS__;                                                                                                                                           \
    IN(__VA_ARGS__)
#define LL(...)                                                                                                                                                \
    ll __VA_ARGS__;                                                                                                                                            \
    IN(__VA_ARGS__)
#define STR(...)                                                                                                                                               \
    string __VA_ARGS__;                                                                                                                                        \
    IN(__VA_ARGS__)
#define CHR(...)                                                                                                                                               \
    char __VA_ARGS__;                                                                                                                                          \
    IN(__VA_ARGS__)
#define DBL(...)                                                                                                                                               \
    double __VA_ARGS__;                                                                                                                                        \
    IN(__VA_ARGS__)
#define VEC(type, name, size)                                                                                                                                  \
    vector<type> name(size);                                                                                                                                   \
    IN(name)
#define VEC2(type, name1, name2, size)                                                                                                                         \
    vector<type> name1(size), name2(size);                                                                                                                     \
    for(int i = 0; i < size; i++) IN(name1[i], name2[i])
#define VEC3(type, name1, name2, name3, size)                                                                                                                  \
    vector<type> name1(size), name2(size), name3(size);                                                                                                        \
    for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i])
#define VEC4(type, name1, name2, name3, name4, size)                                                                                                           \
    vector<type> name1(size), name2(size), name3(size), name4(size);                                                                                           \
    for(int i = 0; i < size; i++) IN(name1[i], name2[i], name3[i], name4[i]);
#define VV(type, name, h, w)                                                                                                                                   \
    vector<vector<type>> name(h, vector<type>(w));                                                                                                             \
    IN(name)
int scan() { return getchar(); }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(string &a) { cin >> a; }
template <class T, class S> void scan(pair<T, S> &p) { scan(p.first), scan(p.second); }
template <class T> void scan(vector<T> &);
template <class T> void scan(vector<T> &a) {
    for(auto &i : a) scan(i);
}
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &...tail) {
    scan(head);
    IN(tail...);
}

template <typename T, typename S> T ceil(T x, S y) {
    assert(y);
    return (y < 0 ? ceil(-x, -y) : (x > 0 ? (x + y - 1) / y : x / y));
}

template <typename T, typename S> T floor(T x, S y) {
    assert(y);
    return (y < 0 ? floor(-x, -y) : (x > 0 ? x / y : x / y - (x % y == 0 ? 0 : 1)));
}
template <typename T, typename S, typename U> U bigmul(const T &x, const S &y, const U &lim) { // clamp(x * y, -lim, lim)
    if(x < 0 and y < 0) return bigmul(-x, -y, lim);
    if(x < 0) return -bigmul(-x, y, lim);
    if(y < 0) return -bigmul(x, -y, lim);
    return y == 0 or x <= lim / y ? x * y : lim;
}
template <class T> T POW(T x, int n) {
    T res = 1;
    for(; n; n >>= 1, x *= x)
        if(n & 1) res *= x;
    return res;
}
template <class T, class S> T POW(T x, S n, const ll &mod) {
    T res = 1;
    x %= mod;
    for(; n; n >>= 1, x = x * x % mod)
        if(n & 1) res = res * x % mod;
    return res;
}
vector<pll> factor(ll x) {
    vector<pll> ans;
    for(ll i = 2; i * i <= x; i++)
        if(x % i == 0) {
            ans.push_back({i, 1});
            while((x /= i) % i == 0) ans.back().second++;
        }
    if(x != 1) ans.push_back({x, 1});
    return ans;
}
template <class T> vector<T> divisor(T x) {
    vector<T> ans;
    for(T i = 1; i * i <= x; i++)
        if(x % i == 0) {
            ans.pb(i);
            if(i * i != x) ans.pb(x / i);
        }
    return ans;
}
template <typename T> void zip(vector<T> &x) {
    vector<T> y = x;
    UNIQUE(y);
    for(int i = 0; i < x.size(); ++i) { x[i] = lb(y, x[i]); }
}
template <class S> void fold_in(vector<S> &v) {}
template <typename Head, typename... Tail, class S> void fold_in(vector<S> &v, Head &&a, Tail &&...tail) {
    for(auto e : a) v.emplace_back(e);
    fold_in(v, tail...);
}
template <class S> void renumber(vector<S> &v) {}
template <typename Head, typename... Tail, class S> void renumber(vector<S> &v, Head &&a, Tail &&...tail) {
    for(auto &&e : a) e = lb(v, e);
    renumber(v, tail...);
}
template <class S, class... Args> vector<S> zip(vector<S> &head, Args &&...args) {
    vector<S> v;
    fold_in(v, head, args...);
    sort(all(v)), v.erase(unique(all(v)), v.end());
    renumber(v, head, args...);
    return v;
}

template <typename S> void rearrange(const vector<S> &id) {}
template <typename S, typename T> void rearrange_exec(const vector<S> &id, vector<T> &v) {
    vector<T> w(v.size());
    rep(i, si(id)) w[i] = v[id[i]];
    v.swap(w);
}
// 並び替える順番, 並び替える vector 達
template <typename S, typename Head, typename... Tail> void rearrange(const vector<S> &id, Head &a, Tail &...tail) {
    rearrange_exec(id, a);
    rearrange(id, tail...);
}

template <typename T> vector<T> RUI(const vector<T> &v) {
    vector<T> res(v.size() + 1);
    for(int i = 0; i < v.size(); i++) res[i + 1] = res[i] + v[i];
    return res;
}
template <typename T> void zeta_supersetsum(vector<T> &f) {
    int n = f.size();
    for(int i = 1; i < n; i <<= 1) rep(b, n) if(!(i & b)) f[b] += f[b | i];
}

template <typename T> void zeta_subsetsum(vector<T> &f) {
    int n = f.size();
    for(int i = 1; i < n; i <<= 1) rep(b, n) if(!(i & b)) f[b | i] += f[b];
}
template <typename T> void mobius_subset(vector<T> &f) {
    int n = f.size();
    for(int i = 1; i < n; i <<= 1) rep(b, n) if(!(i & b)) f[b] -= f[b | i];
}
template <typename T> void mobius_superset(vector<T> &f) {
    int n = f.size();
    for(int i = 1; i < n; i <<= 1) rep(b, n) if(!(i & b)) f[b | i] -= f[b];
}
// 反時計周りに 90 度回転
template <typename T> void rot(vector<vector<T>> &v) {
    if(empty(v)) return;
    int n = v.size(), m = v[0].size();
    vector<vector<T>> res(m, vector<T>(n));
    rep(i, n) rep(j, m) res[m - 1 - j][i] = v[i][j];
    v.swap(res);
}
// x in [l, r)
template <class T, class S> bool inc(const T &x, const S &l, const S &r) { return l <= x and x < r; }

// 便利関数
constexpr ll ten(int n) { return n == 0 ? 1 : ten(n - 1) * 10; }
constexpr ll tri(ll n) { return n * (n + 1) / 2; }
// l + ... + r
constexpr ll tri(ll l, ll r) { return (l + r) * (r - l + 1) / 2; }
ll max(int x, ll y) { return max((ll)x, y); }
ll max(ll x, int y) { return max(x, (ll)y); }
int min(int x, ll y) { return min((ll)x, y); }
int min(ll x, int y) { return min(x, (ll)y); }
// bit 演算系
#define bit(i) (1LL << i)       // (1 << i)
#define test(b, i) (b >> i & 1) // b の i bit 目が立っているか
ll pow2(int i) { return 1LL << i; }
int topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); }
int topbit(ll t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); }
int lowbit(signed a) { return a == 0 ? 32 : __builtin_ctz(a); }
int lowbit(ll a) { return a == 0 ? 64 : __builtin_ctzll(a); }
// int allbit(int n) { return (1 << n) - 1; }
constexpr ll mask(int n) { return (1LL << n) - 1; }
// int popcount(signed t) { return __builtin_popcount(t); }
// int popcount(ll t) { return __builtin_popcountll(t); }
int popcount(uint64_t t) { return __builtin_popcountll(t); }
static inline uint64_t popcount64(uint64_t x) {
    uint64_t m1 = 0x5555555555555555ll;
    uint64_t m2 = 0x3333333333333333ll;
    uint64_t m4 = 0x0F0F0F0F0F0F0F0Fll;
    uint64_t h01 = 0x0101010101010101ll;

    x -= (x >> 1) & m1;
    x = (x & m2) + ((x >> 2) & m2);
    x = (x + (x >> 4)) & m4;

    return (x * h01) >> 56;
}
bool ispow2(int i) { return i && (i & -i) == i; }

ll rnd(ll l, ll r) { //[l, r)
#ifdef noimi
    static mt19937_64 gen;
#else
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
#endif
    return uniform_int_distribution<ll>(l, r - 1)(gen);
}
ll rnd(ll n) { return rnd(0, n); }

template <class t> void random_shuffle(vc<t> &a) { rep(i, si(a)) swap(a[i], a[rnd(0, i + 1)]); }

int in() {
    int x;
    cin >> x;
    return x;
}
ll lin() {
    unsigned long long x;
    cin >> x;
    return x;
}

template <class T, class S> pair<T, S> operator-(const pair<T, S> &x) { return pair<T, S>(-x.first, -x.second); }
template <class T, class S> pair<T, S> operator-(const pair<T, S> &x, const pair<T, S> &y) { return pair<T, S>(x.fi - y.fi, x.se - y.se); }
template <class T, class S> pair<T, S> operator+(const pair<T, S> &x, const pair<T, S> &y) { return pair<T, S>(x.fi + y.fi, x.se + y.se); }
template <class T> pair<T, T> operator&(const pair<T, T> &l, const pair<T, T> &r) { return pair<T, T>(max(l.fi, r.fi), min(l.se, r.se)); }
template <class T, class S> pair<T, S> operator+=(pair<T, S> &l, const pair<T, S> &r) { return l = l + r; }
template <class T, class S> pair<T, S> operator-=(pair<T, S> &l, const pair<T, S> &r) { return l = l - r; }
template <class T> bool intersect(const pair<T, T> &l, const pair<T, T> &r) { return (l.se < r.se ? r.fi < l.se : l.fi < r.se); }

template <class T> vector<T> &operator++(vector<T> &v) {
    fore(e, v) e++;
    return v;
}
template <class T> vector<T> operator++(vector<T> &v, int) {
    auto res = v;
    fore(e, v) e++;
    return res;
}
template <class T> vector<T> &operator--(vector<T> &v) {
    fore(e, v) e--;
    return v;
}
template <class T> vector<T> operator--(vector<T> &v, int) {
    auto res = v;
    fore(e, v) e--;
    return res;
}
template <class T> vector<T> &operator+=(vector<T> &l, const vector<T> &r) {
    fore(e, r) l.eb(e);
    return l;
}

template <typename T> struct edge {
    int from, to;
    T cost;
    int id;
    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}
    edge(int from, int to, T cost, int id) : from(from), to(to), cost(cost), id(id) {}
    constexpr bool operator<(const edge<T> &rhs) const noexcept { return cost < rhs.cost; }
    edge &operator=(const int &x) {
        to = x;
        return *this;
    }
    operator int() const { return to; }
    friend ostream operator<<(ostream &os, const edge &e) { return os << e.to; }
};
template <typename T> using Edges = vector<edge<T>>;

template <typename T = int> Edges<T> read_edges(int m, bool weighted = false) {
    Edges<T> res;
    res.reserve(m);
    for(int i = 0; i < m; i++) {
        int u, v, c = 0;
        scan(u), scan(v), u--, v--;
        if(weighted) scan(c);
        res.eb(u, v, c, i);
    }
    return res;
}

using Tree = vector<vector<int>>;
using Graph = vector<vector<int>>;
template <class T> using Wgraph = vector<vector<edge<T>>>;
Graph getG(int n, int m = -1, bool directed = false, int margin = 1) {
    Tree res(n);
    if(m == -1) m = n - 1;
    while(m--) {
        int a, b;
        cin >> a >> b;
        a -= margin, b -= margin;
        res[a].emplace_back(b);
        if(!directed) res[b].emplace_back(a);
    }
    return res;
}
Graph getTreeFromPar(int n, int margin = 1) {
    Graph res(n);
    for(int i = 1; i < n; i++) {
        int a;
        cin >> a;
        res[a - margin].emplace_back(i);
    }
    return res;
}
template <class T> Wgraph<T> getWg(int n, int m = -1, bool directed = false, int margin = 1) {
    Wgraph<T> res(n);
    if(m == -1) m = n - 1;
    while(m--) {
        int a, b;
        T c;
        scan(a), scan(b), scan(c);
        a -= margin, b -= margin;
        res[a].emplace_back(b, c);
        if(!directed) res[b].emplace_back(a, c);
    }
    return res;
}
void add(Graph &G, int x, int y) { G[x].eb(y), G[y].eb(x); }
template <class S, class T> void add(Wgraph<S> &G, int x, int y, T c) { G[x].eb(y, c), G[y].eb(x, c); }

#define TEST                                                                                                                                                   \
    INT(testcases);                                                                                                                                            \
    while(testcases--)

i128 abs(const i128 &x) { return x > 0 ? x : -x; }
istream &operator>>(istream &is, i128 &v) {
    string s;
    is >> s;
    v = 0;
    for(int i = 0; i < (int)s.size(); i++) {
        if(isdigit(s[i])) { v = v * 10 + s[i] - '0'; }
    }
    if(s[0] == '-') { v *= -1; }
    return is;
}

ostream &operator<<(ostream &os, const i128 &v) {
    if(v == 0) { return (os << "0"); }
    i128 num = v;
    if(v < 0) {
        os << '-';
        num = -num;
    }
    string s;
    for(; num > 0; num /= 10) { s.push_back((char)(num % 10) + '0'); }
    reverse(s.begin(), s.end());
    return (os << s);
}
namespace aux {
template <typename T, unsigned N, unsigned L> struct tp {
    static void output(std::ostream &os, const T &v) {
        os << std::get<N>(v) << (&os == &cerr ? ", " : " ");
        tp<T, N + 1, L>::output(os, v);
    }
};
template <typename T, unsigned N> struct tp<T, N, N> {
    static void output(std::ostream &os, const T &v) { os << std::get<N>(v); }
};
} // namespace aux
template <typename... Ts> std::ostream &operator<<(std::ostream &os, const std::tuple<Ts...> &t) {
    if(&os == &cerr) { os << '('; }
    aux::tp<std::tuple<Ts...>, 0, sizeof...(Ts) - 1>::output(os, t);
    if(&os == &cerr) { os << ')'; }
    return os;
}
template <typename T, typename S, typename U> std::ostream &operator<<(std::ostream &os, const priority_queue<T, S, U> &_pq) {
    auto pq = _pq;
    vector<T> res;
    while(!empty(pq)) res.emplace_back(pq.top()), pq.pop();
    return os << res;
}
template <class T, class S> ostream &operator<<(ostream &os, const pair<T, S> &p) {
    if(&os == &cerr) { return os << "(" << p.first << ", " << p.second << ")"; }
    return os << p.first << " " << p.second;
}
template <class Ch, class Tr, class Container> std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, const Container &x) {
    bool f = true;
    if(&os == &cerr) os << "[";
    for(auto &y : x) {
        if(&os == &cerr)
            os << (f ? "" : ", ") << y;
        else
            os << (f ? "" : " ") << y;
        f = false;
    }
    if(&os == &cerr) os << "]";
    return os;
}

#define dump(...) static_cast<void>(0)
#define dbg(...) static_cast<void>(0)

void OUT() { cout << endl; }
template <class Head, class... Tail> void OUT(const Head &head, const Tail &...tail) {
    cout << head;
    if(sizeof...(tail)) cout << ' ';
    OUT(tail...);
}

template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
template <class T, class S> constexpr pair<T, S> inf<pair<T, S>> = {inf<T>, inf<S>};

template <class T> void OUT2(const T &t, T INF = inf<T>, T res = -1) { OUT(t != INF ? t : res); }
template <class T> void OUT2(vector<T> &v, T INF = inf<T>, T res = -1) {
    fore(e, v) if(e == INF) e = res;
    OUT(v);
    fore(e, v) if(e == res) e = INF;
}

template <class F> struct REC {
    F f;
    REC(F &&f_) : f(forward<F>(f_)) {}
    template <class... Args> auto operator()(Args &&...args) const { return f(*this, forward<Args>(args)...); }
};

template <class S> vector<pair<S, int>> runLength(const vector<S> &v) {
    vector<pair<S, int>> res;
    for(auto &e : v) {
        if(res.empty() or res.back().fi != e)
            res.eb(e, 1);
        else
            res.back().se++;
    }
    return res;
}
vector<pair<char, int>> runLength(const string &v) {
    vector<pair<char, int>> res;
    for(auto &e : v) {
        if(res.empty() or res.back().fi != e)
            res.eb(e, 1);
        else
            res.back().se++;
    }
    return res;
}

struct string_converter {
    char start = 0;
    char type(const char &c) const { return (islower(c) ? 'a' : isupper(c) ? 'A' : isdigit(c) ? '0' : 0); }
    int convert(const char &c) {
        if(!start) start = type(c);
        return c - start;
    }
    int convert(const char &c, const string &chars) { return chars.find(c); }
    template <typename T> auto convert(const T &v) {
        vector<decltype(convert(v[0]))> ret;
        ret.reserve(size(v));
        for(auto &&e : v) ret.emplace_back(convert(e));
        return ret;
    }
    template <typename T> auto convert(const T &v, const string &chars) {
        vector<decltype(convert(v[0], chars))> ret;
        ret.reserve(size(v));
        for(auto &&e : v) ret.emplace_back(convert(e, chars));
        return ret;
    }
    int operator()(const char &v, char s = 0) {
        start = s;
        return convert(v);
    }
    int operator()(const char &v, const string &chars) { return convert(v, chars); }
    template <typename T> auto operator()(const T &v, char s = 0) {
        start = s;
        return convert(v);
    }
    template <typename T> auto operator()(const T &v, const string &chars) { return convert(v, chars); }
} toint;

template <class T, class F> T bin_search(T ok, T ng, const F &f) {
    while(abs(ok - ng) > 1) {
        T mid = ok + ng >> 1;
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}
template <class T, class F> T bin_search_double(T ok, T ng, const F &f, int iter = 80) {
    while(iter--) {
        T mid = (ok + ng) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}

struct Setup_io {
    Setup_io() {
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        cout << fixed << setprecision(11);
    }
} setup_io;

#endif
#pragma endregion

constexpr int N = 24, M = 20;

int ans[N - M][1 << N], tmp[1 << N];

int f[N], idx, to[N], oks[1 << N];

#define setbits(j, n) for(int iiiii = n, j = lowbit(iiiii); iiiii; iiiii ^= 1 << j, j = lowbit(iiiii))

int main() {

    INT(n);
    VV(char, s, n, n);
    auto a = toint(s);
    rep(i, n) rep(j, n) if(a[i][j]) to[i] |= bit(j);

    vi out;
    rep(i, 1, 1 << n) {
        int l = lowbit(i);
        oks[i] = oks[i ^ bit(l)] | to[l];
    }

    per(i, N, M) {
        if(i >= n) continue;
        ans[i - M][bit(i)] = bit(i);
        rep(b, 1, 1 << n) {
            if(!test(b, i)) continue;
            idx = 0;
            int ok = oks[ans[i - M][b]] & ~b;
            setbits(j, ok) ans[i - M][b | bit(j)] |= bit(j);
        }
        out.eb(ans[i - M][mask(n)]);
    }

    per(i, M) {
        if(i >= n) continue;
        rep(j, 1 << M) tmp[j] = 0;
        int res = 0;
        tmp[bit(i)] = bit(i);

        rep(b, 1 << M) {
            if(!tmp[b]) continue;
            int ok = oks[tmp[b]] & ~b;
            setbits(j, ok) {
                if(j < M)
                    tmp[b | bit(j)] |= bit(j);
                else
                    res |= ans[j - M][mask(n) ^ b];
            }
        }
        out.eb(res | tmp[mask(n)]);
    }
    REV(out);
    rep(i, n) {
        rep(j, n) cout << test(out[i], j);
        OUT();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 6ms
memory: 7548kb

input:

4
0110
1010
1101
0010

output:

0001
0001
0000
1100

result:

ok 4 lines

Test #2:

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

input:

6
010001
101000
010100
001010
000101
100010

output:

010001
101000
010100
001010
000101
100010

result:

ok 6 lines

Test #3:

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

input:

4
0111
1011
1101
1110

output:

0111
1011
1101
1110

result:

ok 4 lines

Test #4:

score: 0
Accepted
time: 28ms
memory: 40336kb

input:

23
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000...

output:

00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000000...

result:

ok 23 lines

Test #5:

score: 0
Accepted
time: 51ms
memory: 40364kb

input:

23
00010100000000000101000
00000000010000000001000
00000000000001000000001
10000000000000000010000
00000000000000000000000
10000000000000000000000
00000001000000000000000
00000010000000000010000
00000000000001000000000
01000000000000000000000
00000000000000000000000
00000000000000000000000
000000000...

output:

00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000000...

result:

ok 23 lines

Test #6:

score: 0
Accepted
time: 38ms
memory: 49908kb

input:

23
00001000000000000000000
00001000010001000000000
00000000000101000010000
00001000000100000000000
11010000010011000100000
00000000000100000000000
00000000000000000000001
00000000000000000101000
00000000000000000000000
01001000000000101010010
00000000000000000000101
00110100000010001000000
000010000...

output:

00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000000...

result:

ok 23 lines

Test #7:

score: 0
Accepted
time: 53ms
memory: 74116kb

input:

23
01000000000001101001100
10000001101000000000000
00000100000100010000100
00000000000000001011000
00000100001000000000000
00101000000000001000001
00000000000000000000000
01000000000000000000000
01000000000100000010000
00000000000001000000011
01001000000000010000000
00100000100001000100001
000000000...

output:

00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
00000000000000000000000
000000000000...

result:

ok 23 lines

Test #8:

score: 0
Accepted
time: 92ms
memory: 83772kb

input:

23
00000000010001001001010
00100010001101110000001
01000001000100110000000
00000011010001101100100
00000000010000010001000
00000000000000001001000
01010001000000000000001
00110010000000000000010
00000000011000100100000
10011000101000100000000
01000000110010101010000
01100000000000000000000
000000000...

output:

01111111110111110110111
10011111110111110110111
10011111110111110110111
11101111110110110110111
11110111110111110110111
11111011110111111111111
11111101110111110110111
11111110110111110110111
11111111010111110110111
11111111100110100110111
00000000000010000010100
11111111110011110110111
111111111111...

result:

ok 23 lines

Test #9:

score: 0
Accepted
time: 138ms
memory: 72232kb

input:

23
00001000001001000000000
00101100111110100000000
01001000100001011010000
00000000010000010010000
11100001100001000000010
01000010101010100011011
00000100000100100010000
00001000011000000010001
01101100000000011001001
01010001000010011000000
11000101000110001100000
01000010001000000000010
010001000...

output:

00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
00000000000000000000100
000000000000...

result:

ok 23 lines

Test #10:

score: 0
Accepted
time: 206ms
memory: 77320kb

input:

23
00001011110010000000001
00000100000011000000100
00010011010100000000011
00100011011001010100100
10000101000110100000000
01001000001010001000100
10110000000110000010000
10111000001100010100010
10000000000010001000110
10110000001110100110001
00010101010100001000000
00101011011000100100011
110011101...

output:

00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
00000000000000000001000
000000000000...

result:

ok 23 lines

Test #11:

score: 0
Accepted
time: 313ms
memory: 89500kb

input:

23
00100100001000000100001
00101110110000100100001
11000000000101001000100
00000000010000001111010
01000011010001011001010
11000000010100001001011
01001000001010101000100
00001000001010000000000
01000000000001100001011
01011100001101100000000
10000011010010100000010
00100100010000000001000
000000110...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #12:

score: 0
Accepted
time: 456ms
memory: 89508kb

input:

23
00000001011001011100100
00000001010000000010100
00000001010010100010000
00001000100111100000000
00010100011000010111001
00001000100001000010010
00000001111001100011000
11100010111100110001001
00010111010000101100110
11101011100000100100100
10001011000010100000010
00010001000001011101110
001100000...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #13:

score: 0
Accepted
time: 462ms
memory: 89496kb

input:

23
00100100001101000100000
00010111011000100000010
10000010010001111000010
01001011101001000100000
00010000010110000100111
11000000101000011101001
01110001100000010101100
01010010001001010100000
00010110001100010010001
01101000000011000111000
11010101100010010001101
10001000100010001110100
000010000...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #14:

score: 0
Accepted
time: 552ms
memory: 89536kb

input:

23
01001101001011010101100
10001010111100100001110
00000000010101000111100
00000000001010010100010
11000000100110000111000
10000010001000010101000
01000100100010001100101
10000000010001000110110
01001010000001111100000
01100001000001001101001
11010100000011001010111
01101000000000100100110
100110100...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #15:

score: 0
Accepted
time: 727ms
memory: 89536kb

input:

23
01100101000101001000001
10111000100000010110010
11011010011101000010010
01100010001111011011111
01100010011110001111100
10000000011000001011010
00111001001000101100111
10000010110110011000000
01000001001110010100100
00101101000100111100001
00111110100110011011010
10111001111010001010000
000110011...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #16:

score: 0
Accepted
time: 540ms
memory: 89500kb

input:

23
01111001001110001000101
10000000000100111111110
10010101000110100100101
10101000001010010101001
10010010011110101101111
00100000101100011000000
00001000011000010001101
10100000010000000000100
00000100010110001111100
00001011100101010110111
10011110000000010101101
11101100110010010100000
101110001...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #17:

score: 0
Accepted
time: 617ms
memory: 89528kb

input:

23
01010000000100001110001
10000110010001110010100
00011000101111001010110
10101111011100101100111
00110011111111111011000
01010011100001111011011
01011100001111000011101
00011100001110111010010
00101100011101001000011
01011000100000000000010
00111011100001001000111
10111011100000110100001
001010110...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #18:

score: 0
Accepted
time: 673ms
memory: 89508kb

input:

23
00100101011111000101011
00100001000110000111101
11010000011110010110011
00101101110110000101110
00010101111001110101110
10011001111101010011101
00000000110011000000100
11011100110111001110110
00011111000000100110010
10111111000111101010010
10101100000111111010100
11110101011010101010010
111100110...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #19:

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

input:

23
00100001100011011101011
00111011101101101011001
11001101100100001000111
01001010110101101000010
01110011001111000101111
00100011100000111101010
01011100000110101001100
11101100010110110011000
11110100010010000011010
00010001101011011011011
01001000010001001011111
01111011000010101011101
100010111...

output:

01111111111111111111111
10111111111111111111111
11011111111111111111111
11101111111111111111111
11110111111111111111111
11111011111111111111111
11111101111111111111111
11111110111111111111111
11111111011111111111111
11111111101111111111111
11111111110111111111111
11111111111011111111111
111111111111...

result:

ok 23 lines

Test #20:

score: 0
Accepted
time: 82ms
memory: 73140kb

input:

24
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
0000000000000000000000...

output:

000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
...

result:

ok 24 lines

Test #21:

score: 0
Accepted
time: 92ms
memory: 73136kb

input:

24
000000000000100000000000
000000000000000000001000
000000000000000001000000
000000100000000000000000
000000000000000000000001
000000000000000001000000
000100000000100100000000
000000000000000000000000
000000000000000000000000
000000000000010000000000
000000000000000000000000
0000000000000000010000...

output:

000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
...

result:

ok 24 lines

Test #22:

score: 0
Accepted
time: 83ms
memory: 82804kb

input:

24
000000000010000010000000
000000010100100000010010
000010010000000000000000
000000010000000001000000
001000000000001000000000
000000000100101000000000
000000000000000000000000
011100000001000000000000
000000000010000000000000
010001000000000010100001
100000001000000101000000
0000000100000000100100...

output:

000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
...

result:

ok 24 lines

Test #23:

score: 0
Accepted
time: 106ms
memory: 135904kb

input:

24
000001001001101000001101
000000000000011000100100
000000000000010000000000
000000010000000000000000
000000000000000000000000
100000010000000110000000
000000000001000000010000
000101000000000010000000
100000000001011100011100
000000000000000000100000
000000000000000010001000
1000001010001000000010...

output:

000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
...

result:

ok 24 lines

Test #24:

score: 0
Accepted
time: 202ms
memory: 180700kb

input:

24
011010010001001000000011
100000000000000111000001
100110000100100100010001
001011000100001000110000
101101000000000111000010
000110110000010000010000
000001000000000000000000
100001000001100001000001
000000000001000000110011
001100000000010000001000
000000000000000100000000
1000000110000010000000...

output:

000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000000010000000000000
000000000000000000000000
000000000000000000000000
000000000000000000000000
000000100000000000000000
000000000000000000000000
...

result:

ok 24 lines

Test #25:

score: 0
Accepted
time: 362ms
memory: 193772kb

input:

24
010001010000000000000100
101011011100001011001100
010101010010000100000000
001001101010000000110010
010000000000000000001010
111100000010001101000100
000100000000010000110000
111000000000000011000001
010100000010000000010100
010000000000000001000001
001101001001100110000001
0000000000100100001000...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111110111111
111111111110111111111111
...

result:

ok 24 lines

Test #26:

score: 0
Accepted
time: 762ms
memory: 204220kb

input:

24
010001000001001010000001
100001001110101011001010
000000011000010000000100
000000010000100001110101
000000011001000001100010
110000000000000000011000
000000001000000100011010
001110001010000001110001
011010110000010000001001
010000000000100111100101
010000010000001000000000
1000100000000100101110...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #27:

score: 0
Accepted
time: 594ms
memory: 204212kb

input:

24
010000000000000010000000
100000111000100110000011
000000111110010111000000
000001100001010000001100
000000001000000000110100
000100000100000101101111
011100010111010000110100
011000100010100000100010
011010000011001110000001
001001100010001001000010
001000111100000000100000
0001001010001100001000...

output:

011111111111111111111111
101111111111111101111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #28:

score: 0
Accepted
time: 643ms
memory: 204160kb

input:

24
000100000000010010100000
000000001101000010011011
000000000011000000010000
100010100000100000010000
000100000010110101100001
000000111010100000100101
000101000110000011000000
000001001100101010000011
010001010000000010000101
010000110001011001010000
001011100000010010000011
0110000001000101100101...

output:

011111111111111111111111
101111111111111111011111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #29:

score: 0
Accepted
time: 912ms
memory: 204200kb

input:

24
000000000010110010000001
001010001011101000000110
010001001110000000010000
000000100010000010011101
010001101010010011010100
001010000000011101000010
000110000100101011001111
000000001000110000100000
011010010110000000000000
001000101010001010000100
111110001100100010011101
0100000000001011100000...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #30:

score: 0
Accepted
time: 1270ms
memory: 204280kb

input:

24
010001111000001000000110
100001111000000110010000
000011000101000101100100
000001111111000110100100
001000001010010000111000
111100100000000001110000
110101011101000000001101
110100101000001011000100
110110110011001000000000
001100100000000011011001
000110001000100101110111
0011001010000110110100...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #31:

score: 0
Accepted
time: 1364ms
memory: 204208kb

input:

24
010000010100011100001111
101010011110111111001010
010101011011100101111100
001000110000100010011011
010000000001010100001011
001000100000011000111001
000101011011001000001100
111100100011010011010100
011000100001000001111111
110000000011110100100010
011000110101000100001000
0010101111101100010001...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #32:

score: 0
Accepted
time: 1122ms
memory: 198560kb

input:

24
001011000000111000011011
000100110101100000000100
100001101100110011000010
010011011110101000000110
100101010000100001011110
101110111100100000011111
011001011000001001110011
010111100001110001000110
001101100001110001011011
011101000010010001000100
000100000100001010110110
0100000110000100100100...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #33:

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

input:

24
000010011100100010110100
001011100011110001101010
010001000110100000000111
000001101101011000000111
110000101111000010001111
011100000000011010011000
010110000011100001101010
100000001011101011011101
100110010101101010011010
101110001001010101100101
011010110000011111100000
0101101111000100011011...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #34:

score: 0
Accepted
time: 1470ms
memory: 204244kb

input:

24
001101101101001010011100
000010000000011001010101
100011110111100001101011
100011100011110101101100
011100010010001110010110
101100111100000110101100
101101000101011000101101
001011001101010110010101
100001010101110001010110
101001111011110111000000
001110000100011000101101
1011001111001111100101...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #35:

score: 0
Accepted
time: 1453ms
memory: 204280kb

input:

24
010010110101111110011001
101100001000000100001010
010010101100010111001100
010011001101001011100111
101100011111101011010101
000100010011010011101011
101000001111101010000101
100011001000011110000111
011110110010101000100011
101110100011000101001001
000011101101010110110100
1001111001101010010000...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #36:

score: 0
Accepted
time: 261ms
memory: 88516kb

input:

23
01111101111011111111001
10111101111011111111111
11011101111011111111001
11101101111011111111001
11110111111111111111101
11111001111011111111001
00001000000100000000100
11111100111011111111001
11111101011011111111001
11111101101011111111001
11111101110011111111001
00001010000000000000100
111111011...

output:

01111111111111111111011
10110101111011111111011
11011111111111111111011
11101111111111111111011
10110111111111111111001
11111011111111111111011
10111101111111111111111
11111110111111111111011
11111111011111111111011
11111111101111111111011
11111111110111111111011
10111111111011111111111
111111111111...

result:

ok 23 lines

Test #37:

score: 0
Accepted
time: 169ms
memory: 79260kb

input:

23
00100000001010010010110
00011111110111101101001
10000000000010000010110
01001111110111101101001
01010111110111101101001
01011011110111101101001
01011101110111101101001
01011110110111101101001
01011111010111101101001
01011111100111111101001
10000000000000010000000
01011111110011101101001
111111111...

output:

00100000001000000010110
00111111111111111111111
11011111101111101111111
01101111111111111111111
01110111111111111111111
01111011111111111111111
01111101111111111111111
01111110111111111111111
01111111011111111111111
01011111101101111101001
11111111110101111111111
01111111111011111111111
011111111001...

result:

ok 23 lines

Test #38:

score: 0
Accepted
time: 64ms
memory: 55408kb

input:

23
00000000000100011000000
00000010001000000011000
00001011010111000000011
00000100100000000101100
00100011010111000000011
00010000100000000101100
01101001011111000011011
00101010010111000000011
00010100000000000101100
00101011000111000000011
01000010000000000011000
10101011010011011000011
001010110...

output:

00101001010111111000011
00111111111011000111011
11001011011111001010011
01000100101000100111100
11100011011111001010011
01010000101000100111100
01101001011011000010011
11101010011111001010011
01010100001000100111100
11101011001111001010011
01111111110011000111011
10101001010011001000011
111010110111...

result:

ok 23 lines

Test #39:

score: 0
Accepted
time: 72ms
memory: 57348kb

input:

23
00000000010100001010010
00011001100010100000001
00000110001011010100100
01001001100010100001001
01010001100010100000001
00100010001011010110100
00100100001011010100100
01011000100010100000001
01011001000010100000001
10000000000100001010010
00100110000011010100100
10000000010000001010010
011111111...

output:

00100110011101011111110
00111011101011110101101
11001111111111110110111
01001001100000100001001
01110011101011110101101
10100010011101010110110
11101101111111110110111
01111010101011110101101
01111011001011110101101
10100110001101011111110
11101111110111110110111
10100110011001011111110
011010111010...

result:

ok 23 lines

Test #40:

score: 0
Accepted
time: 41ms
memory: 52092kb

input:

23
00010100000000001100000
00010000000011000000001
00000011000100010011010
11000100000011001100001
00000100001000000000000
10011000001000001100000
00100001000100010011010
00100010000100010011010
00000000000000100010100
00000000000000010000001
00001100000000000000100
00100011000000010011010
010100000...

output:

01011100000011001100000
10010000010011001100001
00000011110100110011010
11000000000011001100000
10000100101000101100100
10001000000000001100000
00100001110100110011010
00100010110100110011010
00101011001100100011110
01100011000111010001011
00001000100000100000100
00100011110000110011010
110100000100...

result:

ok 23 lines

Test #41:

score: 0
Accepted
time: 44ms
memory: 55356kb

input:

23
00100010100001001001000
00000001000010000000010
10010010110101111011000
00100000010100110010010
00000101001000000000100
00001001001000000000000
10100000100001001001000
01001100001010000000010
10100010000001001001000
00110000000100110010000
00001101000000000000000
00110000010000110010000
010000010...

output:

00100010110101111111001
00010101011110110010010
10000010110101111010000
01000000010110110010010
00000100001000000100100
01001001001010000100100
10100000110101111111001
01000100001010000000000
10100010010101111111001
11110010100111111010010
01001101000010000100100
11110010110011111010010
010101010111...

result:

ok 23 lines

Test #42:

score: 0
Accepted
time: 57ms
memory: 47280kb

input:

23
00000001001000011010000
00001110000100000001011
00000000010000100000100
00000000000011100100000
01000110000100000001011
01001010000100000001011
01001100000100000001011
10000000001000001010000
00000000000010000000001
00100000000000010000000
10000001000100001010000
01001110001000000001011
000100001...

output:

00000001000000011010000
00001111101100001011011
00000000010000000000100
00000000100011100100100
01000111101100001011011
01001011101100001011011
01001101101100001011011
11001110001100011011010
01011110000011000101011
00100000000000010000100
01001111000100001011010
01001111001000001011010
000100001000...

result:

ok 23 lines

Test #43:

score: 0
Accepted
time: 47ms
memory: 50040kb

input:

23
00000000000010000010100
00000011000000010000000
00000101000000100001000
00000000110000000000000
00000000101000101100001
00100001000000100001000
01000001000000000000000
01100110000000100001000
00011000011000000000000
00010000100001000000010
00001000100000000000000
00000000000001000010000
100000000...

output:

00000000000110010010100
00000010000000010000000
00000111000000101101001
00000000111000000000010
00000000001000001100001
00100011000000101101001
01100101000000010001000
00100110000000000001000
00010000001000000000000
00010000000000000000010
00011000100000001100001
10000000000001000010110
100000000000...

result:

ok 23 lines

Test #44:

score: 0
Accepted
time: 56ms
memory: 47512kb

input:

23
00000000100000000001011
00000001000010000010000
00000000000101010100100
00001000010100001000000
00010000010000001000000
00000010000000000101000
00000100000000000101000
01000000000000000010010
10000000000000000000011
00011000001000101000000
00000000010000100000000
00110000000001010100100
010000000...

output:

00000110100000000001001
00000000000010000010000
00011110000101011100100
00101000000101011000100
00110000011101011000100
10100010100001010101101
10100100100001010101101
00000000100000000010011
10000111000000000011011
00001000001000001000000
00001000010010101000000
00111000000001011000100
010000000010...

result:

ok 23 lines

Test #45:

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

input:

23
00100100000001001001010
00000000110100010000000
10000000000000100010000
00001010000000000000001
00010000000000100000001
10000000000001001001010
00010000000010000000000
00000000010000000000100
01000000010100010000000
01000001100100010000100
00000000000000010100010
01000000110000010000000
000000100...

output:

00100100000001001011000
00000001111100010100000
10000100000001001011000
00000010000000000000001
00000000000000100010001
10100000000001001111010
00010000000010000000001
01000000110110000000100
01000001011100010100000
01000001100100000000000
01000000100100010100000
01000001111000010100000
000000110000...

result:

ok 23 lines

Test #46:

score: 0
Accepted
time: 36ms
memory: 44096kb

input:

23
00000001000000100000000
00010100000010000000000
00000010101000010011001
01000100000000000000000
00000001000000001000000
01010000000001000000000
00100000101000010011001
10001000000000100000000
00100010001000010011001
00000000000101000000010
00100010100000010011011
00000000010000000000010
010000000...

output:

00001001000000100100000
00010000000010000100000
00000010101100010011111
01000100000011000100000
10000001000000001000000
00010000000001000000000
00100000101100010011111
10001000000000000000000
00100010001100010011111
00000000000101000000000
00100010100100010001011
00100010111001010001011
010100000000...

result:

ok 23 lines

Test #47:

score: 0
Accepted
time: 32ms
memory: 42684kb

input:

23
00011001001000000010000
00010000000000000000001
00000000000010010000010
11001001001000000000000
10010001001000000000000
00000000000100000000100
00000000000000110000100
10011000001000000000000
00000000010001000000000
00000000100000001000010
10011001000000000000000
00000100000000000100000
001000000...

output:

00001001001000000010000
00011001001000000001001
00000010000010111000010
01001001001000000000000
11010001001000000010000
00000010000100100000100
00100100000010110000100
11011000001000000010000
00000000010001001001000
00000000100000001000000
11011001000000000010000
00000100000000000100000
001000100000...

result:

ok 23 lines

Test #48:

score: 0
Accepted
time: 22ms
memory: 42408kb

input:

23
00010010001000000000000
00000000000000000100001
00001100000000000000000
10001010001000010001000
00110000000000010001000
00100000000001000000000
10010000001000000000000
00000000000000000010110
00000000010000001000000
00000000101000000000000
10010010010000000000000
00000000000000001000001
000000000...

output:

00010010011000010001000
00000000000110100100001
00001100000000010001000
10000010000000010001000
00100000000000010001000
00100000000001000000000
10010000011000010001000
00000000000000100010100
00000000010100001000000
10000010101000000000000
10000010010000000000000
01000000100000001000001
010000000000...

result:

ok 23 lines

Test #49:

score: 0
Accepted
time: 49ms
memory: 40996kb

input:

23
00000100000100000100000
00001000000000000001000
00000000000000001010000
00000001000000001000000
01000000010000000001000
10000000000100000100000
00000000001100000000001
00010000000000011000000
00000000000000000110100
00001000000010000000000
00000010000100000000000
10000110001000000100000
000000000...

output:

00000100101100000100100
00001000010000100001000
00010000000000001010100
00100001000000011000000
01000000010000000000000
10000000101100000100100
00000000001000000000001
00010000000000010000000
10000100000000000100100
01001000000010000000000
10000110000100000000001
10000100001000000000000
000000000100...

result:

ok 23 lines

Test #50:

score: 0
Accepted
time: 50ms
memory: 41864kb

input:

23
00000010000000000000010
00100000000001001000000
01000000000000001010000
00000000100010000000000
00000000000001000001000
00000010000000000000101
10000100000000000000101
00000000001000000000010
00010000000000000000100
00000000000000110001000
00000001000000010000000
00000000000010000110000
000100000...

output:

00000110000000000000011
00001000000001001000000
00000000000000001010000
00000000100010000100000
01000000000001101001000
10000010100000000000101
10000100000000000000001
00000000001000000000010
00010100000000000000101
00000000000000110000000
00000001000000010000000
00000000000000000110000
000100000000...

result:

ok 23 lines

Test #51:

score: 0
Accepted
time: 33ms
memory: 41720kb

input:

23
00100000010000000000010
00100000000000000000001
11000000000000000000010
00000000000000100010000
00000000001000000001000
00000000000000010000100
00000000000001010000001
00000000010010001000000
00000000001100000100000
10000001000000000000000
00001000100000000100000
00000000100000000010000
000000010...

output:

00000000010000000000010
00100010000001000000011
01000000000000000000010
00000000000000100010000
00000000001000000101000
00000010000001010000100
01000100000001010000001
00000000010000001000000
00000000000100000100000
10000001000000001000010
00001000000000000100000
00000000100000000110000
000000000000...

result:

ok 23 lines

Test #52:

score: 0
Accepted
time: 59ms
memory: 42036kb

input:

23
00000000010000000001000
00100000100000000000000
01000000000000000000001
00001100000000000100000
00010000000100000100000
00010010000000000010000
00000100000000000011000
00000000000100001000000
01000000000000000000010
10000000000000010000001
00000000000000000000110
00001001000000000000000
000000000...

output:

00000000010000010001000
00100000100000000000000
01000000000000010000001
00000100000000000110000
00000000000100000100000
00010000000000000110000
00000000000000000011000
00000000000100101000000
01000000000000000000010
10000000000000010000000
00000000000000000000110
00001001000000000100000
000000000000...

result:

ok 23 lines

Test #53:

score: 0
Accepted
time: 45ms
memory: 40756kb

input:

23
00000010000001010000000
00010000000000000100000
00000000010100000000000
01000000000010000000000
00000001000000000001000
00000000000001001000000
10000000000001000000000
00001000000000000000010
00000000001000000000001
00100000000100000010000
00000000100000000000101
00100000010000000100000
000100000...

output:

00000010000000010000000
00010000000000000100000
00000000010100000110000
01000000000010000000000
00000001000000000001000
00000010000001001000000
10000100000001010000000
00001000000000000000010
00000000001000000001101
00100000000000000010000
00000000100000000000100
00100000000000000100000
000100000000...

result:

ok 23 lines

Test #54:

score: 0
Accepted
time: 34ms
memory: 40740kb

input:

23
00000000000010000100000
00001000000000000000100
00010000000000010000000
00100100000000010000000
01000000000000001001000
00010010000000000000000
00000100100000000000000
00000000010000000100000
00000010000010000000000
00000001000100000000000
00000000000000100000001
00000000010000000000010
100000001...

output:

00000000000010000100000
00001000000000000001100
00010100000000011001000
00100100000000000000000
01000000000000000001000
00110010000000000000000
00000100100000000000000
00000000010000000100000
00000010000010000000000
00000001000100000000000
00000000000000100000001
00000000010000000000010
100000001000...

result:

ok 23 lines

Test #55:

score: 0
Accepted
time: 50ms
memory: 40748kb

input:

23
01010000000000000000000
10100000000000000000000
01000000000000000001000
10000000010000000000000
00000000000000000110000
00000000000100010000000
00000000000000010100000
00000000000010000000001
00000000001001000000000
00010000000000100000000
00000000100001000000100
00000100000000000000100
000000010...

output:

01010000000000000000000
10100000000000000000000
01000000000000000001000
10000000010000000000000
00000000000000000110000
00000000000100010000000
00000000000000010100000
00000000000010000000001
00000000001001000000110
00010000000000100000000
00000000100000000000100
00000100000000000000100
000000010000...

result:

ok 23 lines

Test #56:

score: 0
Accepted
time: 40ms
memory: 40740kb

input:

23
01001000000000000000000
10000100000000000000000
00000000100000100000000
00000001000001000000000
10000000000001000000000
01000000000000000100000
00000000000000100000010
00010000001000000000000
00100000010000000000000
00000000100010000000000
00000001000000000000010
00000000000000010001000
000000000...

output:

01001000000000000000000
10000100000000000000000
00000000100000100000000
00000001000001000000000
10000000000001000000000
01000000000000000100000
00000000000000100000010
00010000001000000000000
00100000010000000000000
00000000100010000000000
00000001000000000000010
00000000000000010001000
000000000100...

result:

ok 23 lines

Test #57:

score: 0
Accepted
time: 518ms
memory: 174532kb

input:

24
011101010110111111101110
101101010110111111101110
110101010110111111101110
111001010110111111101110
000000101001000000110001
111100010110111111101110
000010001001000000110001
111101000110111111101110
000010100001000000110001
111101010010111111101110
111101010101111111101110
0000101010100000001100...

output:

011111111111111111111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111111111111
111111110111111111111111
111111111011111111111111
111111111101111111011111
111111111110111111011111
...

result:

ok 24 lines

Test #58:

score: 0
Accepted
time: 381ms
memory: 204252kb

input:

24
000000111000000010000000
001111010111111101111111
010111010111111101111111
011011010111111101111111
011101010111111101111111
011110010111111101111111
100000001000000010000000
111111000111111101111111
100000100000000010000000
011111010011111101111111
011111010101111101111111
0111110101101111011111...

output:

011111111111111001111111
101111111111111111111111
110111111111111111111111
111011111111111111111111
111101111111111111111111
111110111111111111111111
111111011111111111111111
111111101111111001111111
111111110111111111111111
111111111011111111111111
111111111101111111111111
111111111110111111111111
...

result:

ok 24 lines

Test #59:

score: 0
Accepted
time: 183ms
memory: 192600kb

input:

24
010011101111010010010001
100011101111010010010001
000000010000001001000100
000000001000100101101010
110001101111010010010001
110010101111010010010001
110011001111010010010001
001000000010001001000100
110111100111110110010001
110011101011010010010001
110011111101010010010001
1100111011100100100100...

output:

011011111111111110010101
101011111111111110010101
110011110111011011111111
000000000000100100101010
111001111111111110010101
111010111111111110010101
111011011111111110010101
111011100111011010010101
110011100101110110010001
111011111011111110010101
111011110101011010010101
111011111110111110010101
...

result:

ok 24 lines

Test #60:

score: 0
Accepted
time: 131ms
memory: 143556kb

input:

24
000000100000001000101001
001010001101010110010010
010011001101010110010010
000001010000101001000100
011000001101010110010010
001100010000101001000100
100000000000001000101000
000101000000101001000100
011010000101010110010010
011010001001010110010010
000000000000010000000001
0110100011000101100100...

output:

000000100010000000101001
001111011111110111010110
010111011101100111010110
011011111101101111111110
011101011111110111010110
011110011101100111010110
100100010010101001101101
011111101101101111111110
011111010111110111010110
011111011011110111010110
110010101101010110111011
011111011110110111010110
...

result:

ok 24 lines

Test #61:

score: 0
Accepted
time: 137ms
memory: 149780kb

input:

24
001010000100010000010001
000100101000100010001010
100110000100010000010001
011000001000000000000000
101000000110010000010001
000000010010000100000000
010000000000100010001010
000001000010000100000000
010100000000000000000000
101010000000010000010001
000011010000000100000000
0000000000000011011011...

output:

001111011110010000010001
000000101000100010000010
100100001100010000010001
101000001100010000010001
100001010110010000010001
100010010111011101110101
010000001001101011101110
100011000111011101110101
111100100100110010010011
101111011010010000010001
100011010100010000010001
000001110000101111101110
...

result:

ok 24 lines

Test #62:

score: 0
Accepted
time: 78ms
memory: 93184kb

input:

24
001001000001001000000000
000110000000010000110100
100001000101001001010000
010010000000010000110100
010100000000010000110100
101000000001001000000001
000000001010000000101010
000000000000100110000010
000000100010000000001010
001000000000000001010000
000000101000000000001010
1010010000000010000000...

output:

001001000101001001000001
000110101110010001111100
100000000101001001000000
010010101110010001111100
010100101110010001111100
100000000001001000000001
010110001010010000101100
000000001010100110001011
010110110010010110101110
111110000001011001010100
010110111000010110101110
101001000100001001000001
...

result:

ok 24 lines

Test #63:

score: 0
Accepted
time: 89ms
memory: 104548kb

input:

24
000001101000100000000100
000000000100001010000001
000000010001000100111010
000010001000000000000000
000100001000010001000001
100000101000100000000100
100001001010100000000100
001000000000000100001010
100111100000100000000100
010000000000001010000001
000000100000000000010000
0010000000000000001100...

output:

000101101010100000000100
000000010100011111001011
000000010001000100100010
100011001000110001000100
000100000000010001000000
100100101010100000000100
100001000010100000000100
011000000101001110101010
100101000000100000000100
010000010000011111001011
100001100001100000110100
001000010010000100110010
...

result:

ok 24 lines

Test #64:

score: 0
Accepted
time: 99ms
memory: 82700kb

input:

24
000110001100000011000010
000000000001110000000100
000000010010000100010000
100010001100000011100010
100100001100000011000010
000000110000000000001000
000001010000000000001000
001001100000000000001000
100110000100000011000010
100110001000000011000010
001000000000000100010100
0100000000001100000001...

output:

000110001100000011100011
000000000011111100010100
000001110000000100010000
100010001100000011100000
100100001100000011100011
001000110000000100011001
001001010000000100011001
001001100000000100010000
100110000100000011100011
100110001000000011100011
010000000001010100010100
010000000010111100010100
...

result:

ok 24 lines

Test #65:

score: 0
Accepted
time: 82ms
memory: 81704kb

input:

24
011010100011011000110000
101010100011011000110000
110010100011011000110000
000001000100000010001000
111000100011011000110000
000100000100000110000000
111010000011011000110000
000000000000100000001010
000000000000000100000001
000101000000000010000000
111010100001011000110100
1110101000100110001100...

output:

011010100011011000110101
101010100011011000110101
110010100011011000110101
000000010100000010001010
111000100011011000110101
000000000100000110000000
111010000011011000110101
000100000100100011001010
000000000000000100000001
000101010000000110001010
111010100000011000110100
111010100000011000110001
...

result:

ok 24 lines

Test #66:

score: 0
Accepted
time: 66ms
memory: 80132kb

input:

24
000000000000010100000000
000000100000001011010100
000100000000000000000010
001000000000100000001000
000000000100000000000100
000000000000000000000011
010000000000001011010100
000000000111000000000000
000000000001000000101000
000010010011000000000100
000000010101000000000000
0000000111100000001010...

output:

000000000000010100000000
000010100000011011010100
000101000000100000000010
001000000000100000000000
010000110110001001010100
001000000000000100000011
010010000000011011010100
000010001111000000100000
000000010011100000101000
000010010010000000000000
000010011101000000100000
000000011010000000100000
...

result:

ok 24 lines

Test #67:

score: 0
Accepted
time: 84ms
memory: 82772kb

input:

24
000100001000000000000000
000000000010000001000000
000000100001100010000001
100001001000000000000000
000000000000000101000010
000100000010000000000000
001000010001101010010001
000000100000001000010000
100100000000000000101100
000000000000010000010000
010001000000000000000000
0010001000001000100000...

output:

000101001000000000101000
000010000010000001000010
000000110001101010101101
100001000000000000000000
010000000000010101000010
100100000010000000000000
001000010001101000000001
001000100101101000010001
100000000000000000101000
000000010000011000010000
010001000000000000000000
001000110000101010101101
...

result:

ok 24 lines

Test #68:

score: 0
Accepted
time: 84ms
memory: 77504kb

input:

24
000001100000000000000000
000010000001000000010000
000000000000001001000000
000000000010010100000000
010000000000000000010000
100000001000000000001000
100000000000000000000011
000000000100100011100000
000001000000000000001000
000000010000100011100000
000100000000010100000001
0100000000000000100000...

output:

000001101000000000000010
000010000001000000000000
000000010100101001100100
000000000010010100000111
010000001001000000011000
100000001000000000000000
100000000000000000000010
001000000101100011100000
100011000000000000011000
001000010001100011100000
000100000000010000000011
010010010100100010100000
...

result:

ok 24 lines

Test #69:

score: 0
Accepted
time: 74ms
memory: 80556kb

input:

24
000010001000000000000000
000000000011110000000000
000100000100000001000001
001000000100100001010001
100000000001000000000000
000000000000000100001110
000000000000001000000100
000000000000000010100000
100000000000000000100000
001100000000000001000001
010000000000110000000000
0100100000000000000000...

output:

000010001000000000000000
000000000011010000000000
000101000100000101011011
001000000100000001010000
100000000001000000000000
001000100100000101001111
000001000000001100001100
000000000000000010100000
100000000000000000100000
001101000000000101011011
010000000001110000010000
010010000010010000000000
...

result:

ok 24 lines

Test #70:

score: 0
Accepted
time: 74ms
memory: 77296kb

input:

24
000000000001000010100000
001000100000000000000000
010000000000010000000000
000000000000000010000100
000000000001000101010000
000000100000000000001000
010001000000000000000000
000000000000000000001001
000000000110000000000000
000000001010101000000000
000000001100000000010000
1000100000000001111100...

output:

000110000001000111100000
001000100000000000000000
010000000000010000000000
100000000000000010100101
100000001011000101110000
000000100000000000001000
010001000000000000000000
000000000000000000001001
000010000110100101010000
000000001000100000000000
000010001000000101010000
100010000000000101100000
...

result:

ok 24 lines

Test #71:

score: 0
Accepted
time: 108ms
memory: 75664kb

input:

24
000100000100000000001000
000000000000000001001000
000000000010000000100100
100000000100000000000000
000000011000000000000000
000000001001000000010000
000000000011001000000000
000010000000000000000010
000011000001000000010000
100100000000000010000000
001000100001001000000000
0000011010100010000100...

output:

000100000000000000001000
000000000000000001001000
000000100010001000100000
100000000100000010001000
000001011000000000010000
000010101001001000010000
001001000011001000110000
000010000000000000000011
000011000000000000010000
000100000000000010000000
001000100000001000100000
000001100000001000010000
...

result:

ok 24 lines

Test #72:

score: 0
Accepted
time: 86ms
memory: 75940kb

input:

24
000011000000000000000000
000000100000000000000100
000000000100000000100000
000001000000000100000000
100001000000100010000001
100110000000000000000000
010000000000001000100000
000000000000000100000100
000000000000010000010001
001000000010000000000000
000000000101000000000000
0000000000100000000010...

output:

000111000000100010000000
000000100000001000000100
000000000100001000100000
100001000000000100000000
100000000000100010000000
100100000000000000000000
010000000000001000000000
000000000000000100000100
000000000000110011010001
001000000010000000000000
000000000101000000000000
000000000010000000001000
...

result:

ok 24 lines

Test #73:

score: 0
Accepted
time: 102ms
memory: 74868kb

input:

24
000000000000100000100001
000100000010000000000000
000000000000000010001000
010000000000000000000001
000000000001001000000010
000000100100000001000000
000001000010000000000000
000000000000010000001000
000000000000010000010000
000001000000000001000000
010000100000000000000000
0000100000000011000000...

output:

000000000000100000000001
000100000010000000000000
000000010000000010001100
010000000000000000000001
000000000000001000000010
000000100100000000000000
000001000110000000000000
001000000000010000001000
000000000000010000010000
000001100000000101000000
010000100000000000000000
000000000000001100000000
...

result:

ok 24 lines

Test #74:

score: 0
Accepted
time: 78ms
memory: 74048kb

input:

24
000000000000100000001000
000000000010010000000000
000010010000000000000100
000000010000000000100000
001000000000000000000110
000000000100001000000000
000000000000010010000000
001100000000000000100000
000000000000000000001010
000001000000000001000001
010000000000010001000000
0000000000000001001000...

output:

000000000000100000001000
000000100010010001000001
000100010000000000000100
001000010001000000100100
000000000000000000000110
000000000100001000000001
010000000000010010000000
001100000000000000000100
000000000000000000001010
000001000000000000000001
010000000000000001000001
000100000000000100100000
...

result:

ok 24 lines

Test #75:

score: 0
Accepted
time: 77ms
memory: 73732kb

input:

24
000001100000000000000000
000000000010000000000001
000000000000101000000000
000000000010000000001000
000000100000010001000000
100000100100000000000000
100011000000000001000000
000000001000100000000000
000000010000000000000100
000001000001000000000000
010100000000000000000001
0000000001000000000001...

output:

000001100100000001000000
000100000010010000000001
000000000000101000000000
010000000010000000001000
000000000000010001000000
100000000100000000000000
100000000000000001000000
000000001000100000000000
000000010000000000000100
100001000001000000000000
010100000000000000000000
000000000100000000000100
...

result:

ok 24 lines

Test #76:

score: 0
Accepted
time: 78ms
memory: 73916kb

input:

24
000000100000000000001000
001010000000000000000000
010001000000000000000000
000000000111000010000000
010000010000000000000000
001000000000010000000000
100000000000000000000001
000010000000000000000010
000000000000100000000001
000100000011000000000000
000100000101010000000000
0001000001100000000000...

output:

000000100000000000001000
001010000000000000000000
010001000000000000000000
000000000101000010000000
010000010000000000000000
001000000000010000000000
100000000000000000000001
000010000000000000000010
000000000000100000000001
000100000011010010000000
000000000101010000000000
000100000110010010000000
...

result:

ok 24 lines

Test #77:

score: 0
Accepted
time: 77ms
memory: 73720kb

input:

24
010000000000000000100000
101000000000000000000000
010000000000000001000000
000010000001000000000000
000100000000000010000000
000000000000000001000001
000000000000000000000011
000000000000100000001000
000000000010000000000100
000000000010000100000000
000000001100000000000000
0001000000000110000000...

output:

010000000000000000100000
101000000000000000000000
010000000000000001000000
000010000001010000000000
000100000000000010000000
000000000000000001000001
000000000000000000000011
000000000000100000001000
000000000010000000000100
000000000010000100000000
000000001100000000000000
000100000000010000000000
...

result:

ok 24 lines

Test #78:

score: 0
Accepted
time: 74ms
memory: 73480kb

input:

24
000000000000010000010000
000100000000000001000000
000000010000000000000001
010000000000000000000010
000000000000000100100000
000000000100000000000100
000000000001000100000000
001000000000000010000000
000000000100001000000000
000001001000000000000000
000000000000000000010001
0000001000000000010000...

output:

000000000000010000010000
000100000000000001000000
000000010000000000000001
010000000000000000000010
000000000000000100100000
000000000100000000000100
000000000001000100000000
001000000000000010000000
000000000100001000000000
000001001000000000000000
000000000000000000010001
000000100000000001000000
...

result:

ok 24 lines