QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#579232#3318. Four-ColoringzltAC ✓4ms4736kbC++141.9kb2024-09-21 10:49:522024-09-21 10:49:52

Judging History

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

  • [2024-09-21 10:49:52]
  • 评测
  • 测评结果:AC
  • 用时:4ms
  • 内存:4736kb
  • [2024-09-21 10:49:52]
  • 提交

answer

#include <bits/stdc++.h>
#define pb emplace_back
#define fst first
#define scd second
#define mkp make_pair
#define mems(a, x) memset((a), (x), sizeof(a))

using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 20050;

int n, m, ans[maxn];
pii b[maxn];
bool vis[maxn], mk[maxn];
vector<int> G[maxn];

struct node {
	int x, y, i;
} a[maxn];

void dfs(int u, int x, int y) {
	mk[u] = 1;
	for (int v : G[u]) {
		if (vis[v] && !mk[v] && (ans[v] == x || ans[v] == y)) {
			dfs(v, x, y);
		}
	}
}

void solve() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		scanf("%d%d", &a[i].x, &a[i].y);
		a[i].i = i;
		b[i] = mkp(a[i].x, a[i].y);
	}
	sort(a + 1, a + n + 1, [&](const node &a, const node &b) {
		return a.x > b.x || (a.x == b.x && a.y > b.y);
	});
	while (m--) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u].pb(v);
		G[v].pb(u);
	}
	for (int i = 1; i <= n; ++i) {
		int u = a[i].i, S = 0;
		vis[u] = 1;
		for (int v : G[u]) {
			if (vis[v]) {
				S |= (1 << ans[v]);
			}
		}
		if (S != 30) {
			ans[u] = 1;
			while (S & (1 << ans[u])) {
				++ans[u];
			}
			continue;
		}
		int v1 = -1, v2 = -1, v3 = -1, v4 = -1;
		for (int v : G[u]) {
			if (vis[v]) {
				if (b[v].fst == a[i].x) {
					v1 = v;
				} else if (b[v].fst - a[i].x == b[v].scd - a[i].y) {
					v2 = v;
				} else if (b[v].scd == a[i].y) {
					v3 = v;
				} else {
					v4 = v;
				}
			}
		}
		int x = ans[v1], y = ans[v3];
		mems(mk, 0);
		dfs(v1, x, y);
		if (mk[v3]) {
			mems(mk, 0);
			x = ans[v2];
			y = ans[v4];
			dfs(v2, x, y);
		}
		for (int j = 1; j <= n; ++j) {
			if (mk[j]) {
				ans[j] ^= x ^ y;
			}
		}
		ans[u] = x;
	}
	for (int i = 1; i <= n; ++i) {
		printf("%d\n", ans[i]);
	}
}

