QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#569822#1148. Gameiframe#42 59ms5964kbC++171.1kb2024-09-17 11:12:042024-09-17 11:12:05

Judging History

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

  • [2024-09-17 11:12:05]
  • 评测
  • 测评结果:42
  • 用时:59ms
  • 内存:5964kb
  • [2024-09-17 11:12:04]
  • 提交

answer

#include "game.h"

#include <iostream>

bool used[1500][1500];
bool vis[1500];
int n;

int root[1500];

int find(int i){
	if(root[i] < 0) return i;
	return root[i] = find(root[i]);
}

void merge(int a, int b){
	if(root[a] < root[b]) root[a] += root[b], root[b] = a;
	else root[b] += root[a], root[a] = b;
}

int left(int a, int b){
	int res = 0;
	for(int i=0; i<n; ++i)
		for(int j=i+1; j<n; ++j)
			if((find(i) == a && find(j) == b) ||
			   (find(i) == b && find(j) == a)) ++res;
	return res;
}

void initialize(int N) {
	n = N;
	for(int i=0; i<n; ++i) root[i] = -1;
}

bool dfs(int a, int b){
	if(a == b) return 1;
	if(!used[a][b]) return 1;
	vis[a] = 1;
	for(int i=0; i<n; ++i) if(!used[a][i] && a!=i && !vis[i])
		if(dfs(i, b)) return 1;
	return 0;
}

bool reachable(int a, int b){
	for(int i=0; i<n; ++i) vis[i] = 0;
	return dfs(a, b);
}

