QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#579138#3318. Four-ColoringJWRuixiAC ✓6ms4152kbC++202.4kb2024-09-21 09:35:312024-09-21 09:35:32

Judging History

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

  • [2024-09-21 09:35:32]
  • 评测
  • 测评结果:AC
  • 用时:6ms
  • 内存:4152kb
  • [2024-09-21 09:35:31]
  • 提交

answer

#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 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

constexpr int N = 1e4 + 9;
int n, m, K, c[N], ord[N];
vi g[N];

struct nd {
  int x, y;

  bool operator < (const nd &rhs) const {
    return x ^ rhs.x ? x < rhs.x : y < rhs.y;
  }
} a[N];

IL int gts (int x) {
  int s = ~c[x] ? 1 << c[x] : 0;
  for (int y : g[x]) {
    if (~c[y]) {
      s |= 1 << c[y];
    }
  }
  return s;
}

bool vis[N];

void dfs (int u, int s) {
  vis[u] = true;
  for (int v : g[u]) {
    if (~c[v] && !vis[v] && (s >> c[v] & 1)) {
      dfs(v, s);
    }
  }
}

void clr (int u) {
  vis[u] = false;
  for (int v : g[u]) {
    if (vis[v]) {
      clr(v);
    }
  }
}

void chg (int u, int s) {
  vis[u] = false;
  c[u] ^= s;
  for (int v : g[u]) {
    if (vis[v]) {
      chg(v, s);
    }
  }
}

IL int slp (int x, int y) {
  if (y == 0) {
    return INT_MIN;
  }
  return x / y;
}

int main () {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  L (i, 1, n) {
    cin >> a[i].x >> a[i].y;
  }
  L (i, 1, m) {
    int u, v;
    cin >> u >> v;
    g[u].eb(v);
    g[v].eb(u);
  }
  L (i, 1, n) {
    c[i] = -1, ord[i] = i;
  }
  sort(ord + 1, ord + n + 1, [] (int x, int y) {
    return a[x] < a[y];
  });
  L (i, 1, n) {
    int u = ord[i];
    int s = gts(u);
    if (s < 15) {
      c[u] = __builtin_ctz(~s);
      continue;
    }
    vi e;
    for (int v : g[u]) {
      if (~c[v]) {
        e.eb(v);
      }
    }
    sort(e.begin(), e.end(), [&] (int i, int j) {
      return slp(a[u].x - a[i].x, a[u].y - a[i].y) < slp(a[u].x - a[j].x, a[u].y - a[j].y);
    });
    dfs(e[0], (1 << c[e[0]]) | (1 << c[e[2]]));
    if (vis[e[2]]) {
      clr(e[0]);
      dfs(e[1], (1 << c[e[1]]) | (1 << c[e[3]]));
      assert(!vis[e[3]]);
      chg(e[1], c[e[1]] ^ c[e[3]]);
    } else {
      chg(e[0], c[e[0]] ^ c[e[2]]);
    }
    s = gts(u);
    if (s < 15) {
      c[u] = __builtin_ctz(~s);
    }
  }
  L (i, 1, n) {
    cout << c[i] + 1 << '\n';
  }
}
// I love WHQ!

詳細信息

Test #1:

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

input:

4009 9537
0 20
20 0
20 20
0 40
10 30
20 40
10 27
10 26
12 27
11 26
9 26
9 24
10 25
10 24
11 24
12 24
10 23
12 23
12 25
12 26
13 24
13 26
10 50
40 40
20 60
30 30
30 50
40 60
30 47
30 46
32 47
31 46
29 46
29 44
30 45
30 44
31 44
32 44
30 43
32 43
32 45
32 46
33 44
33 46
30 70
60 60
40 80
50 50
50 70
6...

output:

1
2
3
2
4
1
3
1
4
2
2
1
4
3
1
2
2
3
3
1
1
2
4
3
2
2
4
1
3
1
4
2
2
1
4
3
1
2
2
3
3
1
1
2
4
3
2
2
4
1
3
1
4
2
2
1
4
3
1
2
2
3
3
1
1
2
4
3
2
2
4
1
3
1
4
2
2
1
4
3
1
2
2
3
3
1
1
2
4
3
2
2
4
1
3
1
4
2
2
1
4
3
1
2
2
3
3
1
1
2
4
3
2
2
4
1
3
1
4
2
2
1
4
3
1
2
2
3
3
1
1
2
4
3
2
2
4
1
3
1
4
2
2
1
4
3
1
2
2
3
...

result:

ok ...

Test #2:

score: 0
Accepted
time: 0ms
memory: 4152kb

input:

3977 9260
0 20
20 0
20 20
0 40
10 30
20 40
10 27
10 33
7 30
13 30
13 32
14 30
14 31
14 29
16 29
15 30
16 30
16 31
16 32
17 30
17 32
15 32
14 32
14 33
16 33
7 32
6 30
6 31
6 29
4 29
5 30
4 30
4 31
4 32
3 30
3 32
5 32
6 32
4 33
6 33
10 34
12 33
11 34
9 34
9 36
10 35
10 36
11 36
12 36
10 37
12 37
12 35...

output:

3
2
1
2
4
3
3
2
1
1
2
3
4
2
3
1
2
3
1
1
2
2
1
3
4
2
2
3
3
2
1
3
4
1
1
2
2
1
3
4
3
3
1
1
2
4
1
2
1
3
4
3
2
1
2
1
4
2
2
1
4
3
1
2
2
3
3
1
1
2
4
1
2
2
4
3
3
2
1
1
2
3
4
2
3
1
2
3
1
1
2
2
1
3
4
2
2
3
3
2
1
3
4
1
1
2
2
1
3
4
3
3
1
1
2
4
1
2
1
3
4
3
2
1
2
1
4
2
2
1
4
3
1
2
2
3
3
1
1
2
4
1
2
2
4
3
3
2
1
1
...

result:

ok ...

Test #3:

score: 0
Accepted
time: 2ms
memory: 3928kb

input:

3365 9976
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
1 4
3 2
3 3
2 4
3 4
2 5
4 3
4 4
3 5
4 5
3 6
5 4
5 5
4 6
5 6
4 7
6 5
6 6
5 7
6 7
5 8
7 6
7 7
6 8
7 8
6 9
8 7
8 8
7 9
8 9
7 10
9 8
9 9
8 10
9 10
8 11
10 9
10 10
9 11
10 11
9 12
11 10
11 11
10 12
11 12
10 13
12 11
12 12
11 13
12 13
11 14
13 12
13 13
12 14
1...

output:

2
1
3
1
4
2
1
2
3
4
4
1
1
4
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
...

result:

ok ...

Test #4:

score: 0
Accepted
time: 5ms
memory: 3876kb

input:

3340 9876
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
1 4
3 2
4 3
2 4
3 4
2 5
1 5
1 6
3 5
2 6
3 6
2 7
4 5
4 6
3 7
4 7
3 8
5 6
5 7
4 8
5 8
4 9
6 7
6 8
5 9
6 9
5 10
7 8
7 9
6 10
7 10
6 11
8 9
8 10
7 11
8 11
9 10
9 11
8 12
9 12
8 13
10 12
9 13
10 13
9 14
11 12
11 13
10 14
11 14
10 15
12 13
12 14
11 15
12 15
11...

output:

2
1
3
1
4
2
1
2
3
4
4
2
1
3
2
1
3
1
1
3
4
2
1
2
4
3
3
1
1
3
2
2
1
4
2
3
3
4
1
3
2
1
4
4
1
3
2
2
4
1
3
2
1
3
4
2
2
4
1
1
2
2
1
3
4
2
4
3
2
1
4
4
1
3
1
2
4
2
1
3
1
2
2
1
4
4
3
3
4
2
1
2
3
1
4
3
3
2
1
4
4
2
2
4
3
1
2
2
3
1
1
2
4
3
3
1
2
3
4
4
2
2
1
3
3
2
2
3
4
1
2
2
4
3
3
2
1
2
4
3
4
2
1
1
3
3
4
2
1
1
...

result:

ok ...

Test #5:

score: 0
Accepted
time: 5ms
memory: 3956kb

input:

3325 9815
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
1 4
3 3
2 4
3 4
2 5
4 4
3 5
4 5
3 6
5 4
5 5
4 6
5 6
4 7
3 7
3 8
5 7
4 8
5 8
4 9
6 7
6 8
5 9
6 9
5 10
4 10
4 11
6 10
5 11
6 11
5 12
7 10
7 11
6 12
7 12
6 13
5 13
5 14
7 13
6 14
7 14
6 15
8 13
8 14
7 15
8 15
9 15
8 16
7 16
7 17
9 16
8 17
7 18
9 17
8 18
9 1...

output:

2
3
1
3
4
2
3
2
1
4
4
3
2
1
3
3
1
4
4
3
2
4
3
2
4
2
1
4
2
3
1
3
2
4
1
2
3
1
2
3
4
3
1
4
2
1
3
1
4
3
1
2
1
4
2
4
1
3
4
3
2
3
1
1
3
2
2
1
1
2
3
3
4
1
3
4
1
2
2
3
1
4
2
2
1
3
3
2
2
4
1
1
2
2
1
3
4
3
2
1
1
3
2
4
2
1
1
3
2
4
4
3
3
1
2
3
4
2
1
1
3
3
4
2
2
3
1
2
3
1
3
4
1
2
2
3
3
2
1
4
1
3
2
4
2
1
3
2
1
4
...

