QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#174003#7186. "Memo" Game With a Hintucup-team180#AC ✓2ms3888kbC++1732.2kb2023-09-10 03:37:332023-09-10 03:37:33

Judging History

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

  • [2023-09-10 03:37:33]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3888kb
  • [2023-09-10 03:37:33]
  • 提交

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 setbits(j, n) for(ll iiiii = (n), j = lowbit(iiiii); iiiii; iiiii ^= 1 << j, j = lowbit(iiiii))
#define perm(v) for(bool permrepflag = true; (permrepflag ? exchange(permrepflag, 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 INTd(...)                                                                                                                                              \
    int __VA_ARGS__;                                                                                                                                           \
    IN2(__VA_ARGS__)
#define LL(...)                                                                                                                                                \
    ll __VA_ARGS__;                                                                                                                                            \
    IN(__VA_ARGS__)
#define LLd(...)                                                                                                                                               \
    ll __VA_ARGS__;                                                                                                                                            \
    IN2(__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 VECd(type, name, size)                                                                                                                                 \
    vector<type> name(size);                                                                                                                                   \
    IN2(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 VEC2d(type, name1, name2, size)                                                                                                                        \
    vector<type> name1(size), name2(size);                                                                                                                     \
    for(int i = 0; i < size; i++) IN2(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 VEC3d(type, name1, name2, name3, size)                                                                                                                 \
    vector<type> name1(size), name2(size), name3(size);                                                                                                        \
    for(int i = 0; i < size; i++) IN2(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 VEC4d(type, name1, name2, name3, name4, size)                                                                                                          \
    vector<type> name1(size), name2(size), name3(size), name4(size);                                                                                           \
    for(int i = 0; i < size; i++) IN2(name1[i], name2[i], name3[i], name4[i]);
#define VV(type, name, h, w)                                                                                                                                   \
    vector<vector<type>> name(h, vector<type>(w));                                                                                                             \
    IN(name)
#define VVd(type, name, h, w)                                                                                                                                  \
    vector<vector<type>> name(h, vector<type>(w));                                                                                                             \
    IN2(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() {}
void IN2() {}
template <class Head, class... Tail> void IN(Head &head, Tail &...tail) {
    scan(head);
    IN(tail...);
}
template <class Head, class... Tail> void IN2(Head &head, Tail &...tail) {
    scan(head);
    --head;
    IN2(tail...);
}

template <int p = -1> void pat() {}
template <int p = -1, class Head, class... Tail> void pat(Head &h, Tail &...tail) {
    h += p;
    pat<p>(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);
}

vector<int> counter(const vector<int> &v, int max_num = -1) {
    if(max_num == -1) max_num = MAX(v);
    vector<int> res(max_num + 1);
    fore(e, v) res[e]++;
    return 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; }
template <class T, class S> bool inc(const T &x, const pair<S, S> &p) { return p.first <= x and x < p.second; }

// 便利関数
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> void connect(vector<T> &l, const vector<T> &r) { fore(e, r) l.eb(e); }
template <class T> vector<T> operator+(const vector<T> &l, const vector<T> &r) {
    vector<T> res(max(si(l), si(r)));
    rep(i, si(l)) res[i] += l[i];
    rep(i, si(r)) res[i] += r[i];
    return res;
}
template <class T> vector<T> operator-(const vector<T> &l, const vector<T> &r) {
    vector<T> res(max(si(l), si(r)));
    rep(i, si(l)) res[i] += l[i];
    rep(i, si(r)) res[i] -= r[i];
    return res;
}
template <class T> vector<T> &operator+=(const vector<T> &l, const vector<T> &r) {
    if(si(l) < si(r)) l.resize(si(r));
    rep(i, si(r)) l[i] += r[i];
    return l;
}
template <class T> vector<T> &operator-=(const vector<T> &l, const vector<T> &r) {
    if(si(l) < si(r)) l.resize(si(r));
    rep(i, si(r)) l[i] -= r[i];
    return l;
}
template <class T> vector<T> &operator+=(vector<T> &v, const T &x) {
    fore(e, v) e += x;
    return v;
}
template <class T> vector<T> &operator-=(vector<T> &v, const T &x) {
    fore(e, v) e -= x;
    return v;
}

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

int main() {
    STR(s);
    if(s == "prepare") {
        TEST {
            STR(s);

            vi f(si(s));
            int t = 0;
            rep(i, si(s)) {
                if(!f[i]) {
                    int c = find(rng(s, i + 1, si(s)), s[i]) - begin(s);
                    rep(j, 6) cout << (c >> j & 1);
                    f[i] = f[c] = true;
                    t++;
                    if(t == 8) break;
                }
            }
            cout << 0 << 0 << endl;
            OUT();
            cout.flush();
        }
    } else {
        int sum = 0;
        TEST {
            STR(s);
            auto a = toint(s);

            auto solve = [&](vi v) {
                random_shuffle(v);
                vi f(si(v), -1);
                int c = 0;
                rep(i, si(v)) {
                    if(f[i] == -1) {
                        OUT(v[i] + 1);
                        cout.flush();
                        STR(x);
                        int now = x[0] - 'A';
                        f[i] = now;
                        bool flag = false;
                        rep(j, i) {
                            if(f[j] == f[i]) {
                                OUT(v[j] + 1);
                                cout.flush();
                                STR(x);
                                flag = true;
                            }
                        }
                        if(!flag) {
                            OUT(v[i + 1] + 1);
                            cout.flush();
                            STR(x);
                            f[i + 1] = x[0] - 'A';
                            if(x[1] == '+' or x[1] == '!') { i++; }
                        }
                    } else {
                        rep(j, i) {
                            if(f[j] == f[i]) {
                                OUT(v[j] + 1);
                                cout.flush();
                                STR(x);
                                OUT(v[i] + 1);
                                cout.flush();
                                cin >> x;
                            }
                        }
                    }
                }
            };

            vi f(si(a));
            int c = 0;
            rep(i, si(a)) {
                if(f[i]) continue;
                int b = 0;
                rep(j, c * 6, c * 6 + 6) { b += (a[j] * bit(j - c * 6)); }
                OUT(i + 1);
                cout.flush();
                STR(x);
                OUT(b + 1);
                cout.flush();
                cin >> x;
                f[i] = f[b] = true;
                c++;
                if(c == 8) break;
            }
            vi v;
            rep(i, si(a)) if(!f[i]) v.eb(i);
            solve(v);
        }
        // OUT(sum);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

First Run Input

prepare
2
ABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLMNOPQRSTUVWXY
AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYY

First Run Output

10011001011011011000111010111001111011111000000100

10000011000010100011100010010011010010110011110000


Second Run Input

play
2
10011001011011011000111010111001111011111000000100
A.
A+
B.
B+
C.
C+
D.
D+
E.
E+
F.
F+
G.
G+
H.
H+
O.
P-
N.
R-
T.
S-
S.
S+
J.
J+
X.
W-
I.
M-
L.
U-
X.
X+
Q.
W-
W.
W+
Y.
M-
M.
M+
K.
U-
U.
U+
V.
V+
Y.
Y+
P.
P+
Q.
Q+
T.
T+
R.
R+
O.
O+
N.
N+
K.
K+
L.
L+
I.
I!
10000011000010100011100010010011010010...

Second Run Output

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

result:

ok Correct! The number of the misses is 20 (2 test cases)

Test #2:

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

First Run Input

prepare
1
FNETFOMMJTYCXKCRYLGXKSPAIVQNBURJAPQHUDWSDWVIHGELBO

First Run Output

00100011011001110110010010001111100011111000001000


Second Run Input

play
1
00100011011001110110010010001111100011111000001000
F.
F+
N.
N+
E.
E+
T.
T+
O.
O+
M.
M+
J.
J+
Y.
Y+
G.
D-
K.
L-
H.
R-
X.
B-
L.
L+
P.
Q-
I.
S-
B.
B+
C.
U-
P.
P+
S.
S+
V.
U-
U.
U+
H.
H+
D.
D+
C.
C+
W.
X-
X.
X+
A.
Q-
Q.
Q+
W.
W+
I.
I+
G.
G+
K.
K+
R.
R+
A.
A+
V.
V!

Second Run Output

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

result:

ok Correct! The number of the misses is 10 (1 test case)

Test #3:

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

First Run Input

prepare
50
FDAVHJWICNELMBTQGPMHCYSTUUKWOYBJNRLGEFXXSIVOAQDRKP
NPBEHYAERLSHAKCMGTQFUYXDVUIWDPBSOXCMFRJOJTNKIGLQWV
AEFGFISMPACJJYRBXUCKNOPEHODITLXWSMGVWBDQKLUQHRYVTN
CKFXOIQOLCSHAGDEUJTYBAVKWPMHDBJNRMFXTEYQUGVNPILWRS
JYIRTLMHQGUUAEDJXTSDCKPCXWPBAWHQRMGNLONVOYEKFVBIFS
IHDCXSWTUHOFXLGLGWJPACUVTBOESDMYAK...

First Run Output

10100101110100110101010111001011111011011010010100

01010110111001111011100011010010101000110010100100

10010011101000100001000111011000000110000101101000

10010011101001000111000111100010110111100101110100

11110010010111110100000110001000100110000101111000

1011011001001011101010100011000011101000...

Second Run Input

play
50
10100101110100110101010111001011111011011010010100
F.
F+
D.
D+
A.
A+
V.
V+
H.
H+
J.
J+
W.
W+
I.
I+
P.
R-
P.
P+
X.
C-
S.
T-
Q.
S-
S.
S+
G.
U-
L.
M-
C.
C+
Y.
G-
G.
G+
B.
E-
R.
R+
O.
T-
T.
T+
M.
M+
B.
B+
U.
U+
Q.
Q+
N.
K-
Y.
Y+
L.
L+
E.
E+
X.
X+
O.
O+
K.
K+
N.
N!
0101011011100111101110001101001...

Second Run Output

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

result:

ok Correct! The number of the misses is 497 (50 test cases)

Test #4:

score: 100
Accepted
time: 2ms
memory: 3888kb

First Run Input

prepare
75
EAHSMUJLVDPNLEKPCNIICFRTMHYWVSTQBBWRXKFDXOJQUAGGOY
CUWYVQJPSRIDKXMKTFXTFDOJVWLBEMNULIAAPYCHNGHEOGSRQB
UJTQMFLPJRGSECWAHXDCIVRQOIEPANHUBYVGFKMKLDTSWYBNOX
EYOUSDBNEQXIPMFUJCYKJVLSVWOXKLCFWARPBTIHGTMNDRGHAQ
PBHANSDUVHNKYRQVMOBLQAXSEXOLYJRGTWCFKGMWPJIFTIEDCU
YREKISUWLRFFQDIWNUASLJXGMVHBXDMBJT...

First Run Output

10110010110110011010111000011000110101010100110000

01100111111010011010100100011000001111101000100100

11111000010001010111101001100100100100010111011000

00010001001001011011110011101000110100100111010100

00010101001010010010101001010011101011110110001100

0111011001001011010001010111001100101000...

Second Run Input

play
75
10110010110110011010111000011000110101010100110000
E.
E+
A.
A+
H.
H+
S.
S+
M.
M+
U.
U+
J.
J+
L.
L+
I.
T-
Q.
X-
F.
C-
B.
D-
O.
F-
F.
F+
Y.
K-
T.
T+
N.
R-
G.
V-
Q.
Q+
O.
O+
C.
C+
G.
G+
R.
R+
N.
N+
P.
P+
W.
Y-
Y.
Y+
D.
D+
K.
K+
X.
X+
B.
B+
W.
W+
V.
V+
I.
I!
0110011111101001101010010001100000111...

Second Run Output

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

result:

ok Correct! The number of the misses is 742 (75 test cases)

Test #5:

score: 100
Accepted
time: 2ms
memory: 3664kb

First Run Input

prepare
85
RSHXLIARGTANBOIMVCQUCBGQWEDTPMYJWYUFPKESKJODLNFVXH
GEFNCRFLXMNOJGIQPLMSBKHDVIUVCHRAAUYWQBPTWYXSJOTEDK
PNCEFQSMQNOUJPKTWEAHFSRKGCIVJXXLRHLYBWGODVBYDUTAIM
EBFQNGFUKBOYENJSUTTPKPVSIRADCMVRHAHMDCLGLXQXIOJYWW
OSYHICRXEQAMWBDUDWANLLNCVBTXMTGEPJYPGFSKIJFHUKRQOV
SESXRAXOUIGPVJUNLMJFYEBVFCOBDQHKGW...

First Run Output

11100011100110001100001100110101110001010001101000

10110011110101100001010000111001111010001001010100

10110010010010011010001000101000010010101010001100

00110010010001100001010110110011100100001000101000

00001101100101000111010100010111101001110111011000

0100001010100110001101010111010101100111...

Second Run Input

play
85
11100011100110001100001100110101110001010001101000
R.
R+
S.
S+
H.
H+
X.
X+
L.
L+
I.
I+
A.
A+
G.
G+
Q.
K-
V.
J-
F.
T-
B.
Y-
O.
Q-
Q.
Q+
P.
D-
Y.
Y+
M.
P-
P.
P+
D.
D+
C.
F-
F.
F+
B.
B+
U.
U+
T.
T+
W.
N-
N.
N+
J.
J+
E.
W-
W.
W+
M.
M+
V.
V+
K.
K+
E.
E+
C.
C+
O.
O!
1011001111010110000101000011100...

Second Run Output

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

result:

ok Correct! The number of the misses is 843 (85 test cases)

Test #6:

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

First Run Input

prepare
90
HPBUYCSIRIQTEVJLTDYGMNBEKMSFHNCRXVDAUFQAWPLGJWKOXO
DGTONCNKSQVCREJMUPOGFWIQPALERLASDYBFVIWKXHTMXBJUHY
KODTYFIXXRTNWNCUSLOREEBCUJPABHIDVGLGJMYKWMSQHAPQVF
BGTFHKOEJPGLWJIHPWAYVDKIFXSUUQYTENNVCMDRMOASRBXCLQ
YSJXTDDMCLKFFBOWVRCSHNPTGARXJQPBKMYWUEAUNGEIIQVHOL
QTXVHWNRFUOHCPMGWMLFRSCQKGEIPKEADY...

First Run Output

00111010010101101000100101001001111001011010010000

00000111001001010101001001100011010011100111111000

11100101001011111001010001100110001101111000010000

10110101010011111000011011110001101010010100000100

01000111001000111011011011101001100010000101001000

1110100010011001011010011101000000100111...

Second Run Input

play
90
00111010010101101000100101001001111001011010010000
H.
H+
P.
P+
B.
B+
U.
U+
Y.
Y+
C.
C+
S.
S+
I.
I+
N.
R-
J.
O-
A.
T-
L.
F-
T.
T+
N.
N+
Q.
O-
O.
O+
E.
R-
R.
R+
V.
D-
A.
A+
W.
G-
M.
F-
F.
F+
D.
D+
G.
G+
X.
X+
K.
K+
M.
M+
W.
W+
E.
E+
L.
L+
Q.
Q+
J.
J+
V.
V!
0000011100100101010100100110001101001...

Second Run Output

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

result:

ok Correct! The number of the misses is 890 (90 test cases)

Test #7:

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

First Run Input

prepare
95
CXKFQPTEDJGCNSIWIDLVHJBTMEUMLQVYOHGPKNRYOFXRSBUWAA
DKGIBMTPLXOCTJEVQYVUMAFHNXEOCRDPNQHSUGSWAJRIFYBWKL
QHTADVKMABFWXHRLNICEGJOCPXWTYNVMBESJURIODUGFLYSKQP
WPTDMLIIEOWCKYSSREBDBFXNQGVNXAPVJHYLUKUCGHQRAFJMOT
PUYIWXOSXDQNITNCYWFEKGHPLKVJABJQTUSVRMLCEDFMGAOBHR
YFMQKSXVBUIYLCBRDWWNVFHTTMRHUDOGLA...

First Run Output

11010001010100100110010110111011000111101010011000

01111000001110100111010101110100101000110011111000

00001110110011011000010000010101111011110111111000

01010001111010001111001011110111000111100010001000

11101010000100001000110010001000010001110101000100

1101001010101001100000111101011100011010...

Second Run Input

play
95
11010001010100100110010110111011000111101010011000
C.
C+
X.
X+
K.
K+
F.
F+
Q.
Q+
P.
P+
T.
T+
E.
E+
H.
A-
Y.
M-
I.
G-
R.
W-
I.
I+
V.
R-
R.
R+
S.
N-
U.
H-
H.
H+
A.
A+
L.
B-
N.
N+
O.
G-
G.
G+
W.
W+
D.
M-
M.
M+
U.
U+
V.
V+
D.
D+
O.
O+
Y.
Y+
B.
B+
S.
S+
J.
L-
L.
L+
J.
J!
0111100000111010011101010...

Second Run Output

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

result:

ok Correct! The number of the misses is 938 (95 test cases)

Test #8:

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

First Run Input

prepare
100
NKXFSXFWWAOBPEJOTMVHIPUKCGQSRLCRHYNVDMETALGIJQUDBY
LQEXDPFVMOMABELGPHCWBJTVCTNYXGRYWJUQKFIHOSNSKAIURD
MBTKVSCAPAXWHBEHUSQOGYJIUVTNEIRPFYQXJORNLFDCMKWDGL
EBBOJXCXNECGAQQALWPPMJVTGSHIORNMHRDFSYUYLFIUVDKWKT
GKOAHWLYQXVKCLRRTCYMFBSQUPDIWIJPVGDFMNAUTSJXHBEEON
EQEDVJGKUIXMCYQTANIHSADKWRNFYBGOT...

First Run Output

01000111101010100001100011011000010000010111110000

01110011000110110000111010001100001010100111101000

00110110110001011010110110011010001011010110010000

10010001000000111010101011100001010001111000011000

10000111010000001101100100110100111010110001001000

0100000111000110100100011000010111101110...

Second Run Input

play
100
01000111101010100001100011011000010000010111110000
N.
N+
K.
K+
X.
X+
F.
F+
S.
S+
W.
W+
A.
A+
O.
O+
D.
M-
T.
U-
E.
R-
I.
M-
M.
M+
G.
I-
I.
I+
Y.
G-
G.
G+
B.
V-
E.
E+
D.
D+
C.
C+
Q.
J-
P.
R-
R.
R+
Y.
Y+
L.
U-
U.
U+
L.
L+
H.
Q-
Q.
Q+
H.
H+
B.
B+
P.
P+
T.
T+
V.
V+
J.
J!
011100110001101100001110...

Second Run Output

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

result:

ok Correct! The number of the misses is 977 (100 test cases)

Test #9:

score: 100
Accepted
time: 2ms
memory: 3664kb

First Run Input

prepare
100
BULRJTVXIHFVSKOMPWMCGENUNYAKIQQXSPBADERWHJCYFDOLGT
FIHEGHKMALOKAVTSYYWTMQJCERQNBLFIOPSBDUCXVNRWJXUGPD
IGMAXBJVQJGTTPKQCFEEUWRSONNSHBRKUPWHCDDYLXFYVLOIMA
FKYUXTNHQBVLPWEOPREKVIMHCOJLXNDGBFUGIRSASJYADMWTCQ
RYIDFMJOWUBQNXLWNCRSSGKTXOHPVKTEPAAFMEILQVBUHJDGCY
SOVMPWQBMWNURDEALASGVNHCYUTOGKTKY...

First Run Output

01000111101011110101100110010110001111010011111000

01111011111010100000011011110111010000101000110000

11110101010000001110001110010110111010010000110100

10000111001001010101000100111011110110111011101000

01001010001101100101110111000100100110110110011000

0100101101100010100001001000011001000000...

Second Run Input

play
100
01000111101011110101100110010110001111010011111000
B.
B+
U.
U+
L.
L+
R.
R+
J.
J+
T.
T+
V.
V+
X.
X+
K.
A-
Y.
I-
C.
G-
S.
D-
E.
W-
M.
F-
P.
H-
Y.
Y+
I.
I+
Q.
M-
M.
M+
G.
G+
W.
W+
O.
N-
P.
P+
N.
N+
O.
O+
E.
E+
K.
K+
S.
S+
C.
C+
Q.
Q+
H.
H+
F.
F+
A.
A+
D.
D!
011110111110101000000110111101110100...

Second Run Output

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

result:

ok Correct! The number of the misses is 996 (100 test cases)

Test #10:

score: 100
Accepted
time: 2ms
memory: 3656kb

First Run Input

prepare
100
SQROXGJWGXFMMKUNTEIRNLEVAYLHDHQPPBCSJIWFUYVCTADBKO
PKYCKEOOYJVXPWFGVDJBEULHWQTCAHLMAMURBFQGTIXSRISNND
UOOAMTVCCXBSEKWXPGWSRBNYNLIHJYJITFADEHKPRFDMQQVUGL
YEFEDNPRNSWMCWBAKSQQRBGLXKOILXTDAGJUVYUMVHHCJIFOTP
AVXANGTWWEBDESYBMQHOVRXCLFKDIGJSTJPQFYRCHIKMNLOPUU
OJNYRXLJHGGWFMDDMOPKYTHTUAKLNICIE...

First Run Output

11000101111011001010001110010000010000100101100100

00110000100000010011011000101011100001001000001000

11110101000001000111010100000101110100010011110000

10100111000001110111111000010010001100101010001000

11000000101001101000110110111000000100010000110000

1000101110000011100010101000011101011101...

Second Run Input

play
100
11000101111011001010001110010000010000100101100100
S.
S+
Q.
Q+
R.
R+
O.
O+
X.
X+
G.
G+
J.
J+
W.
W+
U.
F-
P.
Y-
D.
N-
K.
C-
L.
I-
A.
C-
C.
C+
D.
D+
M.
P-
P.
P+
E.
F-
F.
F+
Y.
Y+
K.
K+
V.
E-
E.
E+
A.
A+
U.
U+
B.
B+
L.
L+
T.
M-
M.
M+
T.
T+
H.
I-
I.
I+
H.
H+
V.
V+
N.
N!
001100001000000100110110...

Second Run Output

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

result:

ok Correct! The number of the misses is 994 (100 test cases)

Test #11:

score: 100
Accepted
time: 2ms
memory: 3636kb

First Run Input

prepare
100
RGFVPILWOVETBGSLKHKNCHJIOXAMPXNQSWJYUDRBMDAEYFQCTU
OLRHQVCXUYKWSEJPDYTFGKNVCASHMIDPNERUBOQJMBTGAXLIFW
KXYEEFLNYOGBNIUVVDTCRJDSHQISRAUWAQCTWLMPBHMJKXGFPO
BUXYMYPJMVFQKCIDQHEUOTITPKHLORXVGLASAGWDCJSBWNEFRN
TXKFEIVQISUBKTHXRDJCNOMPMGHNDCLPAWVBWUAEQSJRFYGOYL
PSRXNYTOKJMUFUTIRVMKBDXLJBCLFVGHA...

First Run Output

01100110110010110110010000111011101011110010000100

10100101110101000111011001100111101000011010110100

00110110110100010000100011110110100100110010001100

11010111001001111010100000010000011010010111111000

10110011110000110000110111100100010001000100010100

0011011001010000100110101000011101010111...

Second Run Input

play
100
01100110110010110110010000111011101011110010000100
R.
R+
G.
G+
F.
F+
V.
V+
P.
P+
I.
I+
L.
L+
W.
W+
D.
B-
S.
J-
C.
X-
O.
K-
M.
C-
C.
C+
B.
B+
K.
K+
A.
S-
S.
S+
H.
T-
U.
N-
Y.
A-
A.
A+
U.
U+
J.
J+
T.
T+
O.
O+
Q.
N-
N.
N+
Y.
Y+
M.
M+
Q.
Q+
D.
D+
H.
H+
X.
X+
E.
E!
101001011101010001110110011001...

Second Run Output

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

result:

ok Correct! The number of the misses is 991 (100 test cases)

Test #12:

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

First Run Input

prepare
100
VJXSDLHVPDTYCWKILGXUIJANAHYSMUWBRRQTCENEPFFOKBGMOQ
BVAFIMQXPHKTKJWSLITNXOEVCFYCOQADGSGDWUPLHNBJRUEMYR
RLPSNKYDCLUMVDTHJYIHWQSGRBNXUFOFAAGEQTKCPVJEWBMOIX
IBFYNHNRSYOHXPGGKBFCSUMOJLUPKVAQMTCLDWREWQDTAVXIEJ
KGRTAINBFADUHILYMBEOPECVXQPDOWWTJSKMGQSVRUHLCNFXYJ
ETFGMNTHGOKBXNMELFBWCARUHICYJRWSX...

First Run Output

11100010101001001011011010010000001010011000010100

01010111101001111010011010001011110110111000101000

00011010010000010101101001011001100110001010110000

11110110001001001010010001100011010001100100101000

01000100100100010111111010010010110010110110001000

1111000110001000100001000111001011000001...

Second Run Input

play
100
11100010101001001011011010010000001010011000010100
V.
V+
J.
J+
X.
X+
S.
S+
D.
D+
L.
L+
H.
H+
P.
P+
E.
Y-
Q.
Q+
C.
R-
U.
K-
T.
C-
C.
C+
G.
M-
B.
M-
M.
M+
R.
R+
E.
E+
K.
K+
N.
O-
Y.
Y+
F.
I-
B.
B+
A.
T-
T.
T+
O.
O+
N.
N+
W.
I-
I.
I+
F.
F+
U.
U+
G.
G+
W.
W+
A.
A!
010101111010011110100110100010...

Second Run Output

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

result:

ok Correct! The number of the misses is 989 (100 test cases)

Test #13:

score: 100
Accepted
time: 2ms
memory: 3632kb

First Run Input

prepare
100
MOHGEABJDDXQJMYVSPKBWONVTCPLWSQRFEKUNUHTLCXYIAFIGR
LOFDRVYTQJXQHRTKMBHCEVSAUUIFAEXLMOGIKPBYNWNWCJPGSD
EJBMJEYAAUDIPOTXILRCUQSDNKVPRYFCKMLSQGWFTVXOHNBHWG
MHKMCDGVOQRWJBFSKLSGTYUDWOIAIUPCYTQPNEHBNJRAFXXVEL
AVRXEJCFQXWBYTQRSWYHOBUPUNGSDMHILCNLFKJKMDGEOITAPV
IRLQBTAYITACMJROOJHYNHSPBQLNEVWGX...

First Run Output

10110010101001100100001110000110110111001000110000

11111010000111011010001110110010101011100101110000

10100000100001110110000110111000010000101011101000

11000001100100001011111011101011001011110110011000

11110110001111110010010011010101100110000100100100

0001000111000101101001100001101001000101...

Second Run Input

play
100
10110010101001100100001110000110110111001000110000
M.
M+
O.
O+
H.
H+
G.
G+
E.
E+
A.
A+
B.
B+
J.
J+
C.
U-
K.
T-
V.
F-
X.
Y-
L.
N-
D.
Y-
Y.
Y+
L.
L+
U.
U+
P.
W-
X.
X+
D.
D+
S.
V-
V.
V+
W.
W+
Q.
P-
P.
P+
K.
K+
T.
T+
I.
I+
R.
Q-
Q.
Q+
N.
N+
F.
F+
C.
C+
S.
S+
R.
R!
111110100001110110100011101100...

Second Run Output

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

result:

ok Correct! The number of the misses is 982 (100 test cases)

Test #14:

score: 100
Accepted
time: 2ms
memory: 3600kb

First Run Input

prepare
100
KVKFHJETMUGYIINCNCXOSBTFLAAQERRDPVHJUXWDPQYWOMLSBG
RKGEAFBUDOEJVNHJBSTOAHIWMWKFCPCYYVITXGXQUDLQSNLRMP
VFSDMWJQNEGIOKCAQFCUJHRBPLWLMUPOASHKYETNTXGDXRVBIY
AUELFVXFMCRTRVDAOJQWJKMQLEUKWSHXGIYHNNBOPBTPGCYSDI
MGTWHRVJKOPGAYSEXKCJIQRYPDXNBTEFBOWACHSLINLUVUDQFM
CAVGCIHTJQXHKTPQOLADBJDMGUWYENMLV...

First Run Output

01000010000111101001000111000100111001101010110100

11110101011010100101010000101011011000001000010100

01110110001010000111010100111001011000101000001000

11110001011010011000011011100010110011111001101000

10001111010010111001000110100101101000110111001000

0010000100100000010001100001011101001011...

Second Run Input

play
100
01000010000111101001000111000100111001101010110100
K.
K+
V.
V+
F.
F+
H.
H+
J.
J+
E.
E+
T.
T+
M.
M+
S.
C-
U.
D-
Q.
I-
R.
G-
Y.
O-
S.
S+
A.
Q-
Q.
Q+
D.
D+
Y.
Y+
C.
C+
O.
O+
X.
N-
A.
A+
B.
W-
U.
U+
L.
G-
G.
G+
P.
R-
R.
R+
L.
L+
X.
X+
N.
N+
I.
I+
W.
W+
B.
B+
P.
P!
111101010110101001010100001010...

Second Run Output

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

result:

ok Correct! The number of the misses is 998 (100 test cases)

Test #15:

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

First Run Input

prepare
100
HXKQHJLCSAEPANTBUFWEUTDPXRRDMQGOKMSBFWVCVLONYYIGJI
FHATBVFQWOIECJDGBSLKREDMQYNOTACNMKSJVULXGYIPPURWXH
JVWOTSJAXCAPFURISNLKXYEHWMPIOHGFUQBCRQVMLYEGDBDNTK
TOWIKXQPDRLAHPNUGUNKIRBECJYSQYMEFSDACFLXHVMJGTWBVO
WTBUHJHOXMQNYCGNQBSKUVPFOFGILTXYLARSEDCRVIWAEJMPDK
VHYQVKEJMPWUDBTWSMKIAGTEFGSYDUCCJ...

First Run Output

00100000011000000110111000001110010111100101000100

01100010001110111000111000001000100100011011110100

01100001100100011000111000001100001001010000101000

10110110001101110100101011001011100100111010110000

01010110111010001000101001100010110100011001111000

0010000000111101101010010100101110100000...

Second Run Input

play
100
00100000011000000110111000001110010111100101000100
H.
H+
X.
X+
K.
K+
Q.
Q+
J.
J+
L.
L+
C.
C+
S.
S+
T.
V-
W.
G-
A.
B-
F.
Y-
I.
M-
Y.
Y+
V.
V+
D.
W-
W.
W+
A.
A+
U.
U+
N.
R-
N.
N+
P.
G-
G.
G+
E.
T-
T.
T+
E.
E+
F.
F+
P.
P+
I.
I+
O.
O+
D.
D+
R.
R+
B.
B+
M.
M!
011000100011101110001110000010001001...

Second Run Output

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

result:

ok Correct! The number of the misses is 1005 (100 test cases)

Test #16:

score: 100
Accepted
time: 2ms
memory: 3856kb

First Run Input

prepare
100
SCMKNXOIGSNYXFERVPAEUQHDULFWTCLIRKMJPOHBBYGJTDVQWA
XGAPSFERTQDFUWOJHLRPYNXIOVSBQTJDGCVKKAMCIUBMLNYEHW
OTQJRXSJVDUSNDIPTGYBIRAMWBEFXFCLEKHGMKQAYHOLNPUCVW
GTPJIHXDRBSYWEECOUYLWNLCXPMJFUAAMOGTVDHQRNFVKQKIBS
URSEIOWGQPCNVFDRMNIUJASLAEBBKFYHJYGVMOXDKWTQXPTCHL
ONFBMGMEDKCRRWCKPABJPDIHIYUGWQXSU...

First Run Output

10010010111001000110000101010000110010100111111000

01101000000110100111001001011011010011110101001000

01010100001001100111100010101000111011010000001100

01000111000110011011011011110101100100011010100100

11001011110001101010011001001010100110010101000100

0010010110010001010100100110001101101111...

Second Run Input

play
100
10010010111001000110000101010000110010100111111000
S.
S+
C.
C+
M.
M+
K.
K+
N.
N+
X.
X+
O.
O+
I.
I+
V.
B-
F.
G-
A.
Q-
F.
F+
H.
U-
E.
V-
V.
V+
T.
J-
T.
T+
L.
A-
A.
A+
W.
J-
J.
J+
Q.
Q+
P.
L-
L.
L+
U.
U+
P.
P+
G.
G+
D.
Y-
R.
D-
D.
D+
B.
B+
E.
E+
H.
H+
R.
R+
Y.
Y+
W.
W!
011010000001101001110010...

Second Run Output

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

result:

ok Correct! The number of the misses is 993 (100 test cases)

Test #17:

score: 100
Accepted
time: 2ms
memory: 3696kb

First Run Input

prepare
100
NNODHVLKIUVAYTXEBRPAPWXGHYJBOMRSSGKFUIQMFWQLTCJEDC
HANGPOYBUGIFVTKOXXWBFRQAJLMYLMPUWCJEREKCVNDSIQSHDT
ORBBPYTLJSQVISIAGHLGUREEOKAXFKYUJQXDMHNCTNCMDWFWPV
GIAKBSRKPITXAVCLFEWDQFVNJJHXOGRMMYDEHUONTBWPUSCQLY
PXIMBIELUQGORGWAKHNJQJBYFTNTKAPDDVVCHOSYLURFMCESXW
GWUXITHXWIKOVQLSENPLYKDNCQPCJFBRM...

First Run Output

10000000111000001100011001010011010101000110100100

11110111101010010110010001111011110011011011001000

00011010101011000000001101111000010101001000000100

10111010010000110011100010010110110101111011010100

01111000001110100000110101101001110100010110010100

1000010001001000111110001001000011010010...

Second Run Input

play
100
10000000111000001100011001010011010101000110100100
N.
N+
O.
O+
D.
D+
H.
H+
V.
V+
L.
L+
K.
K+
I.
I+
Q.
G-
G.
G+
E.
W-
J.
P-
U.
S-
B.
C-
R.
F-
R.
R+
T.
W-
W.
W+
X.
U-
U.
U+
M.
T-
T.
T+
Y.
X-
X.
X+
S.
S+
M.
M+
A.
F-
F.
F+
P.
P+
B.
B+
A.
A+
Q.
Q+
E.
E+
C.
C+
Y.
Y+
J.
J!
111101111010100101100100...

Second Run Output

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

result:

ok Correct! The number of the misses is 989 (100 test cases)