int main() {
	int T = 1;
	// scanf("%d", &T);
	while (T--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 4612kb

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:

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

result:

ok ...

Test #2:

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

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:

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

result:

ok ...

Test #3:

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

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:

4
3
1
2
3
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
3
1
1
3
2
2
1
1
2
3
...

result:

ok ...

Test #4:

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

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:

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

result:

ok ...

Test #5:

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

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:

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

result:

ok ...

Test #6:

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

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:

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

result:

ok ...

Test #7:

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

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
4
1
1
2
3
1
4
3
2
1
1
2
4
4
3
1
4
3
2
1
1
3
2
2
1
1
2
3
3
1
1
4
2
2
3
1
2
3
1
1
3
2
2
1
1
2
3
3
4
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
1
4
3
3
1
2
3
4
1
2
1
3
2
4
1
1
4
2
3
1
1
2
3
4
1
1
3
2
2
1
3
4
2
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
4
1
2
3
3
1
3
2
4
1
1
2
3
3
1
4
2
2
1
1
2
3
3
1
1
3
4
2
4
2
1
3
4
1
3
2
4
...

result:

ok ...

Test #8:

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

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:

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

result:

ok ...

Test #9:

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

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
4
1
3
4
3
1
1
3
2
2
1
1
2
3
4
1
1
3
2
2
1
1
2
3
3
1
1
3
2
2
1
2
3
3
1
4
3
2
1
4
2
3
4
3
2
1
4
1
1
4
2
2
1
1
2
4
4
1
4
2
2
3
1
2
3
1
1
3
4
4
2
1
4
3
3
2
1
4
3
3
1
2
2
3
3
4
1
1
3
3
2
4
4
1
1
3
2
2
1
1
2
3
3
4
1
3
2
1
1
2
4
4
3
1
4
2
1
2
3
1
3
2
3
4
1
2
1
1
3
4
2
3
4
2
1
4
2
1
4
1
1
4
2
3
3
2
4
4
1
...

result:

ok ...

Test #10:

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

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:

2
4
1
4
3
2
1
2
3
3
1
4
2
2
3
1
2
4
3
1
2
1
4
1
4
2
2
1
3
2
4
1
1
4
3
2
3
1
2
4
1
3
1
4
3
2
1
2
3
1
4
2
2
1
3
3
4
4
3
2
2
4
3
3
2
2
3
1
1
4
2
3
4
1
3
3
4
2
1
1
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
4
3
3
1
1
2
4
4
1
3
4
1
3
1
2
3
4
1
1
2
3
3
1
1
3
2
4
1
4
2
3
1
2
1
1
2
4
3
1
1
3
2
4
1
1
...

result:

ok ...

Test #11:

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

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:

2
4
1
1
4
3
1
2
3
2
1
1
2
3
4
3
1
4
2
3
3
1
2
4
2
4
3
1
1
4
2
1
4
3
3
4
2
2
1
3
3
2
4
3
1
1
2
2
1
3
3
2
4
1
2
3
3
1
1
3
2
2
1
1
2
3
3
4
1
3
2
1
1
2
4
3
1
1
4
2
2
1
3
2
1
3
1
4
3
2
3
1
1
3
2
1
1
4
2
3
2
1
3
4
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
1
4
2
2
3
1
2
1
1
2
3
3
1
1
3
2
2
1
1
4
3
...

result:

ok ...

Test #12:

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

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
1
2
4
1
3
3
2
4
1
2
3
3
1
1
3
2
4
2
1
3
3
4
4
3
2
1
1
2
3
3
1
1
4
3
2
1
1
3
2
4
1
1
2
3
4
4
3
1
2
4
4
1
3
3
4
2
3
4
1
4
2
1
3
4
4
3
1
2
4
3
2
4
3
1
1
3
2
2
1
1
2
3
3
1
1
3
4
2
1
4
2
2
1
3
1
2
1
4
4
2
2
4
1
1
2
3
1
2
4
3
3
2
1
1
4
1
2
3
3
2
1
1
3
4
2
4
1
2
3
3
1
4
3
2
4
1
2
3
3
1
1
3
2
2
1
4
2
3
1
...

result:

ok ...

Test #13:

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

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:

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

result:

ok ...

Test #14:

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

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
3
2
2
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
1
1
3
1
2
2
4
1
3
1
2
2
4
1
3
1
2
2
4
1
3
1
2
2
4
1
3
1
2
2
4
1
3
...

result:

ok ...

Test #15:

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

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:

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

result:

ok ...

Test #16:

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

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
1
3
2
3
4
1
3
2
4
1
1
4
2
2
1
3
1
2
2
1
4
3
2
4
2
1
3
1
2
2
4
1
1
2
3
1
2
2
4
3
1
2
3
4
1
4
3
2
1
2
2
4
1
1
2
3
1
4
2
1
3
2
1
2
4
3
2
1
1
2
3
3
1
1
4
3
2
1
4
3
4
2
1
4
4
1
2
3
3
4
2
1
3
2
3
4
4
1
3
2
2
3
4
4
2
1
3
2
4
3
4
2
2
1
3
2
3
2
4
4
2
3
3
1
2
2
4
3
4
2
2
4
3
2
1
3
1
2
3
1
3
3
4
2
1
2
1
3
...

result:

ok ...

Test #17:

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

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:

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

result:

ok ...

Test #18:

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

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
2
4
4
2
3
1
4
2
2
1
3
4
4
2
1
3
3
4
1
2
1
4
3
1
2
3
4
1
1
2
3
3
1
4
4
2
3
1
1
2
4
4
1
3
2
1
2
3
3
1
4
2
3
1
3
4
2
3
4
2
2
3
1
2
3
4
1
1
2
3
4
4
2
1
3
3
4
1
3
2
4
4
1
3
2
3
1
4
2
1
2
3
1
1
4
2
2
1
1
3
4
2
1
2
4
3
3
1
2
3
4
1
2
1
1
2
4
3
3
1
2
2
3
1
4
1
4
3
2
3
2
1
4
4
3
2
2
1
3
4
3
1
2
2
1
3
3
4
2
...

result:

ok ...

Test #19:

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

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:

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

result:

ok ...

Test #20:

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

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:

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

result:

ok ...

Test #21:

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

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
4
2
2
1
3
2
3
4
1
1
3
2
1
2
3
4
4
1
2
3
2
1
3
4
1
3
2
3
2
3
1
1
4
2
3
2
1
3
4
1
2
3
1
2
3
2
2
4
1
1
3
2
1
3
1
2
1
3
3
4
1
2
3
2
1
4
1
2
3
2
1
1
2
4
3
1
3
4
1
2
1
3
2
2
4
1
1
3
2
4
1
1
4
3
2
1
4
4
2
1
3
1
4
2
1
4
3
2
2
1
3
2
4
3
1
1
2
3
4
1
3
1
2
1
4
3
2
1
2
4
3
2
1
3
3
1
2
4
3
4
1
1
2
3
3
1
4
2
4
...

result:

ok ...

Test #22:

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

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:

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

result:

ok ...

Test #23:

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

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:

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

result:

ok ...

Test #24:

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

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
4
3
4
1
4
3
2
1
1
3
2
2
1
1
3
4
2
1
3
3
1
3
4
2
2
3
1
2
3
4
3
1
1
2
4
3
1
3
1
2
3
1
2
3
2
2
3
1
1
4
2
2
3
1
3
4
2
1
1
4
2
2
1
3
1
4
2
4
1
4
2
2
3
4
1
2
2
1
3
1
3
1
2
4
3
2
4
3
3
1
4
2
3
1
1
3
2
2
1
4
2
3
1
1
2
3
4
1
2
1
3
2
3
3
1
2
1
3
2
1
2
4
3
4
3
1
1
2
3
3
1
2
3
4
1
1
2
3
1
2
1
3
2
4
4
1
3
2
4
...

result:

ok ...

Test #25:

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

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:

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

result:

ok ...

Test #26:

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

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:

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

result:

ok ...

Test #27:

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

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:

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

result:

ok ...

Test #28:

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

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:

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

result:

ok ...

Test #29:

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

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:

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

result:

ok ...

Test #30:

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

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:

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

result:

ok ...

Test #31:

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

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
3
1
1
3
4
1
2
4
3
1
1
2
4
3
3
1
4
1
2
3
1
3
2
2
4
4
1
2
3
2
1
2
2
3
1
3
1
2
1
2
2
4
1
3
1
2
3
3
4
1
3
1
2
3
1
4
2
1
3
1
2
3
1
3
2
4
2
3
1
2
3
1
2
1
3
3
2
1
2
3
1
3
2
1
2
1
3
3
1
2
1
4
3
1
2
2
1
4
2
1
1
3
2
2
1
2
3
1
2
4
3
1
3
2
1
3
4
1
2
3
1
4
2
3
1
1
3
2
2
3
1
1
3
2
3
1
1
4
2
3
1
1
2
2
3
1
1
3
2
...

result:

ok ...

Test #32:

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

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:

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

result:

ok ...

Test #33:

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

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
1
2
2
1
4
2
4
1
3
1
1
2
4
1
2
3
3
4
2
2
1
3
4
2
1
3
4
2
1
3
3
1
2
2
3
2
3
4
1
2
1
3
4
4
1
3
2
2
3
1
1
4
2
4
3
3
1
2
4
2
1
1
3
4
2
1
4
2
3
1
1
2
3
4
1
4
4
2
3
1
4
1
2
2
3
1
4
1
4
2
2
3
1
1
2
4
4
3
1
2
2
3
4
2
1
3
2
3
4
2
3
1
4
2
1
1
3
2
2
4
1
4
2
3
2
1
3
3
2
1
3
1
4
2
4
1
3
4
2
3
2
1
4
3
1
2
1
4
3
...

result:

ok ...

Test #34:

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

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:

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

result:

ok ...

Test #35:

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

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
4
2
1
1
3
2
2
1
4
1
3
2
1
4
1
4
3
3
2
2
3
1
1
3
2
3
4
1
2
1
2
3
2
4
2
3
1
4
2
3
1
2
3
1
1
4
2
1
3
2
1
4
3
1
2
2
1
4
2
3
1
1
3
4
2
3
1
4
3
2
1
3
4
2
3
1
2
1
4
1
2
1
3
2
1
4
2
4
3
1
4
3
2
1
1
3
1
2
3
3
2
1
1
4
1
3
2
1
2
4
2
3
1
2
4
1
3
2
1
4
1
1
4
2
1
3
2
1
3
1
2
3
2
1
1
3
2
1
2
3
1
4
3
2
2
1
2
...

result:

ok ...

Test #36:

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

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:

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

result:

ok ...

Test #37:

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

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
3
4
2
1
3
3
4
2
2
1
4
2
3
2
1
3
2
4
1
3
3
2
1
3
1
2
1
4
2
3
3
2
1
1
2
4
3
2
4
1
1
2
3
3
4
1
1
2
4
3
2
1
1
2
3
4
3
1
4
3
2
2
1
3
3
2
4
2
1
1
3
2
1
4
2
3
3
2
1
1
4
3
4
2
1
2
1
4
3
4
2
1
3
2
3
1
2
2
4
4
2
1
3
1
3
2
4
2
3
1
2
1
3
2
1
4
1
3
3
3
4
1
2
3
1
2
3
2
3
1
3
2
1
2
3
1
3
2
1
2
3
4
3
1
2
1
...

result:

ok ...

Test #38:

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

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:

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

result:

ok ...

Test #39:

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

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:

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

result:

ok ...

Test #40:

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

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
4
3
1
4
2
3
1
3
1
2
1
2
3
1
2
2
3
1
3
4
3
2
1
2
2
1
3
1
2
2
4
1
3
4
1
2
4
1
3
1
1
2
3
4
1
2
4
3
1
2
3
1
2
3
2
1
1
4
2
3
1
2
3
1
2
3
4
1
2
3
3
1
2
2
1
3
2
3
1
2
2
1
3
1
1
3
2
4
3
3
2
1
2
2
4
3
1
2
3
1
4
4
3
1
2
3
3
1
2
1
1
2
2
2
1
1
3
2
2
3
1
3
2
1
2
3
1
3
3
4
1
2
3
1
3
2
1
2
2
4
1
1
3
2
3
1
4
1
2
...

result:

ok ...

Test #41:

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

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:

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

result:

ok ...

Test #42:

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

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:

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

result:

ok ...

Test #43:

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

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:

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

result:

ok ...

Test #44:

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

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:

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

result:

ok ...

Test #45:

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

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:

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

result:

ok ...

Test #46:

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

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:

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

result:

ok ...

Test #47:

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

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
4
2
1
3
2
3
1
1
2
4
1
3
2
3
1
3
2
2
1

result:

ok ...

Test #48:

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

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
4
3
4
2
1
3
2
1
2
1
4
1
3
2
3
1
4
2
2
1
3

result:

ok ...

Test #49:

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

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:

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

result:

ok ...

Test #50:

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

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:

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

result:

ok ...

Test #51:

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

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:

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

result:

ok ...

Test #52:

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

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:

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

result:

ok ...

Test #53:

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

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:

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

result:

ok ...

Test #54:

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

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:

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

result:

ok ...

Test #55:

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

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:

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

result:

ok ...

Test #56:

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

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:

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

result:

ok ...

Test #57:

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

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
1
2
4
1
2
1
3
1
2
4
1
3
2
3
1
3
1
2
3
1
4
2
3
1
1
3
2
4
1
1
2
2
3
2
4
1
3
1
4
2
3

result:

ok ...

Test #58:

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

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:

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

result:

ok ...

Test #59:

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

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:

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

result:

ok ...

Test #60:

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

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:

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

result:

ok ...

Test #61:

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

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
4
3
3
2
1
4
3
1
2
1
2
4
4
3
1
2
1
1
3
4
3
2
1
2
3
1
1
3
2
3
1
2
3
1
2
1
3
1
2
2
2
3
1
3
3
2
1

result:

ok ...

Test #62:

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

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:

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

result:

ok ...

Test #63:

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

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:

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

result:

ok ...

Test #64:

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

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:

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

result:

ok ...