QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#117983#3318. Four-ColoringCrysflyAC ✓6ms13996kbC++172.0kb2023-07-02 19:19:312023-07-02 19:19:33

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-02 19:19:33]
  • 评测
  • 测评结果:AC
  • 用时:6ms
  • 内存:13996kb
  • [2023-07-02 19:19:31]
  • 提交

answer

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 200005
#define inf 0x3f3f3f3f

int n,m;
int p[maxn],rnk[maxn],x[maxn],y[maxn],col[maxn],X[maxn],Y[maxn];
vi e[maxn];
bool vis[maxn];
int o[5];

int q[maxn],tl=1,tr=0;
bool inq[maxn];
bool work(int s,int t){
	q[tl=tr=1]=s,inq[s]=1;
	int cs=col[s],ct=col[t];
	while(tl<=tr){
		int u=q[tl++];
		for(int v:e[u]){
			if(col[v] && col[v]==cs+ct-col[u] && !inq[v])
				inq[v]=1,q[++tr]=v;
		}
	}
	if(inq[t]){
		For(i,1,tr)inq[q[i]]=0;
		return 0;
	}
	For(i,1,tr)inq[q[i]]=0,col[q[i]]=cs+ct-col[q[i]];
	return 1;
}

signed main()
{
	n=read(),m=read();
	For(i,1,n)x[i]=read(),y[i]=read(),p[i]=i;
	sort(p+1,p+n+1,[&](int i,int j){
		return x[i]<x[j]||(x[i]==x[j]&&y[i]<y[j]);
	});
	For(i,1,n)rnk[p[i]]=i,X[i]=x[p[i]],Y[i]=y[p[i]];
	For(i,1,n)x[i]=X[i],y[i]=Y[i];
	For(i,1,m){
		int u=read(),v=read();
		u=rnk[u],v=rnk[v];
		e[u].pb(v),e[v].pb(u);
	}
	For(u,1,n){
		For(i,1,4)vis[i]=0;
		for(int v:e[u])if(col[v])vis[col[v]]=1;
		For(i,1,4)if(!vis[i]){col[u]=i;break;}
		if(col[u])continue;
		for(int v:e[u])if(col[v]){
			if(x[u]==x[v] && y[v]<y[u]) o[0]=v;
			if(x[v]<x[u] && y[v]<y[u]) o[1]=v;
			if(x[v]<x[u] && y[v]==y[u]) o[2]=v;
			if(x[v]<x[u] && y[v]>y[u]) o[3]=v;
		}
		assert(work(o[0],o[2])||work(o[1],o[3]));
		For(i,1,4)vis[i]=0;
		for(int v:e[u])if(col[v])vis[col[v]]=1;
		For(i,1,4)if(!vis[i]){col[u]=i;break;}
		assert(col[u]);
	}
	For(i,1,n)cout<<col[rnk[i]]<<"\n";
	return 0;
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok ...

Test #2:

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

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:

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

result:

ok ...

Test #3:

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

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:

1
2
4
2
3
1
2
1
4
3
3
1
1
2
4
4
1
1
4
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: 6ms
memory: 13976kb

input:

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

output:

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

result:

ok ...

Test #5:

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

input:

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

output:

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

result:

ok ...

Test #6:

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

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

result:

ok ...

Test #7:

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

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:

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

result:

ok ...

Test #8:

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

input:

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

output:

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

result:

ok ...

Test #9:

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

input:

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

output:

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

result:

ok ...

Test #10:

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

input:

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

output:

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

result:

ok ...

Test #11:

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

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:

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

result:

ok ...

Test #12:

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

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

result:

ok ...

Test #13:

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

input:

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

output:

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

result:

ok ...

Test #14:

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

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:

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

result:

ok ...

Test #15:

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

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:

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

result:

ok ...

Test #16:

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

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:

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

result:

ok ...

Test #17:

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

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:

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

result:

ok ...

Test #18:

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

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:

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

result:

ok ...

Test #19:

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

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

result:

ok ...

Test #20:

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

input:

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

output:

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

result:

ok ...

Test #21:

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

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:

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

result:

ok ...

Test #22:

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

input:

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

output:

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

result:

ok ...

Test #23:

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

input:

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

output:

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

result:

ok ...

Test #24:

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

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:

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

result:

ok ...

Test #25:

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

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:

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

result:

ok ...

Test #26:

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

input:

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

output:

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

result:

ok ...

Test #27:

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

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:

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

result:

ok ...

Test #28:

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

input:

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

output:

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

result:

ok ...

Test #29:

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

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:

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

result:

ok ...

Test #30:

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

input:

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

output:

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

result:

ok ...

Test #31:

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

input:

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

output:

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

result:

ok ...

Test #32:

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

input:

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

output:

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

result:

ok ...

Test #33:

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

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:

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

result:

ok ...

Test #34:

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

input:

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

output:

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

result:

ok ...

Test #35:

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

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:

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

result:

ok ...

Test #36:

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

input:

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

output:

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

result:

ok ...

Test #37:

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

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

result:

ok ...

Test #38:

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

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:

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

result:

ok ...

Test #39:

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

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:

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

result:

ok ...

Test #40:

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

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:

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

result:

ok ...

Test #41:

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

input:

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

output:

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

result:

ok ...

Test #42:

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

input:

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

output:

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

result:

ok ...

Test #43:

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

input:

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

output:

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

result:

ok ...

Test #44:

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

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

result:

ok ...

Test #45:

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

input:

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

output:

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

result:

ok ...

Test #46:

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

input:

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

output:

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

result:

ok ...

Test #47:

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

input:

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

output:

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

result:

ok ...

Test #48:

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

input:

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

output:

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

result:

ok ...

Test #49:

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

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:

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

result:

ok ...

Test #50:

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

input:

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

output:

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

result:

ok ...

Test #51:

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

input:

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

output:

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

result:

ok ...

Test #52:

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

input:

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

output:

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

result:

ok ...

Test #53:

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

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:

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

result:

ok ...

Test #54:

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

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

result:

ok ...

Test #55:

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

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

result:

ok ...

Test #56:

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

input:

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

output:

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

result:

ok ...

Test #57:

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

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:

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

result:

ok ...

Test #58:

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

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:

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

result:

ok ...

Test #59:

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

input:

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

output:

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

result:

ok ...

Test #60:

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

input:

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

output:

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

result:

ok ...

Test #61:

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

input:

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

output:

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

result:

ok ...

Test #62:

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

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

result:

ok ...

Test #63:

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

input:

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

output:

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

result:

ok ...

Test #64:

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

input:

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

output:

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

result:

ok ...