result:

ok ...

Test #6:

score: 0
Accepted
time: 5ms
memory: 3964kb

input:

3300 9721
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
3 2
3 3
2 4
3 4
2 5
4 3
4 4
3 5
4 5
3 6
5 4
5 5
4 6
5 6
4 7
6 5
6 6
5 7
6 7
5 8
7 6
7 7
6 8
7 8
6 9
8 7
8 8
7 9
8 9
7 10
9 8
9 9
8 10
9 10
8 11
10 9
10 10
9 11
10 11
9 12
11 10
11 11
10 12
11 12
10 13
9 13
11 13
10 14
11 14
10 15
12 13
12 14
11 15
12 15
...

output:

3
1
2
2
4
3
2
1
3
1
2
2
4
1
3
2
2
1
3
4
2
2
3
1
1
2
2
4
3
1
2
1
3
2
4
1
1
2
3
3
1
1
4
2
2
3
3
2
1
1
4
3
1
2
4
3
1
4
3
2
3
2
4
1
2
3
2
2
3
1
4
4
1
3
2
2
4
1
1
3
2
1
3
2
3
4
2
1
3
4
2
3
3
4
1
3
2
3
4
2
1
4
1
4
3
2
4
1
1
4
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
4
1
1
2
3
3
1
1
3
2
2
1
1
2
3
4
4
3
...

result:

ok ...

Test #7:

score: 0
Accepted
time: 5ms
memory: 3936kb

input:

3277 9620
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
3 2
3 3
2 4
3 4
2 5
4 3
4 4
3 5
4 5
3 6
5 4
5 5
4 6
5 6
4 7
6 5
6 6
5 7
6 7
5 8
7 6
7 7
6 8
7 8
6 9
8 7
8 8
7 9
8 9
7 10
9 8
8 10
9 10
8 11
10 9
10 10
9 11
10 11
9 12
11 10
11 11
10 12
11 12
10 13
12 11
12 12
11 13
12 13
11 14
13 12
13 13
12 14
13 14
12 ...

output:

3
2
1
2
4
3
2
3
1
4
2
2
4
3
3
2
2
3
1
1
2
2
4
3
3
2
2
3
1
4
2
2
1
3
3
2
2
3
1
1
2
1
3
3
2
2
3
1
1
2
2
1
4
4
2
2
3
1
1
2
2
1
3
3
2
2
3
1
1
4
2
1
3
2
1
2
2
1
3
2
4
3
1
1
2
4
1
3
3
4
2
3
1
2
4
3
2
3
4
2
1
3
3
2
2
3
4
4
1
1
2
3
3
4
4
3
1
1
4
1
3
4
3
4
2
1
1
3
4
2
2
1
1
2
4
3
4
3
1
2
2
4
2
3
1
3
4
2
3
1
...

result:

ok ...

Test #8:

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

input:

3243 9479
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
1 4
3 2
3 3
2 4
3 4
2 5
4 3
4 4
3 5
4 5
3 6
5 4
5 5
4 6
5 6
6 6
5 7
6 7
5 8
7 6
7 7
6 8
7 8
6 9
5 10
7 9
6 10
7 10
6 11
8 9
8 10
7 11
8 11
7 12
9 10
9 11
8 12
9 12
8 13
10 11
10 12
9 13
10 13
9 14
11 12
11 13
10 14
11 14
10 15
12 13
12 14
11 15
12 15
11 ...

output:

3
2
1
1
4
3
1
3
2
4
4
1
3
4
1
3
2
2
1
3
4
2
2
4
3
3
2
4
4
3
1
4
2
3
1
1
3
4
2
1
1
2
3
4
1
1
3
2
2
1
4
2
3
4
1
1
4
2
3
1
3
2
4
4
3
3
1
2
2
3
3
2
4
1
3
3
1
2
2
4
4
2
3
1
4
4
1
3
3
2
2
3
4
4
2
1
2
3
3
2
4
4
1
1
3
4
2
1
4
2
1
3
3
2
1
4
3
4
1
3
2
4
4
3
2
1
2
1
4
3
3
1
1
2
4
3
4
1
3
2
4
4
3
2
1
4
4
2
1
3
...

result:

ok ...

Test #9:

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

input:

3232 9454
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
1 4
3 2
3 3
2 4
3 4
2 5
4 3
4 4
3 5
4 5
3 6
5 4
5 5
4 6
5 6
4 7
6 5
6 6
5 7
6 7
5 8
7 6
6 8
7 8
6 9
8 7
8 8
7 9
8 9
7 10
8 10
9 9
9 10
8 11
9 11
10 11
9 12
8 12
8 13
10 12
9 13
10 13
9 14
11 12
11 13
10 14
11 14
10 15
12 13
12 14
12 15
11 16
13 14
13 15
...

output:

2
1
3
1
4
2
1
2
3
4
4
2
2
1
3
3
4
4
2
3
1
4
4
3
1
2
4
2
1
3
3
2
3
1
2
1
2
3
3
1
2
4
4
2
1
3
1
4
2
2
1
3
3
2
2
3
1
1
2
1
3
3
2
2
3
4
1
1
4
3
3
2
2
1
3
3
2
4
4
3
3
4
1
2
3
2
1
4
4
3
3
2
1
1
3
3
1
2
4
3
3
2
1
1
3
3
1
2
4
3
2
4
1
3
3
1
2
2
3
3
2
1
3
1
2
2
3
4
4
1
3
3
1
2
2
4
1
3
1
2
2
4
1
3
2
2
3
4
1
2
...

result:

ok ...

Test #10:

score: 0
Accepted
time: 2ms
memory: 3944kb

input:

3223 9416
0 1
1 0
1 1
0 3
1 2
2 1
1 3
2 3
1 4
3 2
3 3
3 4
2 5
4 3
5 4
3 5
4 5
3 6
4 6
5 6
4 7
3 7
3 8
4 8
5 8
4 9
6 7
6 8
5 9
6 9
7 8
7 9
6 10
7 10
6 11
8 9
8 10
7 11
8 11
7 12
9 10
9 11
8 12
9 12
8 13
10 11
10 12
9 13
10 13
9 14
11 12
11 13
10 14
11 14
10 15
12 13
12 14
11 15
12 15
13 15
12 16
13 1...

output:

3
1
2
2
4
3
3
1
4
2
4
2
3
3
1
1
3
2
4
1
3
1
2
4
2
3
3
1
1
3
4
2
2
1
3
3
2
2
3
1
1
2
2
1
4
3
2
2
4
3
1
2
2
3
1
4
2
2
4
3
1
2
4
4
1
1
4
2
2
1
3
4
1
2
3
3
4
1
1
2
3
4
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
2
3
3
1
1
3
2
4
1
1
2
4
3
1
1
3
2
1
4
2
3
3
4
4
3
1
1
4
2
1
4
3
1
2
2
1
4
3
4
3
2
4
1
3
3
...

result:

ok ...

Test #11:

score: 0
Accepted
time: 4ms
memory: 3920kb

input:

3186 9270
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 4
2 3
3 2
3 3
2 4
3 4
2 5
4 3
4 4
3 5
4 5
5 4
5 5
4 6
5 6
4 7
6 5
6 6
5 7
6 7
5 8
7 6
7 7
6 8
7 8
6 9
8 8
7 9
8 9
7 10
9 9
9 10
8 11
10 9
10 10
9 11
10 11
9 12
11 10
11 11
10 12
11 12
10 13
12 11
12 10
13 10
13 11
13 12
12 13
14 11
14 12
13 13
14 13
13 14
15 1...

output:

3
2
1
2
4
3
2
1
3
1
2
2
1
3
3
2
2
3
1
2
4
1
3
3
2
2
3
1
1
2
2
1
3
4
2
3
1
2
1
4
3
2
2
3
1
1
2
2
1
4
4
3
2
1
2
1
4
3
3
4
2
1
2
3
1
4
4
3
2
4
1
1
2
3
4
4
1
2
4
3
3
1
1
3
4
4
1
2
4
1
2
4
2
4
3
2
2
3
4
4
1
2
4
3
1
2
2
4
1
3
2
2
3
4
4
2
2
4
3
3
1
2
3
4
2
1
1
2
4
1
4
2
2
1
4
2
4
4
2
3
3
1
4
3
2
2
4
1
2
4
...

result:

ok ...

Test #12:

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

input:

3183 9253
0 1
1 0
1 1
0 3
1 2
2 1
2 3
1 4
3 2
2 4
3 4
2 5
4 3
4 4
3 5
4 5
3 6
5 4
5 5
5 6
4 7
6 5
6 6
5 7
6 7
7 6
7 7
6 8
7 8
6 9
8 7
8 8
7 9
8 9
7 10
9 8
9 9
8 10
9 10
8 11
10 9
10 10
9 11
10 11
9 12
11 11
10 12
11 12
10 13
12 11
12 12
11 13
12 13
11 14
13 12
13 13
12 14
13 14
12 15
14 13
14 14
13 ...

output:

3
4
1
4
2
3
3
1
1
4
2
3
3
1
4
3
1
2
4
2
4
3
1
1
3
4
2
4
1
3
3
2
2
3
4
1
2
1
4
3
3
2
2
3
4
1
2
4
3
3
1
2
3
1
2
4
4
1
2
3
2
4
3
4
2
1
4
2
1
3
2
4
1
3
1
2
3
4
4
2
2
4
3
1
2
2
1
4
3
2
3
1
4
2
1
2
3
2
1
1
3
3
1
2
4
2
3
4
1
1
3
3
1
2
2
3
2
1
4
3
1
2
3
2
4
4
1
3
4
1
2
1
3
2
4
1
1
4
2
2
1
1
2
4
4
1
1
4
2
3
...

result:

ok ...

Test #13:

score: 0
Accepted
time: 2ms
memory: 3924kb

input:

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

output:

1
2
3
2
4
1
2
1
3
4
4
1
2
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
1
3
4
1
3
2
...

result:

ok ...

Test #14:

score: 0
Accepted
time: 2ms
memory: 4088kb

input:

3273 9660
0 2
2 0
2 2
0 4
1 3
2 4
1 5
4 4
2 6
3 3
3 5
4 6
3 7
6 6
4 8
5 5
5 7
6 8
5 9
8 8
6 10
7 7
7 9
8 10
7 11
10 10
8 12
9 9
9 11
10 12
9 13
12 12
10 14
11 11
11 13
12 14
11 15
14 14
12 16
13 13
13 15
14 16
13 17
16 16
14 18
15 15
15 17
16 18
15 19
18 18
16 20
17 17
17 19
18 20
17 21
20 20
18 22
...

output:

4
2
3
2
1
4
3
1
2
2
3
4
3
3
2
2
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
3
3
2
1
1
4
1
3
2
1
1
4
1
3
2
1
1
4
1
3
2
1
1
4
1
3
2
1
1
4
1
3
2
1
1
4
...

result:

ok ...

Test #15:

score: 0
Accepted
time: 5ms
memory: 3932kb

input:

3336 9816
0 1
1 0
1 1
0 3
1 2
2 2
1 3
2 3
1 4
2 4
1 5
3 4
2 5
3 5
2 6
3 6
2 7
4 5
4 6
3 7
4 7
5 6
5 7
4 8
3 8
5 8
4 9
3 9
5 9
4 10
3 10
5 10
4 11
5 11
6 11
5 12
6 12
7 11
7 12
6 13
5 13
5 14
7 13
6 14
7 14
8 13
8 14
7 15
8 15
9 15
8 16
7 16
9 16
8 17
7 17
9 17
8 18
7 18
9 18
8 19
7 19
7 20
9 19
8 20...

output:

2
1
3
1
4
1
3
2
2
4
1
3
2
4
3
1
2
2
4
4
3
2
4
2
3
3
4
1
2
3
2
4
4
2
1
1
4
2
3
2
4
1
4
3
1
2
4
2
3
2
1
4
3
2
3
4
1
4
3
2
1
3
4
1
2
4
2
3
1
1
2
4
1
1
3
4
2
3
1
3
3
4
2
3
1
4
4
3
2
4
3
1
1
3
2
2
4
1
3
3
2
2
3
1
2
1
4
4
3
2
3
4
1
2
2
4
3
2
1
3
4
4
1
2
3
2
4
3
1
1
2
3
4
1
3
2
1
4
3
2
4
2
2
1
4
3
4
3
2
1
...

result:

ok ...

Test #16:

score: 0
Accepted
time: 5ms
memory: 3972kb

input:

3308 9688
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
1 4
0 5
2 4
1 5
2 5
1 6
3 5
2 6
3 6
4 5
4 6
3 7
4 7
3 8
5 7
4 8
5 8
6 7
6 8
5 9
4 9
6 9
5 10
6 10
5 11
7 10
6 11
7 11
6 12
8 11
7 12
8 12
7 13
9 12
8 13
9 13
8 14
9 14
10 14
9 15
8 15
8 16
10 15
9 16
10 16
9 17
11 15
11 16
10 17
11 17
10 18
9 18
9 19
11 ...

output:

4
2
3
1
2
4
1
4
2
3
2
4
1
2
3
1
4
3
2
1
2
4
3
3
2
1
2
4
3
1
2
4
1
3
4
4
3
2
1
1
2
4
3
1
2
3
4
3
1
4
2
4
4
3
2
1
2
4
3
1
3
4
4
2
3
1
1
4
3
2
1
3
2
2
1
4
2
3
3
1
4
2
2
3
4
4
1
2
1
4
4
3
2
2
1
4
3
2
2
3
4
1
1
4
2
2
3
1
2
3
3
2
1
4
4
1
2
4
2
4
1
1
4
3
3
1
2
4
2
4
3
3
2
1
4
2
4
3
4
1
3
2
3
4
2
3
4
3
1
4
...

result:

ok ...

Test #17:

score: 0
Accepted
time: 4ms
memory: 3888kb

input:

3273 9498
0 1
1 0
1 1
0 3
1 2
2 2
1 3
2 3
3 2
3 3
2 4
1 4
3 4
2 5
1 5
3 5
2 6
1 6
1 7
3 6
2 7
1 8
3 7
2 8
3 8
2 9
1 9
3 9
2 10
1 10
3 10
2 11
3 11
4 10
4 11
3 12
4 12
5 12
4 13
5 13
4 14
6 13
5 14
4 15
6 14
5 15
6 15
5 16
6 16
7 15
7 16
6 17
7 17
6 18
8 17
7 18
8 18
7 19
9 18
8 19
7 20
9 19
8 20
9 2...

output:

2
3
1
3
4
3
1
2
1
4
3
2
2
1
4
4
2
3
1
1
4
3
2
1
3
4
2
2
1
3
4
2
3
2
1
4
2
3
3
1
2
4
3
4
2
1
4
3
2
3
1
1
4
2
3
1
2
3
4
1
2
3
4
2
4
3
1
2
4
3
2
1
3
2
1
4
3
3
2
4
1
3
1
4
1
2
1
2
4
3
4
2
1
3
3
1
2
4
3
2
4
3
1
2
2
3
1
1
4
3
3
1
2
3
4
1
3
4
2
4
3
1
1
4
2
4
1
1
3
2
4
2
1
3
3
1
2
1
4
3
3
2
1
2
3
1
4
2
1
2
...

result:

ok ...

Test #18:

score: 0
Accepted
time: 4ms
memory: 3872kb

input:

3253 9412
0 1
1 0
1 1
0 3
1 2
2 2
1 3
2 3
1 4
3 3
2 4
3 4
2 5
4 4
3 5
4 5
3 6
5 5
4 6
5 6
4 7
3 7
3 8
5 7
4 8
5 8
4 9
5 9
4 10
6 9
5 10
6 10
5 11
6 11
5 12
7 10
7 11
6 12
7 12
6 13
7 13
6 14
8 13
7 14
8 14
7 15
9 14
9 15
8 16
10 14
10 15
9 16
8 17
10 16
9 17
8 18
10 17
9 18
10 18
9 19
8 19
10 19
9 2...

output:

1
4
3
4
2
4
3
1
2
3
4
2
1
4
4
1
2
3
4
2
1
4
3
3
4
1
1
3
2
2
4
1
1
3
2
2
1
4
2
3
1
2
3
3
2
1
1
4
2
3
2
3
1
1
2
3
3
1
2
4
2
1
1
3
2
4
1
4
2
2
3
1
1
2
3
1
1
3
2
1
2
3
1
4
1
3
4
1
4
2
1
2
1
3
3
4
2
2
1
1
3
2
2
1
1
2
3
4
3
1
4
2
4
3
1
4
3
2
1
2
4
3
1
2
3
1
3
4
1
1
2
2
1
3
3
2
1
1
3
2
1
2
3
3
4
1
2
2
3
3
...

result:

ok ...

Test #19:

score: 0
Accepted
time: 4ms
memory: 3964kb

input:

3235 9324
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
1 4
0 5
2 4
1 5
2 5
1 6
0 7
2 6
1 7
2 7
1 8
2 8
1 9
3 7
3 8
2 9
3 9
2 10
4 8
4 9
3 10
4 10
3 11
5 9
5 10
4 11
5 11
4 12
6 10
6 11
5 13
4 13
4 14
6 13
5 14
6 14
7 13
7 14
6 15
5 15
5 16
7 15
6 16
7 16
8 15
8 16
7 18
6 17
6 18
6 19
8 18
7 19
8 19
7 20
9 19...

output:

4
1
3
1
2
4
1
4
2
3
2
4
1
2
3
1
1
2
3
3
4
1
2
1
2
3
4
4
2
1
4
2
3
2
1
3
4
1
2
1
2
3
3
2
4
2
3
1
3
4
4
2
3
2
4
2
1
4
3
1
4
3
1
4
2
4
1
1
3
2
4
1
4
2
3
3
4
1
2
4
2
1
3
1
4
2
1
4
3
1
2
3
4
3
1
3
2
4
3
2
1
4
2
3
3
1
2
4
3
2
1
4
2
3
3
4
2
1
3
3
1
2
2
3
4
4
1
3
3
4
2
2
3
1
1
2
2
4
3
1
2
1
4
4
3
1
2
1
4
1
...

result:

ok ...

Test #20:

score: 0
Accepted
time: 4ms
memory: 4092kb

input:

3203 9190
0 1
1 0
1 1
0 3
1 2
2 2
1 3
2 3
1 4
2 4
3 3
3 4
2 5
1 5
1 6
3 5
2 6
3 6
2 7
4 6
3 7
2 8
4 7
3 8
2 9
4 8
3 9
4 9
5 9
4 10
3 11
5 10
5 11
4 12
6 10
6 11
5 12
4 13
6 12
5 13
4 14
6 13
5 15
4 15
6 14
6 15
5 16
6 16
7 15
6 17
5 17
5 18
8 17
6 18
7 18
8 18
7 19
8 19
9 19
8 20
7 20
9 20
8 21
9 21...

output:

3
1
2
1
4
1
2
3
3
1
2
3
2
1
3
1
1
3
4
2
1
2
4
3
4
2
1
3
1
2
4
3
4
2
2
3
1
4
4
2
3
3
1
2
2
3
3
2
1
4
2
1
2
3
1
3
4
2
1
3
1
2
4
1
4
3
2
2
4
1
2
3
2
3
4
3
1
2
2
3
4
1
4
2
3
3
4
1
2
1
4
4
3
1
1
2
4
3
1
3
2
2
3
4
1
2
1
4
3
2
4
4
1
3
3
2
2
4
1
3
2
1
4
2
3
4
4
1
2
1
3
4
1
3
2
2
4
1
3
3
2
1
1
3
4
2
2
1
4
4
...

result:

ok ...

Test #21:

score: 0
Accepted
time: 3ms
memory: 3920kb

input:

3177 9049
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
1 4
3 2
3 3
2 4
3 4
4 4
3 5
2 5
4 5
3 6
2 6
2 7
4 6
5 5
5 6
4 7
5 7
4 8
6 6
6 7
6 8
5 9
7 8
6 9
7 9
6 10
8 8
8 9
7 10
8 10
7 11
9 10
8 11
9 11
8 12
7 12
7 13
9 12
8 13
9 13
8 14
10 12
10 13
9 14
11 14
9 15
10 15
9 16
8 16
8 17
10 16
9 17
10 17
9 18
10 18...

output:

3
1
4
4
2
3
1
3
4
1
2
3
3
2
1
4
2
2
1
3
4
3
4
1
2
4
1
3
1
3
1
4
4
2
3
1
3
1
4
3
1
2
3
4
1
3
2
2
1
4
4
2
2
4
3
2
1
3
4
4
3
2
2
1
3
4
2
4
3
1
3
2
4
3
2
1
4
1
3
4
2
4
3
2
2
1
4
3
3
2
1
4
4
1
2
3
4
2
3
1
3
2
1
4
1
3
4
2
1
1
3
2
4
4
2
3
3
4
2
1
1
2
3
1
3
3
2
4
1
2
3
3
4
2
1
3
2
3
4
1
4
3
3
4
1
2
3
1
2
4
...

result:

ok ...

Test #22:

score: 0
Accepted
time: 3ms
memory: 3920kb

input:

3156 8934
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
3 3
2 4
3 4
4 4
3 5
2 5
2 6
4 5
3 6
4 6
5 5
5 6
4 7
5 7
4 8
6 7
5 8
6 8
7 8
6 9
7 9
8 8
8 9
7 10
6 10
8 10
7 11
8 11
7 12
9 11
8 12
9 12
8 13
10 12
9 13
10 13
11 13
10 14
11 14
10 15
12 14
11 15
12 15
11 16
12 16
13 15
13 16
12 17
11 17
13 17
12 18
11 18...

output:

1
3
2
3
4
1
3
1
2
1
3
4
3
2
1
3
1
1
3
2
1
4
2
3
4
1
3
1
4
2
3
4
1
3
3
4
2
3
4
1
3
2
1
1
4
2
2
1
4
3
2
1
3
4
3
1
2
1
3
4
3
1
2
3
2
1
4
2
4
3
2
1
2
1
3
2
3
2
1
1
4
3
4
1
2
1
3
3
4
1
3
1
4
3
4
2
1
1
4
3
3
2
3
1
2
2
3
2
1
4
3
3
1
4
4
3
2
2
4
1
1
2
3
4
1
4
3
2
2
2
1
4
2
4
3
1
2
1
4
3
3
1
2
1
3
2
1
2
4
1
...

result:

ok ...

Test #23:

score: 0
Accepted
time: 4ms
memory: 3852kb

input:

3134 8832
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
3 3
2 4
1 4
1 5
3 4
2 5
1 6
3 5
2 6
3 6
2 7
4 6
3 7
4 7
3 8
5 7
5 8
5 9
6 9
7 9
6 10
5 10
5 11
7 10
6 11
7 11
8 10
8 11
7 12
8 12
9 11
9 12
8 13
9 13
10 12
10 13
9 14
10 14
11 14
10 15
11 15
12 15
11 16
10 16
10 17
12 16
11 17
12 17
11 18
13 16
13 17
12 ...

output:

2
1
3
1
4
2
1
2
3
2
4
3
1
3
2
3
1
1
3
4
2
2
4
3
3
1
2
3
2
1
4
2
3
3
2
4
1
1
4
3
2
2
1
4
3
4
2
4
3
1
3
2
1
4
1
3
4
2
2
3
3
2
4
3
1
4
2
2
1
3
4
2
3
4
1
2
1
4
3
2
4
3
2
1
2
4
1
3
3
1
4
4
3
1
2
2
3
4
3
1
4
1
2
4
3
3
1
4
4
2
1
3
2
2
4
1
3
3
2
4
1
2
3
3
2
1
4
2
1
2
3
4
2
3
1
2
2
3
1
2
1
1
2
4
3
3
1
2
3
4
...

result:

ok ...

Test #24:

score: 0
Accepted
time: 4ms
memory: 3956kb

input:

3115 8728
0 1
1 0
1 1
0 3
1 2
2 2
1 3
2 3
3 3
2 4
3 4
2 5
4 3
4 4
3 6
2 6
4 6
3 7
2 7
2 8
5 7
3 8
4 8
3 9
2 9
4 9
3 10
4 10
3 11
5 10
4 11
3 12
5 11
4 12
5 12
4 13
7 12
5 13
6 13
7 13
6 14
5 14
6 15
5 15
5 16
7 15
6 16
7 16
6 17
8 16
7 17
6 18
8 17
7 18
8 18
9 18
8 19
9 19
10 19
9 20
10 20
9 21
11 1...

output:

2
1
4
4
3
1
2
4
2
3
1
2
4
2
4
1
1
2
4
3
3
1
3
2
4
1
3
4
2
3
1
3
2
2
3
1
1
2
1
2
4
1
3
2
4
4
1
2
4
1
3
2
4
1
2
1
3
4
2
2
3
4
4
2
1
3
3
2
1
1
3
2
2
1
3
4
2
4
3
2
3
2
1
3
3
2
4
1
4
3
2
3
1
4
3
3
2
1
1
4
3
2
1
4
3
2
3
1
2
4
2
3
1
1
3
4
2
3
1
3
2
3
2
1
4
3
1
2
3
1
4
2
4
1
3
1
2
2
4
3
3
2
4
1
4
2
3
1
1
2
...

result:

ok ...

Test #25:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

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

output:

2
1
3
1
4
1
2
4
3
2
1
2
2
1
3
3
1
2
4
2
1
1
3
2
4
2
1
1
3
3
2
1
3
1
1
2
1
3
2
3
1
3
1
1
2
1
4
3
1
1
2
1
2
3
2
2
3
1
1
2
3
1
3
4
1
2
1
1
3
3
1
4
2
3
3
1
1
2
3
1
1
2
1
3
3
4
1
3
4
2
3
1
4
2
3
1
2
1
3
2
3
1
4
1
2
3
4
2
1
1
3
4
2
4
1
2
3
1
2
3
4
1
2
3
1
4
3
2
1
2
4
3
1
2
3
2
1
2
1
3
2
3
1
2
3
2
1
3
2
3
...

result:

ok ...

Test #26:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

662 1598
0 1
1 0
1 1
0 3
1 2
1 3
2 3
3 2
2 4
3 4
4 3
4 4
3 5
4 5
5 5
4 6
6 6
4 7
5 7
6 7
5 9
6 8
6 9
6 10
7 10
6 11
9 8
8 8
9 7
10 8
9 9
10 9
10 10
9 11
11 10
10 11
11 11
12 11
12 12
13 11
13 12
12 13
10 13
12 14
10 14
11 15
13 14
12 15
13 15
14 15
13 16
12 17
14 16
15 16
14 17
13 18
17 17
14 18
13 ...

output:

1
2
3
2
4
1
2
1
3
4
2
3
1
2
1
3
2
1
2
1
4
3
1
2
3
4
2
1
4
3
1
2
4
3
3
1
2
1
3
4
1
2
1
3
2
1
1
2
3
4
2
1
1
2
3
2
1
4
1
2
3
4
1
4
2
1
3
4
2
2
2
4
1
3
1
3
2
2
3
1
2
2
3
4
1
3
2
3
2
4
2
1
3
1
2
2
3
4
1
4
2
3
1
2
1
3
3
1
2
1
2
4
3
1
2
3
3
2
1
4
3
2
1
4
3
2
1
4
3
2
3
1
2
3
1
2
1
3
3
1
2
3
1
4
1
2
3
1
2
3
...

result:

ok ...

Test #27:

score: 0
Accepted
time: 3ms
memory: 4020kb

input:

2517 7117
0 1
1 0
1 1
0 3
1 2
2 2
1 3
2 3
3 2
3 3
2 4
1 4
1 5
3 4
2 5
3 5
2 6
3 6
2 7
4 6
3 7
5 7
3 8
4 8
5 8
4 9
5 9
6 9
5 10
4 10
4 11
6 10
5 11
4 12
6 11
5 12
6 12
7 11
7 12
6 13
7 13
6 14
8 13
8 14
7 15
9 13
9 14
8 15
9 15
8 16
10 15
9 16
8 17
10 16
9 17
8 18
10 17
9 18
10 18
11 17
11 18
10 19
1...

output:

2
1
3
1
4
1
2
3
4
2
4
3
1
3
2
1
4
3
2
4
1
2
4
2
3
3
1
4
2
1
4
3
1
3
2
4
3
4
1
2
4
3
1
3
1
2
4
2
1
3
2
4
2
1
3
1
2
4
1
3
2
2
4
3
2
3
4
2
3
4
4
4
3
2
1
4
2
3
4
1
1
4
2
3
1
4
4
3
2
1
4
1
2
3
1
4
2
1
2
3
3
2
1
4
3
2
1
3
4
4
3
2
1
2
3
3
2
4
4
1
3
3
4
2
1
1
3
4
2
2
1
3
3
4
2
3
1
1
3
4
4
2
1
3
3
4
2
3
2
4
...

result:

ok ...

Test #28:

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

input:

767 1862
0 1
1 0
1 1
0 3
1 2
2 1
3 2
1 4
2 3
3 3
2 4
1 5
2 5
3 5
5 5
3 6
4 6
5 6
4 7
3 8
4 8
5 8
6 7
6 8
4 10
6 9
5 10
7 9
7 10
8 9
8 10
9 10
8 11
6 11
8 12
7 13
10 12
8 13
6 15
8 14
7 15
10 14
8 15
7 16
9 15
8 16
9 16
10 15
11 15
12 14
12 15
11 17
10 17
13 17
12 18
10 18
13 18
14 17
14 18
13 19
12 ...

output:

1
2
3
2
4
1
3
3
1
2
4
2
1
2
3
3
1
2
2
1
3
1
4
2
1
3
2
2
1
4
3
1
2
3
1
2
2
3
4
2
1
3
3
2
1
4
2
4
1
2
3
3
2
4
1
3
2
1
4
3
1
2
4
2
1
1
2
3
1
3
4
1
3
2
2
3
4
1
3
1
4
2
3
2
1
1
3
2
2
1
1
4
3
1
4
2
4
1
3
2
1
1
3
1
2
4
1
4
2
4
3
3
2
1
4
3
2
3
1
1
3
2
2
1
4
3
2
2
3
4
1
2
4
2
3
1
4
3
3
1
2
1
3
3
1
2
3
4
1
2
...

result:

ok ...

Test #29:

score: 0
Accepted
time: 0ms
memory: 3708kb

input:

963 2373
0 1
1 0
1 1
0 3
1 2
1 3
2 3
1 4
0 5
2 5
1 6
3 4
3 5
2 6
2 7
3 7
4 6
4 7
3 8
2 8
3 10
2 9
2 10
4 9
4 10
3 11
2 11
2 12
4 11
3 12
4 12
3 13
6 12
4 13
5 13
5 14
6 14
5 15
6 15
7 14
7 15
6 16
7 16
8 16
9 15
9 16
8 17
9 17
8 18
7 18
7 19
9 18
8 19
7 20
9 19
8 20
9 20
8 21
9 21
8 22
10 20
10 21
9...

output:

2
1
3
1
4
2
1
3
2
1
3
3
2
2
4
1
3
2
3
2
1
4
2
3
2
3
1
2
1
1
2
3
1
1
2
3
1
4
2
4
3
3
4
1
2
3
2
1
4
3
1
3
2
3
4
1
2
2
3
4
1
2
1
4
2
1
2
1
3
2
2
3
1
3
2
4
1
2
1
3
4
1
2
1
3
2
3
1
2
3
1
2
1
3
2
4
3
1
2
3
4
1
4
2
1
3
2
1
4
3
2
1
2
4
1
4
3
2
3
1
4
3
2
1
3
2
4
1
3
2
1
3
4
2
3
1
1
4
2
2
1
3
3
1
4
2
3
1
3
2
...

result:

ok ...

Test #30:

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

input:

1217 2984
0 1
1 0
1 1
0 3
1 2
3 2
1 3
2 3
1 4
3 3
2 4
3 4
2 5
4 5
3 6
1 6
2 7
3 7
4 7
3 8
5 6
5 7
4 8
3 9
5 8
4 9
4 10
5 10
6 9
6 10
5 11
6 11
5 13
6 12
7 12
6 14
5 14
7 14
6 15
5 15
7 15
6 16
4 16
5 17
7 16
6 17
7 17
6 18
7 18
6 19
8 18
9 18
8 20
9 19
11 19
9 20
10 20
9 21
11 20
11 21
10 22
12 20
1...

output:

1
2
3
2
4
3
1
2
3
4
1
3
2
3
3
4
1
2
1
4
2
4
3
2
2
1
3
4
1
2
1
3
3
2
1
3
1
4
2
3
1
4
1
2
2
1
3
4
2
1
1
3
2
4
1
1
2
4
3
1
3
2
3
2
1
3
1
1
4
2
1
3
4
1
3
3
2
4
4
1
2
3
4
1
3
2
3
1
2
3
4
1
3
2
1
2
2
3
2
4
3
1
4
1
2
3
3
1
2
1
2
3
3
1
4
3
2
1
1
3
4
1
3
2
1
4
1
2
3
1
2
1
3
4
1
2
3
1
2
3
4
2
1
3
4
2
3
1
2
4
...

result:

ok ...

Test #31:

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

input:

971 2364
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 4
2 3
3 2
4 3
2 4
3 4
2 5
4 4
3 6
2 6
2 7
4 5
3 7
4 7
3 8
2 8
2 9
5 8
3 10
4 9
5 9
4 10
5 10
6 9
6 10
4 12
6 11
5 12
8 11
7 12
6 13
9 12
7 14
6 14
8 14
7 15
7 16
8 16
9 16
8 17
7 17
9 17
8 18
7 18
7 19
9 18
8 19
10 19
8 20
9 20
10 20
9 21
10 21
11 20
10 22
8 22...

output:

2
1
3
1
4
2
1
3
2
3
1
1
3
2
2
4
1
3
1
2
3
1
4
2
4
3
2
1
1
3
4
1
4
3
2
4
2
1
1
1
2
2
3
2
1
2
3
1
1
2
3
1
3
3
1
4
1
2
2
3
4
2
1
1
4
3
1
2
3
4
1
3
2
2
1
3
3
2
1
2
1
3
1
2
2
3
3
1
1
2
3
2
1
4
3
2
2
1
3
2
1
1
4
3
2
1
2
3
1
2
4
3
1
3
2
1
4
3
2
3
1
2
3
1
2
4
4
3
1
1
2
4
3
1
2
3
4
1
2
3
4
1
1
2
4
2
3
1
3
4
...

result:

ok ...

Test #32:

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

input:

2058 5112
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
3 2
3 3
2 4
1 4
1 5
3 4
2 5
1 6
3 5
2 6
2 7
3 7
4 6
4 7
3 8
1 8
2 9
3 9
4 9
3 10
2 10
2 11
4 10
3 11
4 11
3 12
2 12
3 14
4 13
5 12
5 13
4 14
6 15
5 15
6 14
7 14
7 15
6 16
7 16
8 15
8 16
8 17
5 17
7 18
9 16
8 18
9 18
8 19
10 17
10 18
10 19
11 18
10 20
9 2...

output:

2
1
3
1
4
2
1
2
3
4
2
4
3
1
1
2
3
3
1
4
2
1
3
1
3
2
3
2
4
1
2
3
1
2
3
4
4
2
3
1
1
1
4
3
4
3
3
4
2
3
2
1
1
1
4
3
1
1
2
4
3
2
1
3
3
1
4
2
1
4
3
2
3
1
3
4
1
2
2
1
3
4
2
3
1
3
2
1
2
3
3
2
4
1
3
2
1
4
3
3
4
2
1
3
1
1
2
1
3
4
3
2
1
2
3
2
4
1
1
2
2
3
3
1
2
2
4
3
1
1
2
3
1
2
2
1
4
3
1
1
2
2
3
4
1
1
2
1
3
4
...

result:

ok ...

Test #33:

score: 0
Accepted
time: 2ms
memory: 3800kb

input:

1982 5590
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
3 3
1 4
0 5
2 4
1 5
1 6
2 6
3 5
3 6
2 7
3 7
2 8
4 7
3 8
4 8
5 8
4 9
5 9
6 9
5 10
6 10
7 9
7 10
6 11
8 12
7 12
8 11
9 11
9 12
8 13
7 13
9 13
8 14
7 14
7 15
9 14
8 15
9 15
10 14
10 15
9 16
10 16
9 17
11 15
11 16
10 17
9 18
11 17
10 18
11 18
12 17
12 18
11 19
1...

output:

3
2
1
1
4
3
2
3
2
2
3
3
1
2
3
2
1
1
4
3
2
2
1
3
4
2
1
1
4
3
1
3
3
2
2
4
1
4
3
3
2
1
3
1
4
3
2
1
1
4
2
3
1
3
1
2
2
1
4
2
3
4
1
2
3
3
4
1
1
2
3
3
4
1
2
3
2
2
1
3
3
2
4
1
1
3
4
2
4
1
2
3
4
3
1
2
1
3
4
1
2
2
4
3
2
1
3
4
4
2
1
3
4
3
2
1
4
3
4
1
2
4
3
2
3
4
4
3
3
2
4
3
2
1
4
3
3
2
1
2
3
3
2
1
3
4
1
4
3
4
...

result:

ok ...

Test #34:

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

input:

802 2188
0 1
1 0
1 1
0 5
1 2
2 2
1 3
2 3
1 4
2 4
1 5
3 3
3 4
2 5
3 5
4 5
3 6
4 6
3 7
5 6
4 7
3 8
4 8
5 8
6 7
6 8
5 9
4 9
5 10
6 10
7 9
6 11
4 13
8 9
7 11
6 12
7 12
8 11
8 12
7 13
6 14
8 13
7 14
8 14
9 14
8 15
6 15
7 16
9 15
8 16
9 16
10 15
9 17
10 17
9 18
8 18
9 19
10 19
9 20
11 19
10 20
11 20
10 21...

output:

2
1
3
3
1
4
3
2
1
4
2
1
3
3
1
2
2
3
1
2
4
2
1
3
1
4
2
3
4
1
3
2
3
1
1
3
4
3
2
1
2
3
3
4
1
2
4
1
3
3
1
2
2
1
3
2
1
2
4
1
3
4
2
3
2
3
1
3
2
4
4
1
2
2
3
2
1
4
1
3
3
2
1
4
2
4
3
2
2
1
3
3
2
4
3
1
4
1
2
3
2
1
4
1
3
2
4
2
1
2
3
1
3
2
4
2
1
3
2
4
2
3
1
2
4
4
3
1
2
1
4
3
2
3
1
2
1
3
4
2
4
1
3
1
2
1
3
3
1
4
...

result:

ok ...

Test #35:

score: 0
Accepted
time: 2ms
memory: 3864kb

input:

2511 6643
0 1
1 0
1 1
0 3
1 2
2 2
1 3
2 3
1 4
3 2
3 3
2 4
1 5
2 5
3 5
2 6
4 4
4 5
3 6
2 7
4 6
3 7
5 8
4 8
5 7
7 6
6 6
7 5
7 7
8 7
7 8
8 8
9 8
9 7
10 7
10 8
9 9
8 10
9 10
10 10
11 9
10 11
11 11
12 10
12 11
13 10
13 11
12 12
13 12
14 11
14 12
13 13
14 13
13 14
15 12
15 13
16 12
16 13
15 14
16 14
15 15...

output:

1
2
3
2
4
2
1
3
4
4
2
1
2
4
2
1
4
1
3
4
2
1
1
3
3
2
1
3
3
1
2
4
3
2
4
1
2
1
3
1
2
2
3
1
2
3
1
1
3
4
2
1
4
2
1
2
4
3
3
1
4
3
2
1
1
2
3
4
2
1
3
4
3
1
2
4
2
1
1
2
4
1
4
2
4
3
1
2
2
4
1
1
3
2
2
1
4
4
2
4
1
1
2
3
1
2
4
1
1
2
1
2
3
2
4
1
2
3
1
4
2
1
4
1
1
3
2
1
4
2
1
3
1
2
3
2
1
1
3
2
1
2
3
1
4
3
4
2
1
2
...

result:

ok ...

Test #36:

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

input:

862 2006
0 1
1 0
1 1
0 5
1 2
1 4
2 3
2 1
3 2
3 3
2 4
3 4
2 5
1 6
3 6
2 7
4 5
3 7
4 7
3 8
5 7
4 8
5 8
4 9
5 9
6 9
5 10
3 10
6 10
5 11
6 11
5 12
3 12
6 12
5 13
7 14
6 14
7 13
8 14
7 15
6 15
8 16
9 16
8 17
7 17
9 17
8 18
7 18
7 19
10 18
9 19
10 17
10 19
12 19
10 20
9 20
9 21
11 21
10 22
12 21
11 23
10 ...

output:

1
2
3
2
2
1
3
1
1
4
2
1
4
3
2
1
1
3
4
1
1
2
3
4
1
2
3
2
4
1
3
2
1
1
1
4
3
1
2
2
1
1
3
2
1
1
4
3
1
2
1
4
3
1
2
3
1
1
2
2
2
1
1
3
2
1
3
3
2
4
1
3
1
2
3
2
4
1
2
1
3
4
2
3
1
2
4
3
1
2
4
1
4
3
2
1
2
3
4
1
2
1
2
3
1
2
1
3
4
1
2
1
3
4
1
3
2
4
3
1
1
2
2
1
2
3
1
4
2
3
2
1
2
3
2
1
3
2
4
1
3
1
2
3
2
1
1
2
2
1
...

result:

ok ...

Test #37:

score: 0
Accepted
time: 0ms
memory: 3712kb

input:

1615 4544
0 1
1 0
1 1
0 3
1 2
2 2
1 3
2 3
1 4
3 3
2 4
3 4
2 5
3 5
2 6
4 5
3 6
3 7
4 7
5 6
5 7
4 8
3 8
3 9
6 8
4 9
5 9
6 10
4 10
6 11
7 11
7 9
8 10
8 11
7 12
8 12
9 11
8 13
7 13
7 14
9 13
8 14
9 14
8 15
10 14
9 15
8 16
10 15
9 16
8 17
10 16
9 17
10 17
9 18
8 18
10 18
9 20
10 19
11 18
11 19
10 20
11 2...

output:

2
3
1
1
4
3
2
1
4
4
3
2
2
1
3
4
2
1
3
1
2
4
2
1
2
3
1
3
2
2
4
3
2
1
1
2
4
4
2
3
1
2
3
4
2
1
2
3
4
1
2
3
1
2
4
3
1
4
2
1
3
4
2
4
3
1
4
2
1
3
2
4
3
1
4
1
2
3
1
2
2
4
3
1
2
1
4
3
2
1
3
3
4
1
2
3
4
2
1
3
2
2
1
1
4
2
2
3
1
2
3
1
4
1
3
2
4
1
3
2
3
1
2
1
3
4
2
1
4
3
1
2
4
1
3
2
1
2
4
1
3
4
1
2
3
1
4
3
2
3
...

result:

ok ...

Test #38:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

3443 7658
0 1
1 0
1 1
0 3
2 3
1 3
2 2
3 2
2 4
3 4
2 5
4 4
3 5
2 6
2 7
3 7
2 8
4 6
4 8
5 7
4 9
3 10
6 7
5 9
4 10
5 11
6 11
5 12
4 13
6 12
6 13
6 14
7 14
9 12
8 14
8 15
9 15
8 16
11 16
9 17
8 18
9 19
10 18
11 18
10 19
11 19
12 19
12 18
13 19
14 18
14 19
13 21
12 21
14 21
13 22
12 22
14 22
13 23
14 23
...

output:

2
1
3
1
3
2
1
2
1
4
2
2
3
1
2
3
1
2
1
3
2
3
1
3
1
2
1
3
2
2
1
2
3
2
1
2
3
1
2
2
3
1
3
1
2
4
3
2
1
3
2
2
3
1
4
1
2
2
3
1
4
2
1
2
3
2
1
3
1
4
3
2
3
4
1
1
3
2
2
1
1
3
2
1
3
2
3
1
2
3
2
1
2
1
3
4
1
3
2
4
2
1
4
3
2
1
1
2
3
2
4
2
1
1
3
2
4
2
1
1
3
2
1
2
1
1
2
2
2
3
3
1
4
4
2
1
3
2
2
3
1
1
3
2
1
3
1
2
3
1
...

result:

ok ...

Test #39:

score: 0
Accepted
time: 0ms
memory: 3724kb

input:

1721 4230
0 1
1 0
1 1
0 3
1 2
2 1
1 3
3 3
1 4
2 4
1 5
2 5
0 7
4 3
3 5
2 6
1 7
3 6
2 7
1 8
2 8
3 8
2 9
4 7
4 8
6 8
4 9
5 9
6 9
4 11
7 9
6 10
7 10
7 11
6 11
9 11
7 12
6 12
6 13
8 12
9 12
8 13
10 13
8 14
5 14
7 15
8 15
10 15
9 16
7 16
8 17
11 16
9 17
8 18
9 18
10 18
9 19
11 18
10 19
12 20
11 20
13 20
1...

output:

1
2
3
2
4
1
1
2
3
4
2
1
2
3
3
2
1
1
4
3
1
2
4
3
1
2
2
3
1
3
4
2
3
4
1
2
3
2
1
1
3
4
2
3
4
1
2
1
1
4
3
2
2
4
1
4
3
1
2
2
1
4
3
1
2
3
1
3
3
1
4
2
2
3
4
1
3
2
3
1
4
2
1
3
3
1
2
3
2
1
4
1
2
2
1
3
2
1
3
4
3
1
2
1
3
4
2
3
2
1
3
1
2
4
2
1
3
2
1
2
3
1
3
2
1
2
4
1
3
1
2
1
4
2
3
2
1
4
3
1
2
1
3
3
2
4
2
1
3
4
...

result:

ok ...

Test #40:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

1914 4267
0 1
1 0
1 1
0 3
1 2
2 2
1 3
2 3
3 4
2 5
4 3
4 4
3 6
2 7
3 7
2 8
5 7
5 6
6 7
5 8
6 8
7 7
7 8
6 9
5 9
6 10
4 10
5 11
6 11
5 12
7 11
6 12
7 12
6 13
5 13
5 14
7 14
8 14
7 15
8 15
9 15
8 16
9 16
8 17
10 16
9 17
9 18
10 18
11 17
11 18
10 19
11 19
10 22
9 22
10 24
11 23
12 23
11 24
12 24
11 25
13...

output:

2
1
3
1
4
1
2
3
2
4
1
3
3
1
2
3
1
2
3
2
4
2
1
1
4
2
3
1
3
2
2
1
4
3
1
2
2
1
3
4
2
2
1
4
2
2
3
1
4
3
2
1
1
3
3
2
3
1
4
2
1
1
2
3
1
2
2
3
4
1
2
2
1
3
1
1
2
3
2
1
3
3
1
2
1
1
3
2
3
1
2
1
4
2
3
2
2
1
3
1
2
1
1
3
4
2
3
1
4
2
3
1
3
2
2
3
3
1
2
2
3
1
4
3
1
3
2
4
1
2
1
3
1
4
2
3
1
2
3
3
1
2
1
3
2
2
1
1
3
1
...

result:

ok ...

Test #41:

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

input:

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

output:

1
2
3
2
4
1
2
1
3
2
1
1
3
2
2
1
3
2
1
1
3
2
1
3
2
4
1
2
2
3
4
1
3
2
4
1
3
2
4
1
3
3
2
1
4
2
2
3
1
1
2
1
4
4
3
1
1
2
3
1
4
2
1
1
3
2
2
1
2
1
3
4
1
1
4
2
4
2
3
1
2
3
3
1
2
4
1
2
1
3
2
1
4
3
1
2
3
1
3
4
2
1
3
3
1
2
2
1
3
1
4
2
3
1
2
1
2
3
1
2
1
2
3
2
3
2
1
2
4
3
2
1
4
1
2
3
2
4
3
2
1
1
4
2
1
4
2
3
2
1
...

result:

ok ...

Test #42:

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

input:

476 1070
0 1
1 0
1 1
0 5
1 2
2 1
2 2
2 3
4 3
2 4
1 4
2 5
3 5
4 5
3 7
4 6
5 6
4 7
4 8
5 8
5 9
3 9
6 8
5 10
4 10
7 10
5 11
4 11
5 12
4 12
4 13
3 13
3 14
6 13
4 15
5 14
5 16
6 15
6 16
7 16
6 17
7 13
8 16
8 15
9 16
8 17
7 18
9 17
8 18
8 19
9 19
8 20
7 20
7 21
9 20
8 21
9 21
10 21
9 22
11 22
12 21
13 22
...

output:

1
2
3
2
2
1
3
1
3
2
1
4
1
2
2
3
4
1
3
1
2
3
3
3
1
2
2
3
4
1
3
2
4
1
1
2
1
3
4
2
1
3
3
1
4
2
1
1
3
2
1
4
3
1
2
2
1
2
3
1
3
2
1
4
3
1
2
3
3
1
2
1
3
2
3
2
1
3
2
1
1
4
3
1
2
3
4
1
3
3
1
2
4
2
3
3
1
2
1
3
3
1
2
2
1
4
2
3
1
3
4
2
1
3
3
2
1
3
2
2
1
3
2
1
2
3
2
3
1
1
4
2
1
4
3
2
3
4
1
2
1
2
3
1
3
2
1
3
1
2
...

result:

ok ...

Test #43:

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

input:

1017 2311
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
1 4
2 4
2 5
1 6
3 4
3 5
2 6
3 6
2 7
1 8
4 7
3 8
2 9
4 9
3 10
5 9
4 10
3 11
4 11
5 11
5 12
6 12
5 13
7 12
6 13
7 13
6 15
7 14
8 14
7 15
8 15
7 16
8 17
6 17
9 16
9 17
10 16
10 17
8 19
11 17
10 18
10 19
11 19
10 20
12 18
12 19
11 20
11 21
9 21
10 22
12 21
11 23...

output:

1
2
3
2
4
1
2
1
3
4
1
2
3
2
4
3
1
3
4
2
1
1
3
3
2
4
1
4
2
3
1
1
2
3
1
1
4
2
1
3
1
3
2
3
1
2
1
3
1
2
3
1
2
1
2
3
2
1
2
2
1
2
3
1
4
1
2
2
1
3
2
2
1
1
3
4
1
1
3
2
1
1
3
2
2
1
1
4
3
3
1
2
3
3
2
4
4
1
3
1
2
1
2
3
4
2
1
2
1
4
2
3
1
2
1
3
2
4
1
2
1
3
2
4
1
3
4
2
4
1
2
1
4
3
2
4
1
2
3
1
4
2
2
1
2
2
3
4
3
1
...

result:

ok ...

Test #44:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

1367 3169
0 1
1 0
1 1
0 7
1 2
2 2
1 4
2 3
3 3
2 4
3 4
4 4
3 5
1 5
2 6
4 5
3 7
4 6
5 6
5 7
6 7
5 8
6 8
5 9
7 8
5 10
8 8
7 9
6 10
7 10
6 11
7 11
8 11
9 10
9 11
10 10
10 11
11 10
10 12
9 13
11 12
10 13
9 14
11 13
10 14
11 14
10 15
12 13
12 15
12 16
13 16
14 15
14 16
13 17
11 17
12 18
13 18
14 18
15 17
...

output:

2
1
3
1
1
4
2
3
2
4
1
3
2
1
1
1
3
4
2
1
3
2
1
3
3
2
1
2
1
3
4
1
2
1
3
4
2
1
1
2
2
3
4
1
1
4
2
3
1
2
3
2
1
4
3
2
3
2
3
1
1
2
2
4
3
2
1
1
3
4
1
1
3
2
2
1
3
2
1
1
4
3
2
1
1
2
3
1
1
2
4
3
2
1
1
3
4
2
1
4
2
3
3
1
1
2
4
1
2
3
1
2
2
3
1
1
4
2
1
3
2
1
1
2
4
1
2
3
2
4
2
1
4
3
4
2
1
1
3
4
1
2
3
4
1
3
1
2
2
1
...

result:

ok ...

Test #45:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

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

output:

1
2
3
2
4
2
3
1
3
4
1
2
1
3
2
3
4
1
3
4
1
2
3
4
1

result:

ok ...

Test #46:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

49 109
0 1
1 0
1 1
0 3
1 2
1 3
1 5
2 4
3 3
3 4
3 5
4 5
3 6
5 5
4 6
5 6
4 7
6 5
6 6
6 7
5 8
7 7
7 8
8 7
7 6
8 5
7 4
8 3
7 2
7 3
8 1
7 0
7 1
6 1
5 2
6 2
5 3
4 2
6 4
3 1
3 2
2 1
3 0
3 8
1 8
2 7
1 6
1 7
0 7
1 2
1 3
1 4
1 5
5 6
6 7
6 8
8 9
8 10
10 11
10 12
12 13
12 14
12 15
12 16
16 17
16 18
16 19
16 20
...

output:

1
2
3
2
4
1
2
3
1
2
1
3
2
1
1
2
3
3
1
4
1
2
3
4
3
1
2
4
1
3
2
1
3
2
1
3
2
4
1
2
3
1
3
2
3
1
3
2
1

result:

ok ...

Test #47:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

22 48
0 1
1 0
1 1
0 3
1 2
2 1
3 0
3 1
3 2
4 1
3 3
4 3
3 4
4 5
3 5
3 6
1 6
2 5
1 4
1 5
2 3
0 5
1 2
1 3
1 4
1 5
5 6
6 7
6 8
6 9
9 10
9 11
9 12
12 13
12 14
14 15
14 16
16 17
16 18
18 19
18 20
18 21
20 22
19 22
19 21
19 20
17 22
17 20
17 18
15 18
15 16
13 21
13 15
13 14
11 21
11 12
11 13
10 12
8 10
8 9
...

output:

1
2
3
2
4
1
3
2
3
1
2
4
3
1
4
2
3
1
3
2
4
1

result:

ok ...

Test #48:

score: 0
Accepted
time: 0ms
memory: 3544kb

input:

22 48
0 1
1 0
1 1
0 3
1 2
2 1
1 3
2 3
1 4
5 4
4 3
5 3
6 3
5 2
6 1
5 0
5 1
4 1
3 0
4 2
3 2
3 3
1 2
1 3
1 4
1 5
5 6
5 7
7 8
7 9
9 10
10 11
10 12
10 13
13 14
13 15
15 16
15 17
17 18
18 19
18 20
20 21
20 22
21 22
19 21
16 19
16 18
16 17
14 18
14 20
14 17
14 15
12 20
12 14
12 13
11 22
11 20
11 12
8 9
8 2...