int hasEdge(int u, int v) {
	used[u][v] = 1, used[v][u] = 1;

	if(find(u) == find(v)) return 0;

	if(!reachable(u, v)){
		merge(find(u), find(v));
		return 1;
	}

	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 15
Accepted

Test #1:

score: 15
Accepted
time: 0ms
memory: 3736kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #2:

score: 15
Accepted
time: 0ms
memory: 3736kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #3:

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

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #4:

score: 15
Accepted
time: 0ms
memory: 3736kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #5:

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

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #6:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #7:

score: 15
Accepted
time: 0ms
memory: 3644kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #8:

score: 15
Accepted
time: 0ms
memory: 3700kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #9:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #10:

score: 15
Accepted
time: 0ms
memory: 3836kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #11:

score: 15
Accepted
time: 0ms
memory: 3648kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #12:

score: 15
Accepted
time: 0ms
memory: 3732kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #13:

score: 15
Accepted
time: 0ms
memory: 3820kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #14:

score: 15
Accepted
time: 0ms
memory: 3656kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #15:

score: 15
Accepted
time: 0ms
memory: 3648kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #16:

score: 15
Accepted
time: 0ms
memory: 3776kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #17:

score: 15
Accepted
time: 0ms
memory: 3796kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #18:

score: 15
Accepted
time: 0ms
memory: 3844kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #19:

score: 15
Accepted
time: 0ms
memory: 3780kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #20:

score: 15
Accepted
time: 0ms
memory: 3716kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #21:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #22:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #23:

score: 15
Accepted
time: 0ms
memory: 3716kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #24:

score: 15
Accepted
time: 0ms
memory: 3736kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Subtask #2:

score: 27
Accepted

Test #25:

score: 27
Accepted
time: 0ms
memory: 3792kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #26:

score: 27
Accepted
time: 0ms
memory: 3776kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #27:

score: 27
Accepted
time: 0ms
memory: 3748kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #28:

score: 27
Accepted
time: 0ms
memory: 3700kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #29:

score: 27
Accepted
time: 0ms
memory: 3648kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #30:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #31:

score: 27
Accepted
time: 0ms
memory: 3840kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #32:

score: 27
Accepted
time: 0ms
memory: 3700kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #33:

score: 27
Accepted
time: 0ms
memory: 3732kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #34:

score: 27
Accepted
time: 0ms
memory: 3840kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #35:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #36:

score: 27
Accepted
time: 0ms
memory: 3796kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #37:

score: 27
Accepted
time: 0ms
memory: 3732kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #38:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #39:

score: 27
Accepted
time: 0ms
memory: 3648kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #40:

score: 27
Accepted
time: 0ms
memory: 3716kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #41:

score: 27
Accepted
time: 0ms
memory: 3700kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #42:

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

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #43:

score: 27
Accepted
time: 0ms
memory: 3840kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #44:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #45:

score: 27
Accepted
time: 0ms
memory: 3776kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #46:

score: 27
Accepted
time: 0ms
memory: 3652kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #47:

score: 27
Accepted
time: 0ms
memory: 3756kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #48:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #49:

score: 27
Accepted
time: 0ms
memory: 3880kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #50:

score: 27
Accepted
time: 0ms
memory: 3780kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #51:

score: 27
Accepted
time: 0ms
memory: 5916kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #52:

score: 27
Accepted
time: 0ms
memory: 3780kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #53:

score: 27
Accepted
time: 0ms
memory: 3784kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #54:

score: 27
Accepted
time: 0ms
memory: 3780kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #55:

score: 27
Accepted
time: 0ms
memory: 3840kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #56:

score: 27
Accepted
time: 0ms
memory: 3912kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #57:

score: 27
Accepted
time: 0ms
memory: 3840kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #58:

score: 27
Accepted
time: 1ms
memory: 3948kb

input:

80
77 16
16 63
9 36
68 73
61 40
16 6
9 41
53 62
10 2
50 40
24 17
14 29
56 4
24 54
26 33
75 30
47 20
67 16
48 8
60 64
23 35
51 53
5 41
38 58
58 16
30 78
73 75
38 25
36 13
62 74
48 78
12 43
7 19
78 36
78 70
37 1
44 8
19 18
78 64
50 3
67 0
77 8
73 76
24 29
28 78
77 72
1 29
64 10
24 30
40 3
17 79
18 61
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #59:

score: 27
Accepted
time: 1ms
memory: 3912kb

input:

80
24 7
17 55
38 10
45 34
35 11
1 0
33 5
57 78
33 30
65 59
14 79
2 79
54 7
35 79
30 10
76 11
77 79
73 16
24 61
73 36
59 73
30 79
72 5
52 23
46 58
3 42
44 17
29 41
24 40
74 48
38 58
69 23
53 70
43 27
47 75
63 14
55 18
19 77
27 72
61 75
0 26
32 75
47 25
74 77
15 50
20 56
5 37
11 58
11 26
15 18
74 57
6...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #60:

score: 27
Accepted
time: 1ms
memory: 3852kb

input:

80
13 20
13 45
60 44
66 15
69 25
25 15
48 11
47 27
57 0
53 47
70 35
54 38
27 21
27 58
39 23
35 32
45 29
43 75
37 15
67 8
69 63
25 71
18 24
50 66
28 13
16 29
10 78
26 38
50 11
0 54
67 44
28 25
61 62
43 54
22 38
31 27
31 24
5 7
53 61
21 11
78 6
0 73
79 14
63 39
52 58
25 20
16 25
46 59
30 47
24 11
33 5...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #61:

score: 27
Accepted
time: 1ms
memory: 3908kb

input:

80
13 33
50 68
36 7
44 10
41 44
62 1
64 16
8 77
76 39
58 70
62 72
57 16
63 45
36 64
17 47
50 11
72 36
39 45
66 14
65 78
62 66
22 14
45 7
30 3
79 25
25 27
53 13
10 19
74 12
50 33
52 11
14 52
2 57
27 63
9 75
11 8
37 68
23 64
52 34
50 59
44 53
34 55
78 53
46 70
32 71
7 14
0 76
54 21
28 5
9 1
56 49
55 3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #62:

score: 27
Accepted
time: 1ms
memory: 3888kb

input:

80
39 45
57 14
48 65
61 77
35 3
16 54
71 25
47 16
36 50
22 29
54 70
60 74
26 46
37 5
53 0
64 19
24 45
8 74
3 1
62 5
39 6
58 79
30 16
36 77
27 28
55 32
71 3
59 64
61 38
15 41
12 66
51 46
66 27
29 76
69 72
9 23
50 75
56 71
20 61
77 12
29 4
31 43
0 50
64 62
54 34
39 2
12 78
79 25
19 0
21 38
2 12
63 5
7...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #63:

score: 27
Accepted
time: 1ms
memory: 3852kb

input:

80
71 0
46 57
0 28
60 48
67 55
26 66
41 66
24 18
57 62
72 19
34 7
21 69
7 14
67 51
27 79
17 58
31 34
36 2
29 18
3 74
43 23
34 71
67 37
49 42
46 50
33 2
0 64
75 72
65 18
23 56
66 49
33 42
21 49
49 5
12 66
13 6
52 54
75 44
71 47
45 76
16 38
73 35
63 18
16 52
15 76
71 6
60 27
37 47
2 4
1 41
54 42
15 39...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #64:

score: 27
Accepted
time: 1ms
memory: 3980kb

input:

80
71 21
46 38
22 40
47 64
1 71
5 62
53 15
71 53
52 28
32 16
14 4
73 27
0 57
43 63
60 15
54 44
0 68
72 19
79 65
65 26
52 30
45 26
71 50
69 13
67 26
57 37
79 53
61 17
79 78
6 74
66 2
11 72
11 70
61 41
6 27
30 62
35 15
69 59
68 32
44 2
27 17
71 7
52 64
11 76
18 35
32 48
66 31
44 48
58 47
78 33
15 8
4 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #65:

score: 27
Accepted
time: 1ms
memory: 3828kb

input:

80
19 72
39 26
33 59
14 4
22 54
0 72
45 15
44 61
50 23
38 40
5 53
23 10
77 54
3 20
78 15
64 9
42 11
16 64
37 66
21 17
76 15
23 18
12 54
74 29
21 20
10 29
77 24
25 44
79 55
76 71
1 37
26 1
40 16
33 44
42 21
49 15
40 61
20 11
60 61
0 23
77 32
70 34
39 44
55 26
6 28
42 25
13 23
18 32
49 50
44 54
6 46
1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #66:

score: 27
Accepted
time: 1ms
memory: 3764kb

input:

80
54 59
47 66
0 75
23 0
33 17
13 68
29 38
31 6
9 59
71 78
54 51
22 6
60 69
58 24
50 72
19 77
12 64
11 22
54 55
47 5
33 52
51 24
37 42
26 8
65 49
66 12
46 31
47 50
26 68
51 50
71 37
59 20
47 36
52 58
42 50
61 7
65 16
33 75
17 18
71 45
57 7
42 73
44 3
49 14
12 72
78 61
0 36
58 55
14 59
75 26
10 62
40...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #67:

score: 27
Accepted
time: 2ms
memory: 3960kb

input:

80
1 0
0 2
0 3
0 4
5 0
6 0
0 7
0 8
9 0
10 0
11 0
0 12
13 0
0 14
0 15
16 0
17 0
18 0
19 0
0 20
0 21
0 22
0 23
0 24
25 0
0 26
0 27
28 0
29 0
0 30
0 31
0 32
0 33
34 0
35 0
36 0
37 0
38 0
39 0
40 0
41 0
42 0
0 43
0 44
0 45
46 0
0 47
48 0
0 49
50 0
0 51
0 52
0 53
54 0
55 0
56 0
0 57
58 0
59 0
60 0
0 61
0...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #68:

score: 27
Accepted
time: 1ms
memory: 3892kb

input:

80
79 78
77 79
78 77
79 76
78 76
77 76
79 75
75 78
77 75
76 75
74 79
74 78
77 74
74 76
75 74
79 73
73 78
77 73
73 76
75 73
73 74
72 79
78 72
77 72
72 76
72 75
74 72
72 73
71 79
78 71
71 77
76 71
71 75
74 71
71 73
72 71
79 70
70 78
70 77
70 76
70 75
70 74
73 70
70 72
70 71
69 79
69 78
69 77
69 76
69 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #69:

score: 27
Accepted
time: 1ms
memory: 3888kb

input:

80
59 52
23 59
37 31
7 72
69 54
23 27
37 46
61 57
9 23
59 31
59 73
6 54
42 17
0 3
52 58
67 39
21 72
59 30
73 35
37 75
78 31
75 77
24 3
34 19
59 14
10 3
42 33
72 48
49 44
70 60
21 17
1 47
33 22
34 29
29 70
1 8
35 66
63 29
22 10
15 26
60 4
36 52
48 53
2 49
45 11
14 72
64 5
1 40
45 19
15 7
63 26
42 65
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #70:

score: 27
Accepted
time: 1ms
memory: 3948kb

input:

80
29 59
7 20
36 43
27 1
39 6
51 50
11 53
15 69
25 22
54 44
54 28
64 23
51 66
11 55
65 37
2 57
76 45
73 45
5 11
34 75
28 41
54 19
31 73
70 32
45 55
43 68
76 29
5 52
12 56
18 70
14 15
50 5
77 11
54 25
20 26
70 68
59 56
76 19
29 26
41 79
12 8
49 39
15 1
38 14
14 46
72 70
59 50
46 13
44 67
65 36
45 33
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #71:

score: 27
Accepted
time: 1ms
memory: 3956kb

input:

80
74 35
75 43
6 17
21 64
17 52
70 31
63 3
57 42
67 31
48 9
37 44
79 72
54 53
32 58
9 13
59 54
58 51
38 10
52 44
79 64
45 52
41 39
59 73
36 20
72 33
42 66
69 55
8 79
15 27
1 3
22 37
38 23
52 16
60 40
69 28
16 67
58 72
39 12
50 13
50 62
69 32
77 37
45 37
51 62
31 20
42 75
35 11
0 68
49 16
53 37
67 33...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #72:

score: 27
Accepted
time: 1ms
memory: 3816kb

input:

80
26 54
22 24
26 9
7 34
39 57
46 32
8 21
9 40
57 56
27 11
69 22
15 64
7 68
4 35
57 11
2 0
32 40
24 31
37 52
36 38
48 6
29 71
50 32
52 49
79 31
53 68
78 56
22 43
55 75
53 20
64 32
22 48
66 77
31 17
11 58
11 69
35 14
18 79
67 55
19 44
61 10
33 74
63 0
70 29
1 77
22 4
10 3
47 68
55 41
59 4
44 28
18 62...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #73:

score: 27
Accepted
time: 1ms
memory: 3952kb

input:

80
61 51
46 16
29 43
67 77
25 53
62 46
77 58
25 71
69 22
68 65
70 61
0 65
14 9
9 37
52 30
19 17
70 53
76 68
76 9
23 71
43 64
77 7
10 77
4 42
40 55
28 10
14 16
4 32
1 49
14 79
23 24
69 2
57 31
7 2
38 54
76 33
20 74
53 11
68 57
50 64
42 47
61 40
24 58
31 69
35 46
7 31
11 50
7 47
22 26
15 64
9 36
76 78...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #74:

score: 27
Accepted
time: 1ms
memory: 3892kb

input:

80
10 34
47 33
72 68
8 27
63 62
59 8
74 8
47 36
37 24
53 49
34 77
41 49
54 18
4 5
12 65
27 77
68 15
53 78
28 70
74 36
65 55
12 78
57 33
36 65
54 27
5 39
63 45
78 62
28 33
77 36
4 54
40 57
34 63
65 47
55 37
34 17
70 17
27 74
24 39
9 47
27 0
12 72
77 45
65 28
12 45
38 10
34 4
77 37
53 8
45 36
74 39
27...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #75:

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

input:

80
15 35
37 41
35 8
14 67
55 66
36 66
57 40
15 59
14 30
40 23
58 43
43 18
54 18
59 77
15 3
79 23
49 37
66 16
37 58
57 30
30 66
19 40
55 63
27 6
41 49
15 51
27 54
3 54
15 63
63 49
8 33
63 19
51 66
8 15
49 56
45 8
23 30
23 57
48 35
49 54
49 10
33 57
16 19
19 48
8 27
63 3
66 46
71 18
36 30
51 8
33 59
2...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #76:

score: 27
Accepted
time: 1ms
memory: 3944kb

input:

80
40 75
40 39
35 16
26 78
25 34
26 15
21 25
17 53
47 38
68 33
15 40
31 74
33 56
56 65
29 34
74 52
59 74
36 53
70 0
58 25
33 39
57 56
41 4
68 22
16 17
39 53
47 30
64 31
17 8
64 57
47 57
27 19
41 38
27 51
68 51
38 57
57 27
33 27
23 78
70 23
30 35
69 64
65 68
30 37
68 48
56 58
70 69
0 78
22 21
36 35
3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #77:

score: 27
Accepted
time: 1ms
memory: 3952kb

input:

80
66 60
74 16
7 43
11 60
55 75
78 61
78 11
6 75
77 73
36 41
11 44
16 40
15 27
2 64
75 74
36 78
74 46
41 46
44 23
75 79
45 75
13 27
5 62
64 60
55 16
7 36
6 27
44 32
43 5
8 41
2 6
5 36
73 45
40 2
60 27
15 13
75 8
44 64
40 46
44 79
11 62
41 15
11 30
2 27
32 73
11 36
7 77
6 32
43 77
8 30
2 45
23 64
5 3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #78:

score: 27
Accepted
time: 1ms
memory: 3848kb

input:

80
26 38
71 47
15 52
70 44
72 66
25 23
31 9
44 71
6 79
59 49
6 38
71 38
71 25
25 52
73 60
26 44
25 26
57 15
26 2
57 59
73 5
5 72
70 77
54 26
49 57
71 57
5 41
2 6
27 6
31 63
60 3
25 45
41 27
32 59
23 52
79 9
77 38
41 14
26 72
2 52
56 15
23 27
72 9
70 32
32 73
6 25
14 77
27 70
25 54
77 30
2 45
60 6
70...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Subtask #3:

score: 0
Time Limit Exceeded

Test #79:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #80:

score: 58
Accepted
time: 0ms
memory: 3776kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #81:

score: 58
Accepted
time: 0ms
memory: 3796kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #82:

score: 58
Accepted
time: 0ms
memory: 3796kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #83:

score: 58
Accepted
time: 0ms
memory: 3736kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #84:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #85:

score: 58
Accepted
time: 0ms
memory: 3780kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #86:

score: 58
Accepted
time: 0ms
memory: 3840kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #87:

score: 58
Accepted
time: 0ms
memory: 3736kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #88:

score: 58
Accepted
time: 0ms
memory: 3740kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #89:

score: 58
Accepted
time: 0ms
memory: 3648kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #90:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #91:

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

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #92:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #93:

score: 58
Accepted
time: 0ms
memory: 3792kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #94:

score: 58
Accepted
time: 0ms
memory: 3776kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #95:

score: 58
Accepted
time: 0ms
memory: 3648kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #96:

score: 58
Accepted
time: 0ms
memory: 3656kb

input:

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

output:

0
0
1
0
1
1

result:

ok correct

Test #97:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #98:

score: 58
Accepted
time: 0ms
memory: 3840kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #99:

score: 58
Accepted
time: 0ms
memory: 3840kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #100:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #101:

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

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #102:

score: 58
Accepted
time: 0ms
memory: 3732kb

input:

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

output:

0
0
0
1
1
1

result:

ok correct

Test #103:

score: 58
Accepted
time: 0ms
memory: 3912kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #104:

score: 58
Accepted
time: 0ms
memory: 3824kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #105:

score: 58
Accepted
time: 0ms
memory: 3836kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #106:

score: 58
Accepted
time: 0ms
memory: 3844kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #107:

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

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #108:

score: 58
Accepted
time: 0ms
memory: 3912kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #109:

score: 58
Accepted
time: 0ms
memory: 3824kb

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #110:

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

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #111:

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

input:

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

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #112:

score: 58
Accepted
time: 0ms
memory: 3764kb

input:

80
77 16
16 63
9 36
68 73
61 40
16 6
9 41
53 62
10 2
50 40
24 17
14 29
56 4
24 54
26 33
75 30
47 20
67 16
48 8
60 64
23 35
51 53
5 41
38 58
58 16
30 78
73 75
38 25
36 13
62 74
48 78
12 43
7 19
78 36
78 70
37 1
44 8
19 18
78 64
50 3
67 0
77 8
73 76
24 29
28 78
77 72
1 29
64 10
24 30
40 3
17 79
18 61
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #113:

score: 58
Accepted
time: 1ms
memory: 3904kb

input:

80
24 7
17 55
38 10
45 34
35 11
1 0
33 5
57 78
33 30
65 59
14 79
2 79
54 7
35 79
30 10
76 11
77 79
73 16
24 61
73 36
59 73
30 79
72 5
52 23
46 58
3 42
44 17
29 41
24 40
74 48
38 58
69 23
53 70
43 27
47 75
63 14
55 18
19 77
27 72
61 75
0 26
32 75
47 25
74 77
15 50
20 56
5 37
11 58
11 26
15 18
74 57
6...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #114:

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

input:

80
13 20
13 45
60 44
66 15
69 25
25 15
48 11
47 27
57 0
53 47
70 35
54 38
27 21
27 58
39 23
35 32
45 29
43 75
37 15
67 8
69 63
25 71
18 24
50 66
28 13
16 29
10 78
26 38
50 11
0 54
67 44
28 25
61 62
43 54
22 38
31 27
31 24
5 7
53 61
21 11
78 6
0 73
79 14
63 39
52 58
25 20
16 25
46 59
30 47
24 11
33 5...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #115:

score: 58
Accepted
time: 1ms
memory: 3956kb

input:

80
13 33
50 68
36 7
44 10
41 44
62 1
64 16
8 77
76 39
58 70
62 72
57 16
63 45
36 64
17 47
50 11
72 36
39 45
66 14
65 78
62 66
22 14
45 7
30 3
79 25
25 27
53 13
10 19
74 12
50 33
52 11
14 52
2 57
27 63
9 75
11 8
37 68
23 64
52 34
50 59
44 53
34 55
78 53
46 70
32 71
7 14
0 76
54 21
28 5
9 1
56 49
55 3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #116:

score: 58
Accepted
time: 1ms
memory: 3768kb

input:

80
39 45
57 14
48 65
61 77
35 3
16 54
71 25
47 16
36 50
22 29
54 70
60 74
26 46
37 5
53 0
64 19
24 45
8 74
3 1
62 5
39 6
58 79
30 16
36 77
27 28
55 32
71 3
59 64
61 38
15 41
12 66
51 46
66 27
29 76
69 72
9 23
50 75
56 71
20 61
77 12
29 4
31 43
0 50
64 62
54 34
39 2
12 78
79 25
19 0
21 38
2 12
63 5
7...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #117:

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

input:

80
71 0
46 57
0 28
60 48
67 55
26 66
41 66
24 18
57 62
72 19
34 7
21 69
7 14
67 51
27 79
17 58
31 34
36 2
29 18
3 74
43 23
34 71
67 37
49 42
46 50
33 2
0 64
75 72
65 18
23 56
66 49
33 42
21 49
49 5
12 66
13 6
52 54
75 44
71 47
45 76
16 38
73 35
63 18
16 52
15 76
71 6
60 27
37 47
2 4
1 41
54 42
15 39...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #118:

score: 58
Accepted
time: 1ms
memory: 3852kb

input:

80
71 21
46 38
22 40
47 64
1 71
5 62
53 15
71 53
52 28
32 16
14 4
73 27
0 57
43 63
60 15
54 44
0 68
72 19
79 65
65 26
52 30
45 26
71 50
69 13
67 26
57 37
79 53
61 17
79 78
6 74
66 2
11 72
11 70
61 41
6 27
30 62
35 15
69 59
68 32
44 2
27 17
71 7
52 64
11 76
18 35
32 48
66 31
44 48
58 47
78 33
15 8
4 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #119:

score: 58
Accepted
time: 1ms
memory: 3896kb

input:

80
19 72
39 26
33 59
14 4
22 54
0 72
45 15
44 61
50 23
38 40
5 53
23 10
77 54
3 20
78 15
64 9
42 11
16 64
37 66
21 17
76 15
23 18
12 54
74 29
21 20
10 29
77 24
25 44
79 55
76 71
1 37
26 1
40 16
33 44
42 21
49 15
40 61
20 11
60 61
0 23
77 32
70 34
39 44
55 26
6 28
42 25
13 23
18 32
49 50
44 54
6 46
1...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #120:

score: 58
Accepted
time: 1ms
memory: 3888kb

input:

80
54 59
47 66
0 75
23 0
33 17
13 68
29 38
31 6
9 59
71 78
54 51
22 6
60 69
58 24
50 72
19 77
12 64
11 22
54 55
47 5
33 52
51 24
37 42
26 8
65 49
66 12
46 31
47 50
26 68
51 50
71 37
59 20
47 36
52 58
42 50
61 7
65 16
33 75
17 18
71 45
57 7
42 73
44 3
49 14
12 72
78 61
0 36
58 55
14 59
75 26
10 62
40...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #121:

score: 58
Accepted
time: 2ms
memory: 3764kb

input:

80
1 0
0 2
0 3
0 4
5 0
6 0
0 7
0 8
9 0
10 0
11 0
0 12
13 0
0 14
0 15
16 0
17 0
18 0
19 0
0 20
0 21
0 22
0 23
0 24
25 0
0 26
0 27
28 0
29 0
0 30
0 31
0 32
0 33
34 0
35 0
36 0
37 0
38 0
39 0
40 0
41 0
42 0
0 43
0 44
0 45
46 0
0 47
48 0
0 49
50 0
0 51
0 52
0 53
54 0
55 0
56 0
0 57
58 0
59 0
60 0
0 61
0...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #122:

score: 58
Accepted
time: 1ms
memory: 3828kb

input:

80
79 78
77 79
78 77
79 76
78 76
77 76
79 75
75 78
77 75
76 75
74 79
74 78
77 74
74 76
75 74
79 73
73 78
77 73
73 76
75 73
73 74
72 79
78 72
77 72
72 76
72 75
74 72
72 73
71 79
78 71
71 77
76 71
71 75
74 71
71 73
72 71
79 70
70 78
70 77
70 76
70 75
70 74
73 70
70 72
70 71
69 79
69 78
69 77
69 76
69 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #123:

score: 58
Accepted
time: 1ms
memory: 3848kb

input:

80
59 52
23 59
37 31
7 72
69 54
23 27
37 46
61 57
9 23
59 31
59 73
6 54
42 17
0 3
52 58
67 39
21 72
59 30
73 35
37 75
78 31
75 77
24 3
34 19
59 14
10 3
42 33
72 48
49 44
70 60
21 17
1 47
33 22
34 29
29 70
1 8
35 66
63 29
22 10
15 26
60 4
36 52
48 53
2 49
45 11
14 72
64 5
1 40
45 19
15 7
63 26
42 65
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #124:

score: 58
Accepted
time: 1ms
memory: 3948kb

input:

80
29 59
7 20
36 43
27 1
39 6
51 50
11 53
15 69
25 22
54 44
54 28
64 23
51 66
11 55
65 37
2 57
76 45
73 45
5 11
34 75
28 41
54 19
31 73
70 32
45 55
43 68
76 29
5 52
12 56
18 70
14 15
50 5
77 11
54 25
20 26
70 68
59 56
76 19
29 26
41 79
12 8
49 39
15 1
38 14
14 46
72 70
59 50
46 13
44 67
65 36
45 33
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #125:

score: 58
Accepted
time: 1ms
memory: 3848kb

input:

80
74 35
75 43
6 17
21 64
17 52
70 31
63 3
57 42
67 31
48 9
37 44
79 72
54 53
32 58
9 13
59 54
58 51
38 10
52 44
79 64
45 52
41 39
59 73
36 20
72 33
42 66
69 55
8 79
15 27
1 3
22 37
38 23
52 16
60 40
69 28
16 67
58 72
39 12
50 13
50 62
69 32
77 37
45 37
51 62
31 20
42 75
35 11
0 68
49 16
53 37
67 33...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #126:

score: 58
Accepted
time: 1ms
memory: 3888kb

input:

80
26 54
22 24
26 9
7 34
39 57
46 32
8 21
9 40
57 56
27 11
69 22
15 64
7 68
4 35
57 11
2 0
32 40
24 31
37 52
36 38
48 6
29 71
50 32
52 49
79 31
53 68
78 56
22 43
55 75
53 20
64 32
22 48
66 77
31 17
11 58
11 69
35 14
18 79
67 55
19 44
61 10
33 74
63 0
70 29
1 77
22 4
10 3
47 68
55 41
59 4
44 28
18 62...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #127:

score: 58
Accepted
time: 1ms
memory: 3756kb

input:

80
61 51
46 16
29 43
67 77
25 53
62 46
77 58
25 71
69 22
68 65
70 61
0 65
14 9
9 37
52 30
19 17
70 53
76 68
76 9
23 71
43 64
77 7
10 77
4 42
40 55
28 10
14 16
4 32
1 49
14 79
23 24
69 2
57 31
7 2
38 54
76 33
20 74
53 11
68 57
50 64
42 47
61 40
24 58
31 69
35 46
7 31
11 50
7 47
22 26
15 64
9 36
76 78...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #128:

score: 58
Accepted
time: 1ms
memory: 3904kb

input:

80
10 34
47 33
72 68
8 27
63 62
59 8
74 8
47 36
37 24
53 49
34 77
41 49
54 18
4 5
12 65
27 77
68 15
53 78
28 70
74 36
65 55
12 78
57 33
36 65
54 27
5 39
63 45
78 62
28 33
77 36
4 54
40 57
34 63
65 47
55 37
34 17
70 17
27 74
24 39
9 47
27 0
12 72
77 45
65 28
12 45
38 10
34 4
77 37
53 8
45 36
74 39
27...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #129:

score: 58
Accepted
time: 1ms
memory: 3948kb

input:

80
15 35
37 41
35 8
14 67
55 66
36 66
57 40
15 59
14 30
40 23
58 43
43 18
54 18
59 77
15 3
79 23
49 37
66 16
37 58
57 30
30 66
19 40
55 63
27 6
41 49
15 51
27 54
3 54
15 63
63 49
8 33
63 19
51 66
8 15
49 56
45 8
23 30
23 57
48 35
49 54
49 10
33 57
16 19
19 48
8 27
63 3
66 46
71 18
36 30
51 8
33 59
2...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #130:

score: 58
Accepted
time: 1ms
memory: 3944kb

input:

80
40 75
40 39
35 16
26 78
25 34
26 15
21 25
17 53
47 38
68 33
15 40
31 74
33 56
56 65
29 34
74 52
59 74
36 53
70 0
58 25
33 39
57 56
41 4
68 22
16 17
39 53
47 30
64 31
17 8
64 57
47 57
27 19
41 38
27 51
68 51
38 57
57 27
33 27
23 78
70 23
30 35
69 64
65 68
30 37
68 48
56 58
70 69
0 78
22 21
36 35
3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #131:

score: 58
Accepted
time: 1ms
memory: 5784kb

input:

80
66 60
74 16
7 43
11 60
55 75
78 61
78 11
6 75
77 73
36 41
11 44
16 40
15 27
2 64
75 74
36 78
74 46
41 46
44 23
75 79
45 75
13 27
5 62
64 60
55 16
7 36
6 27
44 32
43 5
8 41
2 6
5 36
73 45
40 2
60 27
15 13
75 8
44 64
40 46
44 79
11 62
41 15
11 30
2 27
32 73
11 36
7 77
6 32
43 77
8 30
2 45
23 64
5 3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #132:

score: 58
Accepted
time: 1ms
memory: 3848kb

input:

80
26 38
71 47
15 52
70 44
72 66
25 23
31 9
44 71
6 79
59 49
6 38
71 38
71 25
25 52
73 60
26 44
25 26
57 15
26 2
57 59
73 5
5 72
70 77
54 26
49 57
71 57
5 41
2 6
27 6
31 63
60 3
25 45
41 27
32 59
23 52
79 9
77 38
41 14
26 72
2 52
56 15
23 27
72 9
70 32
32 73
6 25
14 77
27 70
25 54
77 30
2 45
60 6
70...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #133:

score: 58
Accepted
time: 59ms
memory: 5964kb

input:

514
401 94
52 422
361 428
224 345
410 259
280 109
37 171
381 442
441 55
110 68
395 106
108 248
362 0
201 349
261 393
452 159
503 402
389 340
311 294
32 495
172 242
14 312
48 248
4 277
441 379
272 296
309 322
264 44
355 104
72 512
349 382
114 487
66 366
214 4
233 181
109 7
337 280
426 393
504 5
377 3...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #134:

score: 58
Accepted
time: 56ms
memory: 4616kb

input:

514
89 166
227 81
274 479
435 388
224 385
115 350
269 303
486 445
175 369
249 11
34 368
484 347
429 373
265 178
338 184
459 287
291 26
475 361
499 58
100 292
261 256
77 184
447 509
13 81
304 262
307 391
241 261
233 95
199 30
512 50
83 98
400 32
138 162
402 153
492 505
292 497
146 427
362 284
26 126
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #135:

score: 58
Accepted
time: 53ms
memory: 4608kb

input:

514
276 477
105 384
184 260
179 334
69 427
0 9
232 159
79 317
377 226
108 183
294 410
87 219
136 197
303 407
500 443
187 45
292 28
10 127
235 244
481 407
267 350
183 165
319 179
375 438
391 52
322 432
468 245
65 374
85 348
435 424
303 191
414 350
299 34
375 378
475 94
204 473
84 268
26 273
134 224
4...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #136:

score: 58
Accepted
time: 51ms
memory: 4508kb

input:

514
368 424
236 247
405 492
203 309
222 174
141 77
348 284
260 130
300 54
365 137
242 17
46 296
242 19
223 334
107 319
21 116
458 242
432 41
158 362
310 169
420 94
499 449
74 423
123 429
334 176
93 152
231 193
437 114
73 395
314 78
204 359
87 370
174 5
372 427
193 447
509 283
358 287
266 328
466 247...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #137:

score: 58
Accepted
time: 54ms
memory: 4488kb

input:

514
13 325
275 329
253 201
328 507
369 177
400 451
114 173
112 425
67 414
219 333
420 328
18 207
470 250
66 117
13 468
395 453
104 101
277 39
311 126
357 444
420 38
440 92
395 194
208 429
307 27
251 366
78 470
231 87
414 413
413 232
127 218
275 214
347 244
437 188
85 495
64 372
85 488
139 93
222 187...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #138:

score: 58
Accepted
time: 52ms
memory: 4424kb

input:

514
212 186
264 171
442 238
469 466
380 322
287 158
199 276
160 465
425 226
101 491
200 153
95 375
395 247
279 423
53 165
224 457
75 279
164 129
161 462
437 46
203 253
57 239
145 252
192 356
159 414
217 299
46 302
88 100
54 508
149 88
185 106
79 93
245 290
227 401
215 39
39 15
472 229
59 444
204 48
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #139:

score: 58
Accepted
time: 56ms
memory: 4544kb

input:

514
259 222
118 89
113 168
293 429
298 419
29 72
435 167
371 115
416 67
186 469
235 488
96 362
311 23
177 268
496 202
285 127
205 15
218 229
184 208
31 147
450 284
476 211
430 48
247 239
93 115
185 234
6 383
163 508
401 41
160 30
96 441
54 491
5 422
304 260
251 378
297 244
116 27
265 150
470 274
133...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #140:

score: 58
Accepted
time: 51ms
memory: 4612kb

input:

514
442 162
127 482
26 10
255 213
335 34
458 13
504 64
15 227
461 210
465 373
144 423
100 438
455 10
43 369
124 162
349 398
139 322
239 273
138 346
315 33
157 372
478 487
106 148
458 492
264 337
133 214
151 65
475 513
170 130
513 11
355 434
74 254
251 390
511 410
262 339
42 179
433 248
331 425
45 41...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #141:

score: 58
Accepted
time: 55ms
memory: 4608kb

input:

514
65 218
458 451
171 92
185 76
156 258
329 300
387 480
43 477
421 229
351 280
331 257
192 85
335 31
347 124
3 443
50 295
331 492
84 417
78 157
249 259
159 360
353 101
374 211
484 7
88 403
419 85
434 223
177 275
302 260
20 208
279 237
351 495
119 65
409 476
430 462
501 503
421 116
87 343
198 157
50...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok correct

Test #142:

score: 0
Time Limit Exceeded

input:

514
1 0
0 2
0 3
0 4
5 0
6 0
0 7
0 8
9 0
10 0
11 0
0 12
13 0
0 14
0 15
16 0
17 0
18 0
19 0
0 20
0 21
0 22
0 23
0 24
25 0
0 26
0 27
28 0
29 0
0 30
0 31
0 32
0 33
34 0
35 0
36 0
37 0
38 0
39 0
40 0
41 0
42 0
0 43
0 44
0 45
46 0
0 47
48 0
0 49
50 0
0 51
0 52
0 53
54 0
55 0
56 0
0 57
58 0
59 0
60 0
0 61
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result: