QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#783291#9645. 字符游戏JWRuixi100 ✓3200ms93380kbC++176.8kb2024-11-26 07:37:132024-11-26 07:37:18

Judging History

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

  • [2024-11-26 07:37:18]
  • 评测
  • 测评结果:100
  • 用时:3200ms
  • 内存:93380kb
  • [2024-11-26 07:37:13]
  • 提交

answer

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/hash_policy.hpp>
#ifdef LOCAL
#include "stdafx.h"
#else
#include <bits/stdc++.h>
#define IL inline
#define LL long long
#define eb emplace_back
#define sz(v) ((int) (v).size())
#define me(f, x) memset(f, x, sizeof(f))
#define mc(f, g) memcpy(f, g, sizeof(g))
#define L(i, j, k) for (int i = (j); i <= (k); ++i)
#define R(i, j, k) for (int i = (j); i >= (k); --i)
#define FIO(FILE) freopen(FILE".in", "r", stdin), freopen(FILE".out", "w", stdout)
using namespace std;

using vi = vector<int>;
#endif

#define int unsigned

constexpr int N = 5e4 + 9;
constexpr int M = 1e5 + 9;
constexpr int Z = 10;
int n, m, a[N];

int hd[N], tot;

struct edg {
  int v, nx;
} e[N * 2];

IL void add_edge (int u, int v) {
  e[++tot] = {v, hd[u]};
  hd[u] = tot;
}

pair<int, int> q[M];
int ans[M];

int lis[N], nxt[M];

IL int mex (const vi &v) {
  static int buc[Z + 3];
  me(buc, 0);
  for (int x : v) {
    ++buc[x];
  }
  int ret = 0;
  while (buc[ret]) {
    ++ret;
  }
  return ret;
}

int b[N], lst[Z], fst[Z], L;

IL int to (const int &x) {
  return x ^ 1 ? b[x - 1] : Z;
}

struct umap {
  int v[Z + 1];
  int operator [] (int x) const {
    return v[to(x)];
  }
  int& operator [] (int x) {
    return v[to(x)];
  }
} f[N], g[N][Z];

IL int at (int x, int y, int c) {
  return x > y ? 0 : g[y][c][x];
}

IL int at (int x, int y) {
  return x > y ? 0 : f[y][x];
}

void append (int c) {
  b[++L] = c;
  lst[c] = L;
  fst[c] > L && (fst[c] = L, 0);
  vi tmp{1};
  L (i, 0, Z - 1) {
    if (lst[i] && lst[i] < L) {
      tmp.eb(lst[i] + 1);
    }
  }
  sort(tmp.begin(), tmp.end(), greater<>());
  for (int x : tmp) {
    vi qwq;
    L (c, 0, Z - 1) {
      if (c == b[L]) {
        g[L][c][x] = at(x, L - 1, c);
        qwq.eb(g[L][c][x]);
      } else {
        int y = lst[c] + 1;
        if (y > x) {
          g[L][c][x] = at(x, L - 1, c) ^ at(y, L - 1) ^ f[L][y];
          qwq.eb(g[L][c][x]);
        }
      }
    }
    f[L][x] = mex(qwq);
    L (c, 0, Z - 1) {
      if (c ^ b[L] && lst[c] < x) {
        g[L][c][x] = f[L][x];
      }
    }
  }
}

int lab[N];

IL int pd (int u, int f) {
  int msk = 0, ban = 0;
  for (int i = hd[u], v; i; i = e[i].nx) {
    if ((v = e[i].v) ^ f) {
      int t = pd(v, u);
      msk |= ban & t;
      ban |= t;
    }
  }
  int l = msk ? 32 - __builtin_clz(msk) : 0;
  lab[u] = __builtin_ctz((ban >> l) + 1) + l;
  assert(lab[u] <= 20);
  return (ban >> lab[u] | 1) << lab[u];
}

bool vis[N];

int mp[2][N];

struct vmap {
  int v[Z + 1], *p;
  int& operator [] (int x) {
    return v[p[x]];
  }
  int operator [] (int x) const {
    return v[p[x]];
  }
  int safe (int x) {
    return x ? v[p[x]] : 0;
  }
} F[2][N], G[2][N][Z];

int ff[2][N][Z], len[2][N];

int op, sq[N], dfc;

void dfs (int u, int f) {
  sq[++dfc] = u;
  int c = a[u];
  int memlst = lst[c];
  int memfst = fst[c];
  append(c);
  len[op][u] = L;
  mc(ff[op][u], fst);
  F[op][u].v[Z] = at(1, L);
  L (i, 0, Z - 1) {
    G[op][u][i].v[Z] = at(1, L, i);
  }
  L (i, 0, Z - 1) {
    if (1 < fst[i] && fst[i] <= L) {
      F[op][u].v[i] = at(1, fst[i] - 1);
      L (j, 0, Z - 1) {
        G[op][u][j].v[i] = at(1, fst[i] - 1, j);
      }
    }
  }
  for (int i = hd[u], v; i; i = e[i].nx) {
    if ((v = e[i].v) ^ f && !vis[v]) {
      dfs(v, u);
    }
  }
  lst[c] = memlst;
  fst[c] = memfst;
  --L;
}

int col[N];

struct vmap2 {
  int v[Z + 1][Z + 1];
  int get (int x, int y) const {
    return v[mp[0][x]][mp[1][y]];
  }
  int& get (int x, int y) {
    return v[mp[0][x]][mp[1][y]];
  }
} H, W[Z];

void dfz (int u) {
  vis[u] = true;
  op = 0;
  dfs(u, 0);
  op = 1;
  col[u] = u;
  vi Rt;
  for (int i = hd[u], v; i; i = e[i].nx) {
    if (!vis[v = e[i].v]) {
      dfc = 0;
      dfs(v, 0);
      int rt = v;
      L (i, 1, dfc) {
        if (lab[sq[i]] > lab[rt]) {
          rt = sq[i];
        }
      }
      assert(rt != u);
      assert(lab[rt] < lab[u]);
      Rt.eb(rt);
      L (i, 1, dfc) {
        col[sq[i]] = rt;
      }
    }
  }
  int _ = lis[u];
  while (_) {
    int id = _;
    _ = nxt[_];
    auto [x, y] = q[id];
    if (col[x] == col[y]) {
      nxt[id] = lis[col[x]];
      lis[col[x]] = id;
      continue;
    }
    if (y == u) {
      swap(x, y);
    }
    int l1 = len[0][x];
    int l2 = len[1][y];
    mp[0][l1] = mp[1][l2] = Z;
    vi tmp0, tmp1;
    tmp0.eb(l1);
    tmp1.eb(l2);
    L (i, 0, Z - 1) {
      int p = ff[0][x][i];
      if (1 < p && p <= l1) {
        mp[0][p - 1] = i;
        tmp0.eb(p - 1);
      }
      p = ff[1][y][i];
      if (1 < p && p <= l2) {
        mp[1][p - 1] = i;
        tmp1.eb(p - 1);
      }
    }
    auto qwq = [&] (int p, int q) -> int {
      return !p || !q ? (p ? F[0][x][p] : (q ? F[1][y][q] : 0)) : H.get(p, q);
    }; 
    sort(tmp0.begin(), tmp0.end());
    sort(tmp1.begin(), tmp1.end());
    vi whq;
    whq.reserve(10);
    for (int p : tmp0) {
      for (int q : tmp1) {
        L (c, 0, Z - 1) {
          int v = G[0][x][c][p] ^ G[1][y][c][q];
          int pp = min(p + 1, ff[0][x][c]);
          int qq = min(q + 1, ff[1][y][c]);
          if (pp <= p || qq <= q) {
            W[c].get(p, q) = v ^ F[0][x].safe(pp - 1) ^ F[1][y].safe(qq - 1) ^ qwq(pp - 1, qq - 1);
            whq.eb(W[c].get(p, q));
          } 
        }
        int SG = H.get(p, q) = mex(whq);
        whq.clear();
        L (c, 0, Z - 1) {
          if (ff[0][x][c] > p && ff[1][y][c] > q) {
            W[c].get(p, q) = SG;
          }
        }
      }
    }
    if (H.get(l1, l2)) {
      L (i, 0, Z - 1) {
        if (ff[0][x][i] <= l1 || ff[1][y][i] <= l2) {
          ans[id] += !W[i].get(l1, l2);
        }
      }
    } 
  }
  for (int v : Rt) {
    dfz(v);
  }
}

signed main () {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  char ch;
  do {
    cin.get(ch);
  } while (ch < '0' || ch > '9');
  L (i, 1, n) {
    a[i] = ch ^ 48;
    cin.get(ch);
  }
  L (i, 1, n - 1) {
    int u, v;
    cin >> u >> v;
    add_edge(u, v);
    add_edge(v, u);
  }
  me(fst, 0x3f);
  pd(1, 0);
  int rt = 1;
  L (i, 2, n) {
    if (lab[i] > lab[rt]) {
      rt = i;
    }
  }
  L (i, 1, m) {
    int x, y;
    cin >> x >> y;
    if (x == y) {
      ans[i] = 1;
    } else {
      q[i] = {x, y};
      nxt[i] = lis[rt];
      lis[rt] = i;
    }
  }
  L (o, 0, 1) {
    L (i, 1, n) {
      F[o][i].p = mp[o];
      L (c, 0, Z - 1) {
        G[o][i][c].p = mp[o];
      }
    }
  }
  dfz(rt);
  L (i, 1, m) {
    if (ans[i]) {
      cout << "Alice " << ans[i] << '\n';
    } else {
      cout << "Bob\n";
    }
  }
  cerr << clock() << '\n';
}
// I love WHQ!

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 0ms
memory: 22100kb

input:

8 1000
20002200
7 5
1 4
4 2
8 5
4 6
4 5
3 7
2 6
1 3
6 4
4 4
6 8
3 1
2 6
1 2
2 2
5 3
4 1
4 3
8 6
2 7
5 6
5 8
8 4
2 1
4 6
5 2
5 6
6 8
4 1
7 2
6 4
7 5
5 2
1 2
5 7
6 3
8 8
7 1
3 1
4 1
7 6
7 2
1 2
1 8
2 3
5 5
7 3
8 3
2 1
8 2
7 6
1 8
8 1
1 5
2 3
5 3
6 4
2 4
8 4
5 3
3 2
3 1
4 1
2 2
3 6
6 6
5 3
5 8
4 8
3 2
...

output:

Bob
Alice 2
Bob
Alice 1
Alice 2
Alice 2
Bob
Bob
Alice 1
Bob
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Alice 2
Bob
Alice 1
Bob
Bob
Bob
Bob
Bob
Alice 2
Alice 1
Alice 2
Alice 2
Bob
Alice 2
Alice 1
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Alice 2
Alice 2
...

result:

ok 1000 lines

Test #2:

score: 7
Accepted
time: 0ms
memory: 22408kb

input:

8 1000
21120020
2 1
4 2
5 7
4 3
6 8
5 2
6 4
4 1
6 1
2 1
2 3
3 2
4 1
2 1
4 6
2 1
4 4
1 2
6 5
8 5
3 6
4 1
5 7
8 1
6 4
1 4
7 7
8 4
2 3
4 7
1 2
5 1
5 1
2 8
7 7
4 7
2 1
1 3
6 1
2 1
7 2
5 6
5 6
3 5
2 8
3 5
7 2
6 1
6 1
1 6
1 4
6 8
2 8
3 5
1 7
1 8
2 4
6 8
4 8
4 6
3 1
7 3
6 6
3 7
1 4
4 3
5 4
5 8
3 2
2 6
5 8
...

output:

Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 3
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 3
Alice 3
Alice 3
Alice 1
Alice 1
Bob
Alice 2
Alice 1
Bob
Alice 3
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Alice 3
Alice 1
Alice 1
Alice 1
...

result:

ok 1000 lines

Test #3:

score: 7
Accepted
time: 3ms
memory: 20004kb

input:

8 1000
12110101
8 4
2 6
7 5
8 1
1 6
7 3
2 5
8 7
4 5
5 8
8 3
5 7
7 7
7 1
8 1
4 3
8 1
3 1
5 4
6 3
6 2
4 2
8 3
5 7
2 5
1 5
3 8
1 2
6 2
4 2
5 3
4 4
3 3
6 3
1 7
6 6
2 8
1 8
6 3
8 1
3 2
3 3
7 1
4 5
7 2
8 4
4 2
2 5
1 1
8 5
6 6
4 1
8 1
4 6
6 7
2 2
6 2
4 1
6 6
5 1
3 5
2 6
5 4
7 7
1 4
8 7
6 2
8 5
8 7
5 4
1 8
...

output:

Alice 3
Alice 3
Alice 3
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Bob
Bob
Alice 1
Alice 1
Bob
Alice 3
Alice 1
Bob
Bob
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Alice 3
Alice 3
Bob
Alice 1
Bob
Bob
Alice 1
Alice 3
...

result:

ok 1000 lines

Test #4:

score: 7
Accepted
time: 0ms
memory: 22144kb

input:

8 1000
10100100
3 8
8 6
1 8
7 8
8 5
4 8
2 8
8 8
4 1
2 2
5 7
5 8
5 3
8 4
5 1
1 5
5 1
8 2
6 7
2 3
8 3
7 8
5 7
3 7
4 4
1 2
7 5
3 7
5 1
3 6
1 5
6 7
1 8
4 1
7 6
1 4
4 6
7 8
8 4
2 4
3 7
2 8
8 4
5 3
4 1
2 5
3 3
6 6
4 1
3 6
8 6
5 3
7 3
3 6
2 2
4 6
2 4
7 3
8 4
1 4
3 2
3 2
5 2
2 2
6 2
6 7
8 7
3 6
1 8
2 1
4 2
...

output:

Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Bob
Alice 1
Bob
Bob
Alice 1
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Bob
Alic...

result:

ok 1000 lines

Test #5:

score: 7
Accepted
time: 0ms
memory: 22108kb

input:

8 1000
21010212
3 7
8 3
4 1
3 6
2 1
5 3
3 1
3 8
6 2
3 5
5 7
6 2
6 2
3 8
1 4
2 7
7 8
8 8
1 8
7 1
2 5
3 5
8 3
6 1
7 2
4 8
5 6
8 8
7 8
6 3
3 4
7 7
4 1
8 6
2 4
2 7
7 5
4 3
2 7
5 1
8 4
2 2
6 8
6 5
8 1
5 5
6 6
8 6
2 5
4 3
3 2
2 3
4 7
1 8
5 6
8 6
1 1
4 2
7 3
8 1
2 5
8 4
1 2
5 3
7 2
4 6
4 3
7 6
2 3
2 2
8 8
...

output:

Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 3
Alice 1
Alice 1
Alice 3
Alice 3
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 3
Bob
Alice 3
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 3
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Alice 3
...

result:

ok 1000 lines

Test #6:

score: 7
Accepted
time: 0ms
memory: 24128kb

input:

8 1000
21101220
2 7
5 3
2 6
4 5
1 4
8 2
4 8
5 1
6 3
4 2
2 6
3 7
1 8
6 4
1 1
4 3
4 3
8 8
7 5
4 4
4 2
1 3
8 7
1 5
5 8
6 8
2 3
7 4
6 3
2 6
8 6
4 6
2 8
3 1
1 6
5 7
7 4
6 6
2 8
6 5
2 4
1 2
6 7
5 5
8 5
7 2
4 3
6 3
5 4
7 4
1 6
7 5
8 6
4 4
8 8
5 8
4 7
5 7
8 3
4 1
7 6
6 2
6 6
2 4
6 7
4 3
5 6
3 7
6 6
3 5
4 7
...

output:

Alice 3
Alice 1
Bob
Bob
Alice 1
Bob
Alice 3
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 1
Alice 3
Alice 1
Bob
Alice 3
Alice 3
Bob
Alice 3
Alice 1
Alice 1
Alice 3
Alice 1
Bob
Alice 1
Bob
Alice 3
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Alice 3
Alice 1
Alice 1
...

result:

ok 1000 lines

Test #7:

score: 7
Accepted
time: 0ms
memory: 24412kb

input:

8 1000
12221101
5 7
3 1
1 7
7 6
2 6
1 8
5 4
7 4
3 3
5 8
7 4
4 6
1 2
7 8
7 1
6 8
2 7
4 8
7 6
8 3
6 3
5 1
6 2
1 7
7 7
2 5
6 6
4 6
4 4
4 3
8 3
1 8
8 2
5 6
4 3
8 8
4 4
5 6
4 6
4 4
7 1
6 4
1 6
4 8
4 3
1 1
4 3
3 3
3 3
6 6
6 7
1 7
5 2
6 4
7 1
6 4
4 1
3 5
1 5
5 4
8 1
6 1
5 1
6 8
2 3
7 1
3 8
1 8
3 7
8 6
6 3
...

output:

Alice 3
Alice 1
Alice 1
Alice 3
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 3
Alice 1
Bob
Bob
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alic...

result:

ok 1000 lines

Test #8:

score: 7
Accepted
time: 0ms
memory: 22384kb

input:

8 1000
21001110
2 8
1 6
2 3
4 3
6 7
7 8
4 5
5 7
1 5
6 7
7 3
4 4
1 4
3 1
3 7
7 6
5 4
2 4
3 7
1 2
3 1
7 3
2 7
1 6
8 1
1 5
7 4
4 6
8 1
3 5
6 4
6 8
8 5
4 1
3 2
4 8
6 3
7 7
5 5
3 4
7 8
2 2
8 1
1 8
8 1
2 8
1 3
2 1
4 2
3 6
5 1
3 5
3 1
4 1
1 6
2 1
8 2
8 7
3 1
3 1
1 4
5 3
6 6
3 2
2 2
8 3
8 2
8 2
1 1
5 3
7 3
...

output:

Alice 1
Alice 1
Alice 1
Alice 2
Alice 1
Bob
Bob
Alice 2
Alice 1
Bob
Bob
Alice 2
Alice 1
Bob
Alice 2
Alice 1
Bob
Alice 3
Alice 1
Alice 2
Alice 2
Alice 3
Bob
Alice 2
Bob
Alice 2
Bob
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Bob
Alice 1
Bob
Alice 2
Alice 1
Bob
...

result:

ok 1000 lines

Test #9:

score: 7
Accepted
time: 0ms
memory: 20320kb

input:

10 1000
8402982536
9 10
2 6
3 1
5 9
8 1
6 7
9 4
3 10
9 6
9 1
7 7
3 3
3 3
4 2
2 3
9 2
5 3
5 5
4 7
6 6
8 10
1 5
1 8
9 7
7 2
8 7
9 3
9 7
7 6
6 7
6 10
8 8
9 6
10 4
2 2
4 8
10 6
7 7
9 10
2 2
1 3
9 7
2 3
1 4
5 7
6 3
7 7
3 2
1 2
10 6
7 3
1 5
6 1
10 6
6 4
3 1
5 4
7 4
4 2
3 10
9 7
6 3
7 8
8 6
1 4
7 7
4 7
1 7...

output:

Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 5
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 5
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Bob
Bob
Alice 3
Alice 1
Bob
Alice 3
Alice 1
Bob
Alice 3
Alice 1
Bob
Alice 1
Bob
Alice 3
Alice 5
Alice 5
Bob
Bob
Alice 1
Alice 5
Alice 1
Alice 3
Alice 5
Alice 5
Alice 3
...

result:

ok 1000 lines

Test #10:

score: 7
Accepted
time: 4ms
memory: 22048kb

input:

10 1000
0069433911
2 8
4 6
4 7
3 9
4 3
5 2
9 8
6 1
10 3
1 7
9 4
9 3
2 3
1 9
1 6
4 10
9 8
10 8
9 7
9 4
2 1
5 2
9 10
3 9
9 9
10 2
5 7
8 4
5 2
8 10
1 2
1 10
2 8
9 5
3 2
1 4
6 4
5 3
7 6
5 7
3 9
1 7
3 3
9 10
7 6
5 3
8 4
7 8
9 3
5 9
10 6
2 1
7 10
5 2
7 7
5 7
10 10
4 9
5 9
7 7
9 10
5 6
6 6
7 5
3 1
9 8
3 9
...

output:

Alice 1
Alice 3
Bob
Bob
Alice 5
Bob
Alice 3
Bob
Alice 1
Bob
Alice 3
Alice 2
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Bob
Alice 1
Alice 2
Alice 5
Bob
Bob
Bob
Alice 3
Bob
Alice 5
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 5
Alice 1
Alice 2
Bob
Bob
Bob
Alice 2
Bob
Bob
Alice 1
Alic...

result:

ok 1000 lines

Test #11:

score: 7
Accepted
time: 0ms
memory: 22104kb

input:

10 1000
2402249289
8 6
9 7
8 4
9 2
5 1
1 4
3 10
2 3
7 6
8 6
5 6
5 10
7 4
9 5
10 9
1 1
6 7
8 2
6 3
6 2
9 7
3 3
8 6
9 5
2 10
6 1
3 2
1 4
7 4
7 1
2 3
3 8
4 10
9 6
3 3
5 10
6 1
3 8
1 6
4 6
7 2
7 5
3 2
5 6
3 8
8 3
3 5
8 9
8 2
9 3
3 2
2 4
4 9
9 8
6 2
8 5
2 6
1 1
9 1
7 10
2 2
3 7
5 6
9 10
4 6
6 9
6 6
5 10
...

output:

Bob
Bob
Alice 1
Alice 3
Bob
Bob
Alice 1
Bob
Alice 2
Alice 2
Alice 1
Bob
Alice 1
Bob
Bob
Alice 3
Bob
Bob
Alice 1
Alice 3
Alice 3
Bob
Alice 1
Alice 1
Alice 3
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Alice 3
Alice 3
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 2
Alice 3
Bob
Alice 2
Bob
Bob
Alice 1
Alice 1
Alic...

result:

ok 1000 lines

Test #12:

score: 7
Accepted
time: 0ms
memory: 24148kb

input:

10 1000
5440855673
5 10
5 6
8 5
7 5
5 3
1 5
5 4
5 9
5 2
10 1
9 10
1 2
4 8
4 2
6 5
8 4
7 4
9 10
10 1
6 10
9 5
5 2
1 10
6 2
3 10
4 1
5 8
10 3
9 8
3 7
10 5
2 10
4 2
9 8
8 1
1 10
5 3
10 4
6 5
5 5
4 10
9 2
5 7
3 3
8 8
2 7
1 8
8 6
8 7
8 10
1 7
7 1
5 10
10 1
7 6
8 3
3 2
6 1
3 1
10 4
8 4
3 3
3 7
10 1
2 3
1 ...

output:

Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Bob
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Bob
Alice 1
Alice 3
Alice 3
Bob
Alice 1
Alice 1
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alic...

result:

ok 1000 lines

Test #13:

score: 7
Accepted
time: 3ms
memory: 22096kb

input:

10 1000
2192963407
9 8
2 9
4 1
1 5
9 6
10 1
7 1
1 9
1 3
4 6
9 4
1 7
9 10
7 7
7 10
5 8
2 9
2 1
3 10
8 3
2 7
2 3
2 4
4 7
7 2
5 2
6 8
5 8
2 4
2 2
7 1
7 1
4 5
1 3
10 3
4 7
10 8
6 6
3 9
8 8
9 9
4 1
10 8
5 9
2 2
4 10
2 1
1 1
7 1
3 8
6 8
8 2
7 10
1 7
8 5
8 7
3 8
6 9
1 5
5 5
3 7
5 1
5 7
1 1
1 7
5 10
2 8
8 8...

output:

Alice 3
Bob
Bob
Alice 3
Alice 1
Alice 3
Bob
Bob
Alice 3
Alice 3
Bob
Bob
Bob
Alice 3
Bob
Bob
Bob
Alice 3
Bob
Alice 3
Alice 1
Bob
Bob
Bob
Bob
Alice 3
Bob
Bob
Alice 1
Alice 3
Alice 1
Alice 1
Alice 1
Bob
Alice 3
Alice 1
Bob
Alice 3
Alice 1
Bob
Bob
Alice 3
Alice 3
Alice 3
Bob
Bob
Bob
Bob
Bob
Bob
Alice 1
...

result:

ok 1000 lines

Test #14:

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

input:

10 1000
3386934725
9 6
4 10
7 3
3 2
7 8
5 3
4 7
1 9
9 8
6 10
4 10
8 3
3 8
6 9
9 1
3 4
3 4
8 7
4 6
8 10
5 5
5 1
4 4
9 5
6 8
7 1
7 5
10 4
4 2
10 4
9 8
3 6
5 2
4 5
6 6
5 3
8 1
5 2
3 7
10 1
8 8
2 6
3 6
1 4
9 8
3 8
1 8
5 3
6 10
1 6
9 6
3 5
2 10
5 2
10 1
3 4
4 1
2 9
9 5
4 8
10 3
2 4
6 9
10 7
4 1
4 2
3 6
6...

output:

Bob
Bob
Alice 3
Alice 3
Bob
Bob
Alice 3
Alice 3
Bob
Alice 5
Bob
Alice 1
Bob
Alice 1
Alice 5
Alice 3
Bob
Alice 3
Bob
Bob
Bob
Bob
Alice 5
Alice 3
Bob
Alice 1
Bob
Alice 3
Alice 3
Bob
Bob
Alice 1
Alice 1
Alice 5
Alice 5
Bob
Alice 3
Alice 3
Bob
Bob
Alice 1
Bob
Bob
Alice 5
Alice 3
Bob
Alice 3
Alice 5
Alic...

result:

ok 1000 lines

Test #15:

score: 7
Accepted
time: 0ms
memory: 20052kb

input:

10 1000
0783411333
9 5
1 4
1 2
3 1
4 10
8 1
3 9
8 6
1 7
3 6
2 5
4 9
2 8
9 9
1 6
4 4
7 9
6 7
5 1
10 8
4 9
7 5
6 9
9 10
7 1
1 4
2 7
1 10
7 6
6 4
8 5
8 6
2 7
8 4
5 8
1 9
5 7
2 4
1 3
1 1
8 7
1 10
9 4
3 8
4 10
7 8
10 10
7 8
5 5
10 10
2 8
1 1
7 1
5 9
9 1
5 7
3 6
10 5
7 4
8 1
1 5
9 1
4 1
9 3
9 7
9 7
4 9
6 ...

output:

Bob
Alice 5
Alice 1
Alice 3
Alice 1
Alice 3
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 5
Alice 2
Alice 1
Bob
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 2
Bob
Alice 3
Alice 1
Alice 2
Alice 3
Alice 5
Alice 3
Bob
Alice 1
Alice 3
Bob
Alice 1
Alice 3
Alice 1
Alice 3
Alice 1
Alice 3
Alice 1
Alice 1
Alice 3
...

result:

ok 1000 lines

Test #16:

score: 7
Accepted
time: 0ms
memory: 22400kb

input:

10 1000
4318437248
3 6
10 9
7 8
2 8
1 5
7 3
4 1
9 2
8 5
3 2
2 4
8 5
9 8
9 3
2 4
10 5
1 10
9 6
7 5
1 3
2 9
1 3
10 5
3 5
1 2
10 2
5 5
2 2
6 3
5 3
3 7
9 2
6 8
8 9
3 4
1 6
3 2
3 2
1 5
2 10
3 4
10 9
7 8
5 5
5 5
9 2
4 7
3 9
6 1
7 10
1 2
9 7
5 2
9 5
6 1
5 4
3 9
3 3
10 7
6 7
10 5
9 4
5 3
3 1
3 3
9 2
5 7
6 8...

output:

Bob
Bob
Bob
Alice 3
Alice 5
Bob
Alice 2
Alice 2
Alice 1
Alice 3
Bob
Bob
Bob
Alice 2
Bob
Alice 3
Alice 3
Alice 1
Alice 1
Bob
Bob
Bob
Bob
Bob
Alice 3
Alice 5
Alice 5
Bob
Bob
Alice 1
Alice 3
Alice 5
Bob
Bob
Alice 1
Alice 1
Bob
Bob
Alice 5
Alice 5
Alice 5
Alice 3
Bob
Alice 3
Alice 1
Alice 5
Bob
Alice 5
...

result:

ok 1000 lines

Subtask #2:

score: 13
Accepted

Test #17:

score: 13
Accepted
time: 23ms
memory: 22084kb

input:

480 20000
32012301130203122211230023310322103223212113200231311033220010333333321311120012223103131311311301133221302321303010010022110030012100331300310310311022022323203133200022232131230000211133110313130331312231301200120332012021021132321030321120330201330112231031300132223110203123333321033013...

output:

Bob
Alice 1
Alice 2
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 2
Alice 1
Alice 2
Alice 2
Alice 1
Alice 4
Bob
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Bob
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
...

result:

ok 20000 lines

Test #18:

score: 13
Accepted
time: 181ms
memory: 22464kb

input:

500 20000
73687348165015627904416892848753049277736455324346250540516375277947857861973194207059437453784014238783781479748334028755967119529784157735609134344453271739463723221429334773709757461340229620064198948768302403565379630679235113271028908928419462143360342711694298852690722169197788083620...

output:

Alice 1
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 3
Alice 2
Alice 3
Alice 2
Alice 1
Alice 2
Alice 1
Alice 3
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Alice 3
Alice 3
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 3
Alice 1
Alice 2
Alice 2
Alice 3
Alice 1
Alice 1
Alice 3
Alice 1
Alice 2
Alice 1
...

result:

ok 20000 lines

Subtask #3:

score: 12
Accepted

Dependency #2:

100%
Accepted

Test #19:

score: 12
Accepted
time: 69ms
memory: 26492kb

input:

2900 20000
4141100311441022141004021100422204333020421404142000021040413142102014130414141343213023410222003014133204210013013312214421010201202231032034141334413222133200331424424033310242341021230001103432022431243131313312334000202130304142220121434012122232402403340002143234321441304320413214214...

output:

Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Bob
Bob
Bob
Bob
Alice 1
Bob
Alice 3
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Alice 1
Bob
Alice 2
Bob
Alice 1
Alice 1
Bob
Alice 2
Bob
Bob
Bob
Bob
Bob
Bob
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 2
Alice 1
Bob
...

result:

ok 20000 lines

Test #20:

score: 12
Accepted
time: 220ms
memory: 28656kb

input:

3000 20000
0632646244233053883653005902095690349866815175579636899613527485536586407428380999423236264050013980205742691453835142820657794940427740023522125242887874701190042600813771108844757657136827100662657033479283859173358522259944337315076287587724207344864952582542839573938367304692884891988...

output:

Bob
Alice 2
Alice 1
Bob
Bob
Bob
Bob
Alice 1
Alice 2
Alice 2
Alice 1
Alice 2
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
Alice 1
Alice 1
Alice 3
Alice 2
Alice 1
Bob
Bob
Alice 2
Bob
Alice 1
Alice 3
Alice 2
Alic...

result:

ok 20000 lines

Subtask #4:

score: 19
Accepted

Dependency #3:

100%
Accepted

Test #21:

score: 19
Accepted
time: 1135ms
memory: 93100kb

input:

49000 100000
01023213304220000331213311230202011441012123004001030133104430442321203014010201400203431331230331121033312443112103302201330131221321212410313022210413142421100301313021132032220012203434402133300323421110033440400111441044234320123340033222442012103044043422420113001121033032014004014...

output:

Alice 1
Bob
Bob
Bob
Alice 1
Bob
Alice 2
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Bob
Alice 1
Bob
Bob
Bob
Bob
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Bob
Bob
Bob
Bob
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 2
Bob
...

result:

ok 100000 lines

Test #22:

score: 19
Accepted
time: 3173ms
memory: 92880kb

input:

50000 100000
28389295275554509470597994895319759760941267257897055842298078178986380422073104189201510046554719704690426374041857717076905776680508059522444566764985590363287700638676939048897823271225995386225345535104415608407773286763759702247029533606363850114135108326528698187966786409003286200...

output:

Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Alice 2
Bob
Bob
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 2
Bob
Alice 1
Bob
Alice 1
Bob
Alice 3
Alice 1
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 3
Alice 1
...

result:

ok 100000 lines

Subtask #5:

score: 24
Accepted

Test #23:

score: 24
Accepted
time: 97ms
memory: 43376kb

input:

19000 20000
102021210212211220210110112221121210201110111120112111122211020121110112100120010111010011110122211022001210202111112120211102021001200110111001202011100212112112002221022112021122001001120010111210011110021012122000122022020101201022011202011221021202120100112220021112201022221220120100...

output:

Alice 2
Bob
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Alice 2
Alice 1
Alice 1
Alice 2
Alice 3
Alice 1
Alice 2
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 2
Alice 2
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Alice 2
Alice 1
Alice 1
Alic...

result:

ok 20000 lines

Test #24:

score: 24
Accepted
time: 153ms
memory: 45688kb

input:

19000 20000
001212200001011122012011201101022022120020112102112221002010112210011012212002020222010210221011120222210021001022000010020011111212122200110220122000120010101101001010202102210000022201120020020200201010022211211210002111110021200100010102111101100120022110101201200000120020002200020012...

output:

Bob
Bob
Alice 1
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Alice 2
Bob
Bob
Bob
Bob
Alice 2
Alice 2
Bob
Alice 1
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Bob
Alice 2
Alice 1
Alice 1
Bob
Alice 2
Alice 1
Bob
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Bob
...

result:

ok 20000 lines

Test #25:

score: 24
Accepted
time: 197ms
memory: 52484kb

input:

19000 20000
101001001010112210021021102021111020202220000001222002021012021201101222210110211101021022201120112010202221210022211112221210101021201012020112100121012210111000012221120121101221020001210021221122112211110200122222020202001221022001221101221100002120112222102101212012210222001201120210...

output:

Alice 1
Alice 1
Alice 1
Alice 2
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Bob
Bob
Alice 1
Bob
Alice 2
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Alice 1
Bob
Bob
Alice 2
...

result:

ok 20000 lines

Test #26:

score: 24
Accepted
time: 26ms
memory: 43684kb

input:

19000 20000
122201222212000201120212010200121110102111211200221110212100220001110200012022210120022022220122202110120121112220010110110011020021001002021212000112201000022012110111000111021002201222210021210212220102010010211020110002121202011111021002100002220122212101111221121000210101110002101120...

output:

Alice 3
Bob
Bob
Alice 3
Alice 1
Alice 1
Bob
Alice 3
Bob
Alice 3
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Bob
Bob
Alice 1
Alice 3
Bob
Alice 3
Bob
Alice 3
Alice 1
Bob
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alice 1
Alice 3
Bob
Alice 1
Alice 3
Bob
Bob
Bob
Alice 1
Bob
Alice 3
Bob
Bob
Bob
...

result:

ok 20000 lines

Test #27:

score: 24
Accepted
time: 28ms
memory: 45424kb

input:

19000 20000
210021212112211001001212101200220200121022201102020101011111100020102121122122020021101220020211012122111122102221011201100021012011120102112211222211221221202012200001202222211002110220202211020002211020211210122120110100012021211022022002020221001021011111200222101211002022010102112202...

output:

Bob
Alice 3
Alice 1
Bob
Alice 3
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 2
Bob
Alice 3
Bob
Alice 2
Alice 1
Alice 3
Alice 1
Alice 1
Bob
Alice 1
Alice 3
Alice 3
Alice 1
Alice 3
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Bob
Alice 3
Alice 1
Alice 3
Alice 1
Bob
Bob
Bob
...

result:

ok 20000 lines

Test #28:

score: 24
Accepted
time: 162ms
memory: 45812kb

input:

19000 20000
012212100211022001111000121220221220210020210221012010201222011020022201120000112110212120210201121001221202121122010122020220111201222000121202020212212121220210212111211110222110002220220012112012010010011002102011020121101202001121002102122021000122212001200012222010000200000202020122...

output:

Alice 1
Alice 2
Bob
Bob
Alice 1
Alice 1
Bob
Alice 2
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 3
Bob
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Alice 2
Alice 1
Alice 1
Alic...

result:

ok 20000 lines

Test #29:

score: 24
Accepted
time: 117ms
memory: 45008kb

input:

19000 20000
111020221220022022221212012102200011221010000021201210001022200012211002110110220212111120100212221011201020200200001020000212002122222010210101212120102010112012001212201201120211012220121200022210022111221201221021020222211210121211011011121201122210202022122000221011201111221021202211...

output:

Bob
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 2
Bob
Bob
Alice 2
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Bob
Alice 1
Bob
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 3
Alice 1
Alice 3
Alice 1
Bob
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 3
...

result:

ok 20000 lines

Test #30:

score: 24
Accepted
time: 105ms
memory: 45436kb

input:

19000 20000
212121011100020120011010212001210001121102220220010111022221000011101120222200012000100002000021022122001202222112202110012011000220010202121111211011000222211201000120220212200220212220210221212100022121122220112222212010111012111110121020112020120110222220002211010002101210011220000112...

output:

Alice 1
Alice 2
Bob
Bob
Alice 1
Bob
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 2
Alice 2
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Alice 2
Alice 1
Alice 2
Bob
Alic...

result:

ok 20000 lines

Test #31:

score: 24
Accepted
time: 181ms
memory: 45368kb

input:

20000 20000
122040040244103312230142440114443123421301104124042200130230204043422223112114232243020034024024322422423413343311333104311230002132040410041440432143434114042314012334111343243441433021424013322424314203133241022111220012211101323433302021212000422313330200303231312343303003231330233431...

output:

Alice 1
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Alice 4
Alice 3
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 3
Alice 1
Alice 1
Alice 1
Bob
Alice 2
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 1
Bob
Bob
Bob
Alice 1
Alice 1
...

result:

ok 20000 lines

Test #32:

score: 24
Accepted
time: 288ms
memory: 45492kb

input:

20000 20000
103042110023010301132120302120220234202044140131034402431230030404113121031342432313013003201002021000141003022210122430220102201334441420244312223410030323302442430142314140024440044022343111301230414123314102034201133030232441441041244114222010144341210411104020140342410024014004011003...

output:

Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 2
Alice 1
Alice 2
Alice 1
Bob
Bob
Alice 1
Bob
Bob
Bob
Bob
Bob
Alice 1
Bob
Alice 2
Alice 1
Alice 4
Bob
Bob
Bob
Alice 1
Bob
Alice 2
Bob
Bob
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 3
Alice 1
Alice 1
Alice 3
Alice 3
Bob
Bob
Alice 1
Bob
Bob
Alice 2
Bob
Alic...

result:

ok 20000 lines

Test #33:

score: 24
Accepted
time: 378ms
memory: 52984kb

input:

20000 20000
032042014243202311132010423311310141420000204331010143142242434420121341344434204233404304043402423034014001042410343304302300030130131321231333401010423302331443014222112403441202241010421332323444332113344104224430111223324211204323210302023234143232434141243410331013212322434433133132...

output:

Alice 2
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 1
Bob
Bob
Alice 2
Bob
Alice 2
Alice 1
Bob
Bob
Bob
Alice 2
Alice 1
Bob
Bob
Bob
Alice 2
Bob
Bob
Bob
Bob
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Bob
Alice 1
Alic...

result:

ok 20000 lines

Test #34:

score: 24
Accepted
time: 22ms
memory: 45372kb

input:

20000 20000
342412301031234340421203301204300224204141110202003030421243112043234334422333444222111222412043202100212021334240313420000224222401220431001124433402313000012110410143104412312222224114030220314010130111040403241423013132034243131112223340101102131023210420420033432222133214403304121403...

output:

Alice 1
Bob
Bob
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Bob
Alice 1
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 1
Alice 3
Bob
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Bob
Bob
Bob
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Bob
Alice 3
Alice 3
Bob
Alice 1
...

result:

ok 20000 lines

Test #35:

score: 24
Accepted
time: 33ms
memory: 47068kb

input:

20000 20000
301222212241221113302144432111042342424100042212330024130323242433301240410303221033130110041012302144210204213233203214023331423222230232414020024111300033201223121021433040120212000310030224002011414032143022020311100404104022232410124040341420134033120322042233422214110403320024032344...

output:

Alice 1
Bob
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 3
Bob
Bob
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Bob
Bob
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Bob
Bob
...

result:

ok 20000 lines

Test #36:

score: 24
Accepted
time: 288ms
memory: 47932kb

input:

20000 20000
340303430120122112023131443104134024123341230440041044132120330342023424132243001420203410302114433240321200010441010143212404204330241240141200313104414140320421421221132140044043222130302202312010432140441421032032143020412034201123244122131331204120124320040024023224412302203212343344...

output:

Bob
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
Alice 2
Alice 1
Alice 1
Alice 2
Alice 2
Alice 1
Bob
Alice 1
Bob
Bob
Alice 2
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Alice 1
Bob
Bob
Alice 2
Alice 2
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 2
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
...

result:

ok 20000 lines

Test #37:

score: 24
Accepted
time: 246ms
memory: 50276kb

input:

20000 20000
231311434332214340400012211401443124334122440434340441023401241300121310113013124412304022232301130033213341120121021144423431040133142203204031131040213022132433403203133241331443321302223231031410143041214243122430123444022340043143322003033421200034144033302434322443244341432011023001...

output:

Alice 3
Alice 2
Alice 3
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Alice 3
Bob
Alice 1
Bob
Alice 1
Alice 3
Bob
Bob
Bob
Alice 1
Alice 3
Alice 2
Bob
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Bob
Alice 3
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 1
...

result:

ok 20000 lines

Test #38:

score: 24
Accepted
time: 212ms
memory: 46444kb

input:

20000 20000
033112233132001144414022313432103213143440024123402410032310032031302040430441433431000341213024422212324343124334443031432200431134234224220301223412443034243044134010234313030112330431324412213210314241023000130432014244412133422431243041242030112240114114320422324022431333324014041203...

output:

Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 2
Alice 1
Bob
Bob
Alice 2
Alice 1
Bob
Bob
Bob
Alice 2
Alice 1
Alice 2
Alice 2
Bob
Alice 1
Bob
Alice 3
Alice 1
Alice 3
Bob
Bob
Alice 1
Bob
Alice 2
Alice 3
Bob
Bob
Bob
Alice 3
Bob
Alice 2
Bob
Alice 2
Alice 1
Bob
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Alic...

result:

ok 20000 lines

Subtask #6:

score: 25
Accepted

Dependency #1:

100%
Accepted

Dependency #4:

100%
Accepted

Dependency #5:

100%
Accepted

Test #39:

score: 25
Accepted
time: 666ms
memory: 77452kb

input:

49000 100000
44344304234013323112013232104112310431100104433113242444303323133000044231121001323211432322402240141133210311003021330042412111202313312000021300341302402104204313211323442413333420321103213213141431203143112404310033010312024020121414144022221300431244022312144103333211041140320011313...

output:

Alice 3
Alice 2
Alice 3
Alice 1
Alice 3
Alice 1
Alice 2
Alice 4
Alice 1
Bob
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 3
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Alice 2
Alice 1
Alice 2
Alice 2
Bob
Alice 3
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Alice 2
Alice 1
Alice 2
Alice 4
Bob
...

result:

ok 100000 lines

Test #40:

score: 25
Accepted
time: 948ms
memory: 77600kb

input:

49000 100000
12334203112402241402042211341441120304324122334313041231144400102103121223344042421441044213024031423331240001104142021241003440012430033202344131033224024431341222312420320303443122044100130302033120024433021121423200314413224301000424034044421113341143030440204232032211432043201040231...

output:

Alice 2
Bob
Bob
Alice 3
Bob
Bob
Bob
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 1
Bob
Bob
Bob
Bob
Alice 1
Alice 1
Alice 2
Bob
Bob
Bob
Alice 1
Alice 1
Alice 3
Alice 3
Alice 1
Alice 1
Alice 1
Alice 2
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Alice 2
Bob
Alice 1
Bob
Bob
...

result:

ok 100000 lines

Test #41:

score: 25
Accepted
time: 1146ms
memory: 92876kb

input:

49000 100000
22040403244230023240140222430100003030013231413430444033013242112440233434221320444142423021111434404014223421232102413241001424112410130004043244241311421331414031304020121343010331040103041021230323244033441111003344420221214220022303222222144224120232320134410043342131014421120011204...

output:

Bob
Alice 1
Alice 1
Alice 1
Alice 2
Bob
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Alice 3
Bob
Bob
Alice 2
Alice 2
Bob
Bob
Bob
Alice 1
Bob
Alice 2
Bob
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Alice 1
Bob
Alice 3
Alice 1
Bob
Bob
Alice 1
Bob
Bob
Bob
Alice 2
Alice 3
Bob
Bob
Alice 1
Bob
...

result:

ok 100000 lines

Test #42:

score: 25
Accepted
time: 105ms
memory: 75592kb

input:

49000 100000
00431430440123000030414142311202030243204333423300211310223400310231341223024343203012202444033321421220142203312314231034130014310213002433212231430011440314030300131020104130000001020024413343000443221311412101142223324334341030013101004123234313402404022031140302310423220424130224422...

output:

Alice 3
Alice 1
Alice 3
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Alice 1
Bob
Bob
Bob
Alice 3
Bob
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alice 1
Bob
Bob
Bob
Bob
Bob
Alice 3
Bob
Alice 3
Alice 3
Bob
Alice 3
Alice 1
Bob
Bob
Bob
Bob
Alice 3
Alice 3
Alice 1
Bob
Bob
Alice 3
Bob
Bob
Alice 1
Alic...

result:

ok 100000 lines

Test #43:

score: 25
Accepted
time: 131ms
memory: 75704kb

input:

49000 100000
30234331131414312340303403024400113030243324300440112433344222324131120113312201223144414101040232223342014434404341430001022321331344111234241211343222042410312443112320120300212300214303004342410240013120211140144130321300410234224430341324244201012101403012043143101430024433003130312...

output:

Alice 1
Alice 3
Alice 3
Bob
Alice 1
Alice 2
Bob
Bob
Alice 1
Alice 3
Bob
Alice 3
Alice 1
Alice 1
Alice 3
Bob
Alice 3
Alice 3
Alice 1
Alice 1
Bob
Alice 3
Alice 3
Bob
Bob
Alice 1
Bob
Bob
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 3
Alice 1
Alice 3
...

result:

ok 100000 lines

Test #44:

score: 25
Accepted
time: 946ms
memory: 75464kb

input:

49000 100000
12300131241002334223001002133241233020302010032334430140134220130143430133033142141100043313023114021200023110031200333140434331422104104022110404340120110302141033222130414344013400232034433344432130002124020113244100410211023403234204121132020333213034333222102000342321342442401304324...

output:

Bob
Alice 1
Alice 2
Bob
Alice 1
Alice 2
Alice 1
Alice 1
Alice 2
Alice 1
Alice 3
Alice 1
Bob
Alice 2
Alice 2
Bob
Alice 3
Bob
Bob
Bob
Alice 1
Alice 1
Alice 2
Alice 1
Bob
Alice 2
Bob
Alice 2
Alice 3
Bob
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 3
Alice 1
Bob
Bob
Alice 1
Bob
Bob
Alice 1
Alice 1
Bob
Alic...

result:

ok 100000 lines

Test #45:

score: 25
Accepted
time: 859ms
memory: 80396kb

input:

49000 100000
32423201134220013011443440342243341340012024103432302342200443444440440133310024302423140100202401404103120132033423413242131443111230031101133424210243324414241303133120121233200324413440412024032112332413332002243301214444201100313140302344413234213241422214021202030212313341443113020...

output:

Alice 1
Alice 1
Bob
Bob
Alice 3
Alice 3
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 1
Bob
Bob
Alice 1
Bob
Alice 1
Alice 4
Alice 1
Bob
Bob
Bob
Alice 1
Bob
Alice 1
Bob
Alice 1
Bob
Bob
Bob
Alice 3
Alice 1
Bob
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Bob
Alice 1
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 3
Alic...

result:

ok 100000 lines

Test #46:

score: 25
Accepted
time: 708ms
memory: 77536kb

input:

49000 100000
03430322244101002314013110113433304021344224223040003012032334234413200121142304224130342301140032431141230124242334143410213030342140120303302204214031202024304014021311120202344441111112214144321212244223303000233320244133021331104120313120031023430210103413422203011432331424421043111...

output:

Alice 1
Alice 1
Alice 2
Alice 2
Alice 1
Alice 1
Alice 2
Bob
Bob
Alice 2
Alice 2
Alice 3
Bob
Bob
Alice 1
Alice 2
Bob
Bob
Alice 1
Bob
Bob
Bob
Bob
Alice 1
Alice 2
Bob
Bob
Bob
Bob
Bob
Bob
Alice 2
Alice 1
Alice 1
Bob
Alice 1
Alice 2
Alice 2
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Bob
Bob
Bob
Alice 2
Alic...

result:

ok 100000 lines

Test #47:

score: 25
Accepted
time: 1391ms
memory: 77756kb

input:

50000 100000
41469402892856288847143622096526154430711506024592621224250665670589886799055712412767877447024342805760868278585714139039219581918284580209996705719191117734423250225312365389063887110584070828466227656537031103910550357032933688391981836157181600199922714786625099595689132004921267731...

output:

Alice 3
Alice 1
Alice 2
Alice 1
Alice 1
Alice 2
Alice 2
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Bob
Alice 3
Alice 4
Alice 1
Alice 3
Alice 1
Alice 3
Alice 1
Alice 1
Bob
Alice 3
Bob
Bob
Alice 1
Alice 1
Bob
Alice 3
Alice 1
Alice 4
Alice 2
Alice 3
Alice 3
Alice 1
Alice 1
Alice 1
Alic...

result:

ok 100000 lines

Test #48:

score: 25
Accepted
time: 2506ms
memory: 75716kb

input:

50000 100000
11865236105525638025450753567662408874839720373357296130202499648922182856711967053996235798835957166020568903128611644629449362918814286646529702262545419076422470672309642712190488512718240963801282717745145940463034015168816814946466408374946805073868041811076784260404862312201570474...

output:

Alice 1
Alice 1
Alice 1
Alice 3
Alice 1
Alice 2
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 2
Alice 3
Alice 1
Alice 1
Alice 4
Alice 1
Bob
Alice 1
Bob
Alice 1
Alice 2
Alice 1
Alice 3
Alice 2
Bob
Alice 1
Alice 1
Bob
Alice 2
...

result:

ok 100000 lines

Test #49:

score: 25
Accepted
time: 3200ms
memory: 93380kb

input:

50000 100000
95791805558433242901730123925290382126441257842394948855116220826708749127436521411648043400328895423785265719141375893099305149648223634093981998174444749252404042459200916217116896792954792027925096924195484337827186259268671783621340464833865710277793814768563333947092183303340134957...

output:

Alice 1
Bob
Bob
Bob
Alice 2
Bob
Alice 1
Bob
Alice 1
Alice 2
Bob
Alice 1
Alice 2
Alice 1
Alice 3
Alice 1
Bob
Alice 1
Alice 3
Alice 2
Alice 1
Bob
Alice 1
Bob
Alice 2
Alice 1
Bob
Alice 3
Bob
Bob
Bob
Bob
Alice 2
Alice 1
Alice 2
Bob
Bob
Alice 2
Alice 1
Alice 1
Alice 4
Alice 1
Alice 2
Alice 1
Bob
Bob
Alic...

result:

ok 100000 lines

Test #50:

score: 25
Accepted
time: 104ms
memory: 75492kb

input:

50000 100000
70268630453970609470081174370346734791021955916959002631950179222499310204430721681437673209780591437436627361459598465195231975548186808693759894224415731951058192158278443737072147033171612250085310825742591653595219677566957959807552678754589099917647798406892867612523421393692712048...

output:

Alice 3
Alice 3
Alice 3
Alice 1
Alice 1
Alice 3
Alice 1
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Alice 1
Alice 3
Alice 1
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Alice 1
Alice 3
Alice 3
Alice 3
Alice 3
Alic...

result:

ok 100000 lines

Test #51:

score: 25
Accepted
time: 133ms
memory: 75708kb

input:

50000 100000
87155569333392685251947463630455773945301750656190842742541929645395304199289870767768109538853071791546490916631060850465302220101065354985752737472890367830675943654261039579726436880901178543855772927164050009575855044882308998785248941893362797284655251887963668453327461073373282848...

output:

Alice 1
Bob
Bob
Bob
Bob
Alice 3
Alice 1
Bob
Bob
Alice 3
Bob
Bob
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Bob
Alice 1
Alice 3
Bob
Bob
Alice 3
Alice 3
Bob
Alice 1
Alice 1
Alice 3
Alice 1
Alice 3
Bob
Alice 3
Alice 1
Alice 1
Alice 1
Alice 1
Alice 3
Alice 3
Alice 3
Bob
Alice 3
Bob
Alice 3
Bob
Bob
Bob
Alice 3
...

result:

ok 100000 lines

Test #52:

score: 25
Accepted
time: 2189ms
memory: 75548kb

input:

50000 100000
44419020988909849128380660219815265098033185605780321578129831190849711514462258377178525731026888859989582246441712466828929576002835376645951508059710740353811314953067769912398478352454113400287419557733259646551170816588197320966228388102712967302793851052620500568593214040910118507...

output:

Alice 2
Bob
Bob
Alice 4
Alice 2
Bob
Alice 1
Bob
Alice 1
Alice 2
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 1
Alice 3
Alice 3
Alice 2
Alice 2
Bob
Alice 1
Bob
Alice 3
Alice 2
Bob
Alice 3
Bob
Alice 2
Alice 2
Alice 2
Bob
Alice 2
Alice 3
Alice 1
Alice 2
Alice 1
Alice 3
Alice 3
Bob
Alic...

result:

ok 100000 lines

Test #53:

score: 25
Accepted
time: 1472ms
memory: 85268kb

input:

50000 100000
99015175527161039711968308158970401111186859450515996867236884760481432211517725200133986977826853926132487154132411695127231398362005404031697446152212085146898544662653330395884300461721426324950097687328156545596739137847482582859122599355791463215213743774816441008120370170744664085...

output:

Bob
Bob
Bob
Alice 1
Bob
Alice 1
Alice 1
Alice 3
Alice 1
Bob
Bob
Alice 3
Bob
Alice 1
Alice 1
Alice 1
Bob
Bob
Alice 1
Alice 3
Alice 2
Alice 3
Alice 1
Alice 2
Alice 1
Bob
Alice 3
Alice 1
Bob
Alice 1
Alice 3
Alice 1
Alice 1
Alice 1
Alice 1
Alice 5
Alice 1
Alice 3
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alic...

result:

ok 100000 lines

Test #54:

score: 25
Accepted
time: 2305ms
memory: 77740kb

input:

50000 100000
05034210319141086175468297740092605715584081891367533616727739984122457828829167650055213173196536176507535633569140088468486836787253623935206504598955495351850464934785686726789538927885557993298322739505161908747127297945313771753354416257942712612472906096556599052477671977401135599...

output:

Alice 1
Bob
Alice 1
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 2
Bob
Alice 2
Alice 2
Alice 1
Alice 2
Alice 1
Alice 1
Alice 1
Alice 2
Bob
Bob
Alice 3
Bob
Bob
Alice 1
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 1
Alice 1
Alice 1
Alice 2
Bob
Alice 1
Alice 2
Bob
Alice 2
Alice 3
Bob
Bob
Alice 2
Alice 2
Bob
...

result:

ok 100000 lines