output:

1
2
3
2
4
1
1
2
3
4
1
3
2
4
1
2
3
1
3
2
1
3

result:

ok ...

Test #49:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

54 127
0 1
1 0
1 1
0 5
1 2
2 1
2 2
3 2
2 3
1 4
2 4
3 4
2 5
4 4
3 5
3 6
4 6
5 5
5 6
4 7
5 7
6 7
5 8
3 8
7 8
7 7
8 7
7 6
8 5
7 4
6 5
8 3
7 2
8 1
7 0
7 1
6 1
5 0
4 1
6 2
5 2
6 3
4 2
3 0
3 1
5 4
6 6
1 8
2 7
3 7
1 5
1 6
0 7
1 7
1 2
1 3
1 4
1 5
5 6
5 7
7 8
7 9
9 10
9 11
9 12
12 13
12 14
12 15
15 16
15 17
...

output:

2
1
3
1
1
2
3
4
1
2
4
3
1
2
2
3
1
3
2
2
3
1
4
1
2
4
1
2
4
3
1
1
4
3
2
1
3
1
2
1
3
2
1
3
1
4
4
3
2
4
3
4
2
1

result:

ok ...

Test #50:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

17 40
0 1
1 0
1 1
0 3
1 2
2 2
1 3
2 3
1 4
3 3
3 4
4 3
3 2
4 1
3 0
3 1
2 1
1 2
1 3
1 4
1 5
5 6
5 7
5 8
8 9
8 10
8 11
11 12
12 13
12 14
14 15
14 16
16 17
15 17
15 16
13 17
13 16
13 14
10 13
10 12
10 11
9 11
7 8
7 9
6 17
6 13
6 8
6 10
4 5
4 7
4 9
3 17
3 5
3 6
2 15
2 3
2 17

output:

1
2
3
2
4
2
1
3
4
1
2
4
3
1
3
2
1

result:

ok ...

Test #51:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

45 111
0 1
1 0
1 1
0 3
1 2
1 3
2 3
1 4
0 5
2 4
2 5
1 6
3 4
3 5
2 6
3 6
4 6
3 7
4 7
3 8
5 6
5 7
5 8
6 7
6 5
5 4
5 5
6 3
5 2
5 3
6 1
5 0
5 1
4 1
3 0
3 1
3 2
2 1
3 3
4 4
4 5
1 8
2 7
1 7
0 7
1 2
1 3
1 4
1 5
5 6
6 7
6 8
8 9
8 10
8 11
11 12
11 13
11 14
11 15
11 16
16 17
16 18
16 19
19 20
19 21
19 22
19 23...

output:

1
2
3
3
4
1
3
2
1
1
3
2
4
1
4
2
4
1
3
4
1
2
1
3
4
3
2
2
1
4
4
2
3
1
3
2
3
1
2
1
3
2
3
1
3

result:

ok ...

Test #52:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

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

output:

1
2
3
2
4
1
2
1
3
4
1
2
3
1
2
3
2
1
3
4
2
3
1
2
1

result:

ok ...

Test #53:

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

input:

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

output:

2
1
3
1
4
2
1
2
3
2
4
1
1
2
2
1
3
2
4
1
3
2
1
4
3
2
1
2
3
4
1
2
3
1
3
2
1
3
3

result:

ok ...

Test #54:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

50 115
0 1
1 0
1 1
0 3
1 2
2 1
3 2
1 3
2 3
1 4
2 4
3 3
4 4
2 5
3 5
4 5
3 6
2 7
3 7
4 7
3 8
5 8
6 7
7 8
7 7
8 7
7 6
8 5
7 5
8 3
7 2
6 3
6 5
8 1
7 0
7 1
6 1
5 0
5 1
6 2
4 1
4 2
5 3
5 4
3 0
6 6
1 8
0 7
1 7
1 6
1 2
1 3
1 4
1 5
5 6
5 7
5 8
8 9
8 10
10 11
11 12
11 13
11 14
11 15
15 16
15 17
17 18
17 19
17...

output:

2
1
3
1
4
2
1
2
1
3
2
3
1
3
1
2
4
2
1
2
3
1
2
3
1
2
4
1
3
4
1
1
2
3
1
2
3
2
1
2
4
2
3
4
3
1
1
2
3
1

result:

ok ...

Test #55:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

46 101
0 1
1 0
1 1
0 3
1 2
2 1
3 2
1 3
2 3
3 3
1 5
4 3
4 2
5 3
4 4
5 4
4 5
7 4
5 6
4 6
5 7
6 7
7 6
7 7
7 8
3 8
8 7
8 5
8 3
7 2
8 1
7 0
7 1
6 1
5 0
3 0
4 1
1 8
2 7
3 7
4 7
3 5
1 7
0 7
1 6
0 5
1 2
1 3
1 4
1 5
5 6
5 7
5 8
5 9
9 10
10 11
10 12
12 13
12 14
12 15
12 16
16 17
16 18
16 19
19 20
19 21
19 22
...

output:

2
1
3
1
4
2
3
2
1
2
1
4
2
1
1
2
3
3
1
2
3
2
1
3
1
2
2
4
2
3
1
3
2
1
2
3
1
3
1
3
1
2
2
1
3
2

result:

ok ...

Test #56:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

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

output:

1
2
3
2
4
1
2
1
3
4
4
1
2
1
4
3
2
4
1
3
2
4
3
1
2
1
3
4
3

result:

ok ...

Test #57:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

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

output:

3
2
1
2
4
1
2
3
1
1
2
4
3
1
2
4
2
1
4
3
1
2
3
4
1
1
3
2
1
2
3
2
2
3
1
4
3
1
2
3
1
3

result:

ok ...

Test #58:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

56 137
0 1
1 0
1 1
0 3
1 2
2 1
2 2
1 3
2 3
1 4
2 4
2 5
1 5
1 6
4 3
3 5
2 6
2 7
1 7
1 8
3 8
4 7
5 8
5 7
6 7
7 8
7 7
8 7
7 6
8 5
7 4
7 5
8 3
7 2
7 3
8 1
7 0
7 1
6 1
6 2
5 1
5 2
5 3
6 3
5 4
4 4
5 5
4 6
6 5
6 6
4 1
3 2
3 1
3 0
0 7
0 5
1 2
1 3
1 4
1 5
5 6
5 7
5 8
8 9
8 10
8 11
11 12
12 13
12 14
12 15
12 ...

output:

3
2
1
2
4
3
2
1
3
3
2
1
2
3
2
3
2
4
1
3
1
2
4
3
1
3
2
4
3
1
3
4
4
1
2
3
2
4
1
3
2
1
4
1
2
1
3
1
1
2
3
4
2
1
2
1

result:

ok ...

Test #59:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

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

output:

1
2
3
2
4
1
2
4
1
3
2
4
3
1
1
3
2
4
1
3
4
2
1
2
3
1
3
2
1

result:

ok ...

Test #60:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

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

output:

1
2
3
2
4
2
1
3
1
4
1
2
3
4
3
4
1
2
4
3
1
3
2
1
3
1
3
2
1

result:

ok ...

Test #61:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

48 103
0 1
1 0
1 1
0 3
1 2
1 4
0 5
2 3
2 1
2 5
3 4
4 3
5 4
3 5
4 5
5 5
5 6
4 7
6 7
5 8
7 6
7 7
7 8
8 7
8 5
7 4
7 5
8 3
7 2
8 1
7 0
7 1
6 1
5 1
6 2
5 2
4 1
4 2
5 3
3 0
6 4
3 8
1 8
2 7
3 7
1 6
1 7
0 7
1 2
1 3
1 4
1 5
5 6
6 7
6 8
8 9
8 10
8 11
11 12
11 13
11 14
11 15
15 16
15 17
17 18
17 19
19 20
19 21...

output:

1
2
3
2
4
3
1
2
1
3
1
3
2
2
3
1
4
2
2
1
1
3
4
2
3
1
2
2
4
1
2
3
1
2
3
4
1
2
1
3
3
4
3
2
1
3
1
2

result:

ok ...

Test #62:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

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

output:

2
1
3
1
1
2
3
2
1
2
1
4
2
3
1
2
2
1
3
2
1
4
2
4
1
3
1
2
3
2
1
2
1
3
3
2
3
1
3

result:

ok ...

Test #63:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

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

output:

1
2
3
2
2
4
3
1
2
1
3
3
1
2
1
3
2
1
4
3
1
2
3
1
4
2
3
1
2
2
1
3
4
1
1
3

result:

ok ...

Test #64:

score: 0
Accepted
time: 0ms
memory: 3632kb

input:

17 40
0 1
1 0
1 1
0 3
1 2
2 2
1 3
2 3
1 4
3 2
3 3
3 4
4 3
4 1
3 0
3 1
2 1
1 2
1 3
1 4
1 5
5 6
5 7
5 8
8 9
8 10
8 11
8 12
12 13
13 14
14 15
14 16
16 17
15 17
15 16
11 13
11 12
10 17
10 16
10 14
10 11
10 13
9 12
7 8
7 9
6 17
6 10
6 8
4 5
4 7
4 9
3 17
3 5
3 6
2 15
2 3
2 17

output:

1
2
3
2
4
2
1
3
4
4
1
2
3
1
3
2
1

result:

ok ...