QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#425129#8106. Mosaicjinqihao2023AC ✓85ms7120kbC++145.0kb2024-05-29 22:26:532024-05-29 22:26:54

Judging History

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

  • [2024-05-29 22:26:54]
  • 评测
  • 测评结果:AC
  • 用时:85ms
  • 内存:7120kb
  • [2024-05-29 22:26:53]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2e3+5;
int n,x[N],y[N],b[N],T,cx[N],cy[N];
int mxup;
set<int>sx[N],sy[N];
map<pair<int,int>,int>mp;
int fx(int x){int pos=lower_bound(cx+1,cx+cx[0]+1,x)-cx;if(pos==cx[0]+1 || cx[pos]!=x)return -1;return pos;}
int fy(int y){int pos=lower_bound(cy+1,cy+cy[0]+1,y)-cy;if(pos==cy[0]+1 || cy[pos]!=y)return -1;return pos;}
struct Seg_tree
{
	struct STree{int lc,rc,add,minn;pair<int,int>maxn;}t[N*60];
	int tot,rt;
	void pushup(int p)
	{
		t[p].maxn=max(t[t[p].lc].maxn,t[t[p].rc].maxn);
		t[p].minn=min(t[t[p].lc].minn,t[t[p].rc].minn);
	}
	void update(int &p,int v,int l,int r)
	{
		if(!p)tot++,p=tot,t[p].lc=t[p].rc=0,t[p].maxn={mxup,-l},t[p].minn=mxup,t[p].add=0;
		t[p].maxn.first+=v,t[p].minn+=v,t[p].add+=v;
	}
	void pushdown(int p,int l,int r)
	{
		int mid=l+r>>1;
		update(t[p].lc,t[p].add,l,mid),update(t[p].rc,t[p].add,mid+1,r),t[p].add=0;
	}
	void change(int &p,int l,int r,int al,int ar,int v)
	{
		if(!p)p=++tot,t[p].lc=t[p].rc=0,t[p].maxn={mxup,-l},t[p].minn=mxup,t[p].add=0;
		if(al<=l && r<=ar)return update(p,v,l,r),void();
		pushdown(p,l,r);
		int mid=l+r>>1;
		if(al<=mid)change(t[p].lc,l,mid,al,ar,v);
		if(mid<ar)change(t[p].rc,mid+1,r,al,ar,v);
		pushup(p);
		// cout<<p<<" "<<l<<" "<<r<<" "<<t[p].minn<<" "<<mxup<<" "<<v<<endl;
	}
	int ask(int p,int l,int r,int al,int ar)
	{
		if(!p)return mxup;
		if(al<=l && r<=ar)return t[p].minn;
		pushdown(p,l,r);
		int mid=l+r>>1,res=mxup;
		if(al<=mid)res=min(res,ask(t[p].lc,l,mid,al,ar));
		if(mid<ar)res=min(res,ask(t[p].rc,mid+1,r,al,ar));
		return res;
	}
}t1;
int ans[N];
bool slv()
{
	// cout<<"mxup"<<mxup<<endl;
	t1.t[0].maxn={mxup,0},t1.t[0].minn=mxup,t1.tot=0,t1.rt=0;
	// cout<<(*sx[1].rbegin())<<endl;
	if(!sx[1].size())return 0;
	int nx=mxup-*sx[1].rbegin();
	vector<pair<int,int> >temp;
	ans[mp[{0,*sx[1].rbegin()}]]=nx;
	temp.push_back({0,nx-1});
	sx[1].erase(--sx[1].end());
	// cout<<(*sx[1].rbegin())<<endl;
	// cout<<nx<<" "<<fx(nx)<<endl;
	int cnt=1;
	while(fx(nx)!=-1)
	{
		int nx1=fx(nx);
		if(!sx[nx1].size())return 0;
		int ny=*sx[nx1].rbegin(),pos=mp[{nx,ny}];
		sx[nx1].erase(--sx[nx1].end());
		// cout<<nx<<" "<<ny<<" "<<pos<<endl;
		cnt++;
		ans[pos]=mxup-ny;
		temp.push_back({nx,nx+ans[pos]-1});
		nx+=ans[pos];
	}
	for(int i=1;i<=n;i++)if(cx[x[i]]>nx)return 0;
	// cout<<"nx"<<nx<<endl;
	int mxri=nx;
	// for(int i=0;i<mxri;i++)printf("%d ",t1.ask(t1.rt,0,mxri-1,i,i));printf("\n");
	// cout<<t1.t[0].lc<<" !!!!!!!!!!! "<<t1.t[0].rc<<endl;
	for(auto i:temp)t1.change(t1.rt,0,mxri-1,i.first,i.second,i.first-i.second-1);
	// for(int i=0;i<mxri;i++)printf("%d ",t1.ask(t1.rt,0,mxri-1,i,i));printf("\n");
	while(t1.t[t1.rt].maxn.first>0)
	{
		int x=-t1.t[t1.rt].maxn.second,y=t1.t[t1.rt].maxn.first,nx=fx(x);
		// cout<<x<<" "<<y<<" "<<nx<<" "<<sx[nx].size()<<endl;
		if(nx==-1 || !sx[nx].size())return 0;
		int ny=*sx[nx].rbegin();sx[nx].erase(--sx[nx].end());
		// cout<<ny<<endl;
		if(ny>=y)return 0;
		ans[mp[{x,ny}]]=y-ny;
		// cout<<y-ny<<endl;
		if(x+(y-ny)>mxri)return 0;
		if(t1.ask(t1.rt,0,mxri-1,x,x+(y-ny)-1)<y)return 0;
		t1.change(t1.rt,0,mxri-1,x,x+(y-ny)-1,ny-y);
		cnt++;
		// for(int i=0;i<mxri;i++)printf("%d ",t1.ask(t1.rt,0,mxri-1,i,i));printf("\n");
	}
	// cout<<cnt<<endl;
	if(cnt<n)return 0;
	return 1;
}
bool isans;
void solve1()
{
	// for(int i=1;i<=n;i++)printf("%d %d\n",x[i],y[i]);
	for(int i=1;i<=n;i++)mp[{x[i],y[i]}]=i;
	cx[0]=0,cy[0]=0;
	for(int i=1;i<=n;i++)cx[0]++,cx[cx[0]]=x[i],cy[0]++,cy[cy[0]]=y[i];
	sort(cx+1,cx+cx[0]+1),cx[0]=unique(cx+1,cx+cx[0]+1)-cx-1;
	sort(cy+1,cy+cy[0]+1),cy[0]=unique(cy+1,cy+cy[0]+1)-cy-1;
	for(int i=1;i<=n;i++)x[i]=lower_bound(cx+1,cx+cx[0]+1,x[i])-cx,y[i]=lower_bound(cy+1,cy+cy[0]+1,y[i])-cy;
	pair<int,int>mxx={-1,0};
	for(int i=1;i<=n;i++)if(x[i]==1)mxx=max(mxx,{y[i],i});
	for(int i=1;i<=cx[0];i++)if(cx[i])
	{
		mxup=cy[mxx.first]+cx[i];
		for(int j=1;j<=cx[0];j++)sx[j].clear();
		for(int j=1;j<=n;j++)sx[x[j]].insert(cy[y[j]]),ans[j]=0;
		if(slv())
		{
			isans=1;
			return ;
		}
	}
}
int xx[N],yy[N];
int ct,fir=-1;
void solve()
{
	scanf("%d",&n),isans=0;
	for(int i=1;i<=n;i++)scanf("%d %d",&x[i],&y[i]);
	ct++;
	if(fir==-1)fir=n;
	// if(ct==24 && fir==2)
	// {
	// 	printf("J%d\n",y[5]);
	// 	return ;
	// }
	if(n==1){printf("YES 1\n");return ;}
	int mnx=2e9,mny=2e9;
	for(int i=1;i<=n;i++)mnx=min(mnx,x[i]),mny=min(mny,y[i]);
	bool fl=0;
	for(int i=1;i<=n;i++)if(x[i]==mnx && y[i]==mny)fl=1;
	if(!fl){printf("NO\n");return ;}
	for(int i=1;i<=n;i++)x[i]-=mnx,y[i]-=mny,xx[i]=x[i],yy[i]=y[i];
	mp.clear();
	solve1();
	if(isans)
	{
		printf("YES ");
		for(int i=1;i<=n;i++)printf("%d ",ans[i]);
		printf("\n");
		return ;
	}
	mp.clear();
	for(int i=1;i<=n;i++)x[i]=yy[i],y[i]=xx[i];
	solve1();
	if(isans)
	{
		printf("YES ");
		for(int i=1;i<=n;i++)printf("%d ",ans[i]);
		printf("\n");
		return ;
	}
	printf("NO\n");
}
int main()
{
	// freopen("ex_puzzle2.in","r",stdin);
	// freopen("puzzle.out","w",stdout);
	scanf("%d",&T);
	while(T--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 6848kb

input:

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

output:

YES 1 1 
NO
YES 1 1 3 2 

result:

ok 3 testow OK.

Test #2:

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

input:

50
21
2 1
0 4
1 3
1 2
0 2
0 1
1 4
2 3
0 3
2 4
0 0
1 1
1 0
0 6
1 5
2 0
2 2
2 5
1 6
2 6
0 5
1
3 17
9
3 17
28 12
27 3
17 3
17 13
27 12
21 13
3 3
21 20
9
68 38
75 22
34 47
70 50
70 45
59 38
34 22
68 45
59 22
10
47 38
75 35
70 54
64 49
64 38
72 13
72 35
47 55
47 13
70 49
10
54 47
42 111
9 92
42 123
35 11...

output:

YES 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
YES 1
YES 18 8 9 10 4 1 7 14 15 
YES 7 28 36 33 5 9 25 2 16 
YES 17 19 24 6 11 22 3 23 25 5 
YES 60 12 26 28 7 33 45 19 16 44 
YES 15 26 41 4 7 57 11 3 44 54 
YES 34 4 16 55 15 11 60 19 39 23 
YES 35 12 34 41 23 3 44 11 45 38 
YES 2 15 25 30 11 3 8 27 1...

result:

ok 50 testow OK.

Test #3:

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

input:

50
2
2 1
3 1
3
1 2
1 3
1 1
4
0 0
0 1
0 2
0 3
5
1 6
1 7
1 4
1 8
1 5
5
2 5
4 5
5 2
3 5
2 2
4
6 5
5 3
5 5
7 3
5
2 5
2 3
2 4
3 3
3 4
5
1 0
3 0
0 2
0 0
0 1
5
11 2
8 1
5 1
11 3
11 1
4
4 3
2 2
4 2
0 2
5
3 1
1 1
0 1
0 2
3 2
5
1 5
8 5
8 6
6 5
6 7
5
2 3
2 2
3 2
4 2
2 6
3
2 2
1 3
1 2
4
3 3
2 3
3 2
2 2
5
5 0
4 ...

output:

YES 1 1 
YES 1 1 1 
YES 1 1 1 1 
YES 1 1 1 1 1 
YES 1 1 4 1 3 
YES 1 2 1 3 
YES 2 1 1 1 1 
YES 2 5 3 1 1 
YES 1 3 3 1 1 
YES 1 2 1 2 
YES 1 2 1 1 1 
YES 5 1 1 2 3 
YES 3 1 1 1 3 
YES 2 1 1 
YES 1 1 1 1 
YES 1 1 1 1 2 
YES 1 1 1 3 
YES 1 1 4 3 1 
YES 1 2 1 2 
YES 1 2 1 1 1 
YES 2 2 
YES 1 1 2 2 
YES ...

result:

ok 50 testow OK.

Test #4:

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

input:

50
5
3 7
5 7
7 7
3 4
6 4
3
6 1
6 4
9 1
5
6 2
6 0
3 3
6 1
3 0
5
2 0
2 1
5 0
2 2
3 0
5
2 5
2 2
5 4
5 2
5 6
5
8 7
2 4
7 8
7 7
7 4
4
6 6
9 9
6 9
9 6
2
2 7
2 11
5
4 1
5 0
6 0
7 0
4 0
3
3 7
5 5
3 5
4
16 5
18 3
16 3
10 3
5
1 7
5 3
5 6
3 7
1 3
5
11 9
6 5
9 9
6 8
9 5
3
8 2
4 2
4 6
4
6 6
6 10
10 8
10 6
4
3 2
...

output:

YES 2 2 2 3 3 
YES 3 3 6 
YES 1 1 4 1 3 
YES 1 1 5 3 2 
YES 3 3 2 2 2 
YES 2 5 1 1 3 
YES 3 3 3 3 
YES 4 4 
YES 3 1 1 4 1 
YES 2 4 2 
YES 4 2 2 6 
YES 2 3 3 2 4 
YES 2 3 2 3 4 
YES 8 4 4 
YES 4 6 2 2 
YES 4 4 4 4 
YES 1 1 
YES 1 1 1 
YES 1 1 1 1 
YES 1 1 1 1 1 
YES 2 2 
YES 2 1 1 
YES 1 2 2 1 
YES 1...

result:

ok 50 testow OK.

Test #5:

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

input:

50
4
1 1
3 1
5 1
5 2
5
3 3
2 6
3 6
2 3
2 4
2
3 2
1 2
4
8 1
9 0
6 0
8 0
5
1 4
2 4
1 6
1 5
2 5
5
8 8
7 8
4 8
7 9
4 3
3
2 4
1 4
1 2
4
4 1
8 1
7 2
7 1
3
9 2
7 4
7 2
4
2 0
5 2
6 2
5 0
5
8 2
8 5
8 4
3 2
9 4
4
4 2
4 0
6 2
6 0
5
13 4
13 2
7 2
11 4
11 2
5
5 4
5 7
3 4
3 6
3 8
4
3 2
3 8
5 8
7 8
5
7 2
6 3
6 5
6...

output:

YES 2 2 1 1 
YES 1 1 1 1 2 
YES 2 2 
YES 1 2 2 1 
YES 1 1 2 1 1 
YES 1 1 3 2 5 
YES 1 1 2 
YES 3 1 2 1 
YES 4 2 2 
YES 3 1 1 2 
YES 2 2 1 5 1 
YES 2 2 2 2 
YES 2 2 4 2 2 
YES 3 3 2 2 2 
YES 6 2 2 2 
YES 1 2 2 1 5 
YES 2 4 2 3 3 
YES 3 3 
YES 1 1 3 1 
YES 4 3 1 1 1 
YES 2 3 2 3 2 
YES 3 6 3 
YES 4 1 ...

result:

ok 50 testow OK.

Test #6:

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

input:

50
3
6 0
5 0
5 1
4
4 1
5 1
5 0
4 0
5
2 2
1 2
3 2
2 3
1 3
4
3 4
2 5
2 4
4 4
5
4 4
4 1
5 1
4 2
4 3
4
4 5
4 6
7 5
5 5
5
0 3
1 3
0 4
3 3
3 4
2
3 0
1 0
3
2 5
2 7
3 7
4
4 8
6 9
6 8
4 5
3
4 0
6 0
4 2
4
6 4
6 2
3 2
7 4
5
5 10
7 11
5 5
7 10
8 10
4
3 4
5 4
3 2
5 2
5
5 2
7 2
5 4
1 2
7 4
5
7 8
7 6
9 4
7 4
9 7
4...

output:

YES 2 1 1 
YES 1 1 1 1 
YES 1 1 2 1 1 
YES 1 2 1 3 
YES 1 1 4 1 1 
YES 1 1 2 2 
YES 1 2 1 1 1 
YES 2 2 
YES 2 1 1 
YES 2 1 1 3 
YES 2 4 2 
YES 1 2 3 1 
YES 2 1 5 1 2 
YES 2 2 2 2 
YES 2 2 2 4 2 
YES 2 2 3 2 3 
YES 2 2 2 6 
YES 2 1 5 2 1 
YES 1 1 
YES 1 1 1 
YES 1 1 1 1 
YES 1 1 1 1 1 
YES 2 2 
YES 1...

result:

ok 50 testow OK.

Test #7:

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

input:

50
5
5 4
3 3
6 4
5 3
6 3
3
5 5
3 5
1 5
4
5 0
4 1
7 0
4 0
2
6 3
9 3
4
3 4
4 3
3 5
3 3
2
4 10
4 6
2
0 6
1 6
3
3 0
4 0
5 0
4
7 4
4 4
6 4
5 4
5
5 4
5 5
5 6
5 8
5 7
2
3 2
5 2
3
6 5
8 5
10 5
2
3 5
6 5
2
4 2
4 6
2
2 3
2 2
3
1 0
3 0
2 0
4
2 5
2 6
2 7
2 4
5
1 4
1 6
1 7
1 5
1 3
5
6 5
4 5
5 5
4 2
7 2
4
4 2
4 4...

output:

YES 1 2 1 1 1 
YES 2 2 2 
YES 2 1 2 1 
YES 3 3 
YES 1 3 1 1 
YES 4 4 
YES 1 1 
YES 1 1 1 
YES 1 1 1 1 
YES 1 1 1 1 1 
YES 2 2 
YES 2 2 2 
YES 3 3 
YES 4 4 
YES 1 1 
YES 1 1 1 
YES 1 1 1 1 
YES 1 1 1 1 1 
YES 1 1 1 3 4 
YES 1 1 3 1 
YES 1 2 1 1 1 
YES 5 2 1 1 3 
YES 1 1 2 2 
YES 2 1 1 1 1 
YES 2 5 2 ...

result:

ok 50 testow OK.

Test #8:

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

input:

50
2
0 1
0 4
4
7 1
8 3
4 1
7 3
5
2 8
3 8
4 8
2 9
2 5
5
3 14
3 12
4 14
0 12
0 7
4
2 3
1 3
1 5
1 4
5
1 10
1 8
1 7
1 9
2 7
4
2 1
4 1
3 3
2 3
5
10 5
5 5
11 5
10 6
10 7
3
9 4
3 1
9 1
5
9 7
7 4
8 7
7 7
3 4
5
4 9
7 6
7 10
7 8
4 6
4
2 0
5 0
5 3
2 3
2
4 1
8 1
5
8 2
8 3
8 1
8 4
4 1
3
6 0
2 0
6 2
2
1 1
2 1
3
1...

output:

YES 3 3 
YES 2 1 3 1 
YES 1 1 1 3 3 
YES 1 2 1 3 5 
YES 3 1 1 1 
YES 1 1 1 1 4 
YES 2 3 1 1 
YES 1 5 2 1 3 
YES 3 6 3 
YES 1 3 1 1 4 
YES 3 2 2 2 3 
YES 3 3 3 3 
YES 4 4 
YES 1 1 1 1 4 
YES 2 4 2 
YES 1 1 
YES 1 1 1 
YES 1 1 1 1 
YES 2 2 
YES 1 1 2 
YES 2 1 1 2 
YES 1 1 1 1 2 
YES 3 3 
YES 3 1 1 1 
...

result:

ok 50 testow OK.

Test #9:

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

input:

50
4
4 2
6 2
4 0
6 0
2
0 4
0 1
4
8 5
8 4
5 3
8 3
5
9 6
11 9
10 9
9 9
12 6
3
9 10
6 10
6 4
5
8 2
11 1
10 1
8 1
9 1
4
6 8
9 5
6 5
9 8
2
1 3
2 3
3
3 2
2 2
1 2
4
0 3
0 0
0 1
0 2
2
2 1
0 1
3
4 4
4 3
5 3
4
1 4
2 3
1 1
1 3
5
0 1
1 0
1 1
2 0
0 0
2
6 2
3 2
4
4 2
3 2
5 2
3 3
2
3 0
2 0
3
3 1
4 1
5 1
4
4 6
2 5
...

output:

YES 2 2 2 2 
YES 3 3 
YES 1 1 3 1 
YES 3 1 1 1 4 
YES 3 3 6 
YES 3 4 1 1 1 
YES 3 3 3 3 
YES 1 1 
YES 1 1 1 
YES 1 1 1 1 
YES 2 2 
YES 1 1 2 
YES 2 1 2 1 
YES 1 1 1 2 1 
YES 3 3 
YES 1 1 3 2 
YES 1 1 
YES 1 1 1 
YES 1 2 1 3 
YES 1 1 1 1 2 
YES 1 2 1 2 5 
YES 2 1 1 
YES 1 1 1 1 
YES 1 1 1 1 2 
YES 1 ...

result:

ok 50 testow OK.

Test #10:

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

input:

50
4
4 7
5 7
4 5
4 3
5
2 5
3 2
2 2
2 3
3 5
2
2 1
1 1
3
4 0
3 0
2 0
4
2 1
3 1
4 1
5 1
2
2 0
0 0
3
8 1
7 1
7 2
4
5 0
6 0
3 0
5 1
5
1 3
1 4
0 3
0 1
0 4
2
5 4
5 7
2
3 6
2 6
3
5 4
7 4
6 4
4
4 7
5 7
6 7
3 7
2
1 4
1 2
2
3 3
3 0
2
2 0
1 0
3
0 0
0 2
0 1
4
0 0
3 0
1 0
2 0
5
4 3
4 4
4 6
4 5
4 7
5
1 3
3 0
2 3
0...

output:

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

result:

ok 50 testow OK.

Test #11:

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

input:

50
2
4 11
4 7
3
5 4
7 4
5 0
2
5 1
6 1
3
2 0
4 0
3 0
2
2 4
2 6
3
0 2
0 1
1 1
2
5 4
5 3
3
5 6
5 4
5 5
4
4 0
3 0
5 0
6 0
5
7 3
3 3
7 4
8 3
9 3
4
6 1
2 1
5 1
5 2
5
4 1
4 2
5 1
3 1
3 2
4
4 2
7 2
5 2
4 3
5
4 1
4 2
7 2
7 1
5 1
5
4 12
1 10
5 12
1 5
4 10
3
0 1
1 3
0 3
4
1 2
2 1
2 2
1 1
5
1 3
1 4
2 2
1 2
2 3
...

output:

YES 4 4 
YES 2 2 4 
YES 1 1 
YES 1 1 1 
YES 2 2 
YES 1 1 2 
YES 1 1 
YES 1 1 1 
YES 1 1 1 1 
YES 1 4 3 1 1 
YES 1 3 1 2 
YES 1 1 2 1 1 
YES 1 2 2 1 
YES 1 1 1 1 2 
YES 1 3 1 5 2 
YES 2 1 1 
YES 1 1 1 1 
YES 1 2 1 1 1 
YES 1 3 1 2 
YES 2 2 
YES 1 2 1 2 
YES 1 1 1 1 2 
YES 1 5 2 2 1 
YES 1 1 2 
YES 3 ...

result:

ok 50 testow OK.

Test #12:

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

input:

50
2
2 2
2 4
3
0 1
1 3
0 3
2
0 0
0 1
3
1 5
0 5
0 3
4
4 3
5 3
4 2
5 2
5
6 6
6 3
7 6
6 5
7 5
4
3 2
4 0
3 0
3 1
2
2 0
3 0
3
4 4
5 4
3 4
2
1 1
1 3
3
1 3
1 2
2 2
2
1 0
1 1
3
7 8
8 8
9 8
2
0 0
2 0
2
1 1
0 1
3
5 0
3 0
4 0
4
6 4
6 3
6 2
6 5
5
5 0
6 0
3 0
4 0
7 0
5
7 6
7 7
7 8
7 5
8 5
4
1 0
4 1
4 0
5 0
5
4 0...

output:

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

result:

ok 50 testow OK.

Test #13:

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

input:

32
2
0 0
0 1
2
5 1
6 1
3
5 9
5 7
5 8
4
7 0
8 2
9 0
7 2
5
6 9
6 10
7 8
6 8
7 9
3
2 1
3 0
2 0
4
0 2
1 1
0 1
1 2
2
1 2
3 2
3
7 1
9 1
9 2
2
2 0
2 1
2
6 0
7 0
3
3 6
3 7
4 6
4
7 3
6 4
7 4
6 3
2
1 3
1 2
2
4 2
4 1
2
5 0
5 1
3
1 1
3 1
2 1
4
6 1
5 1
3 1
4 1
5
6 0
8 0
7 0
5 0
4 0
2
2 1
2 3
3
8 4
8 6
8 8
2
5 4
...

output:

YES 1 1 
YES 1 1 
YES 1 1 1 
YES 2 1 3 1 
YES 1 2 1 1 1 
YES 1 2 1 
YES 1 1 1 1 
YES 2 2 
YES 2 1 1 
YES 1 1 
YES 1 1 
YES 1 1 2 
YES 1 1 1 1 
YES 1 1 
YES 1 1 
YES 1 1 
YES 1 1 1 
YES 1 1 1 1 
YES 1 1 1 1 1 
YES 2 2 
YES 2 2 2 
YES 3 3 
YES 4 4 
YES 1 1 
YES 1 1 1 
YES 1 1 1 1 
YES 2 2 
YES 3 3 
YE...

result:

ok 32 testow OK.

Test #14:

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

input:

50
19
4294 4169
4061 4177
4061 4170
4061 4546
4066 4169
4095 4169
5658 4169
4150 4169
4061 4172
4061 4224
4062 4169
4671 4169
4061 4313
4061 4190
4061 6753
4074 4169
4063 4169
4061 5156
4061 4169
23
1358 249
1351 841
1353 249
1351 303
1356 249
1351 346
1372 249
1360 249
1352 249
1760 249
1354 249
13...

output:

YES 377 13 2 610 8 55 4181 144 5 89 1 987 233 34 1597 21 3 1597 1 
YES 1 409 1 43 1 43 11 1 1 1001 1 11 183 11 1 1 1 43 183 10 43 409 1 
YES 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
YES 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
YES 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
...

result:

ok 50 testow OK.

Test #15:

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

input:

50
6
4 1
6 1
5 1
8 1
9 1
7 1
6
7 9
7 10
7 7
3 2
7 8
3 7
6
6 3
5 3
7 3
6 1
4 3
4 1
6
6 2
3 2
6 4
4 5
5 5
3 5
6
11 3
12 3
10 4
10 3
3 3
10 7
6
2 8
1 9
3 8
4 8
1 13
1 8
6
5 2
4 3
6 2
4 2
5 3
8 2
6
6 3
7 2
9 2
6 4
6 2
6 7
6
2 4
1 4
1 5
1 3
2 5
2 3
6
4 1
2 2
3 1
2 3
3 2
2 1
6
1 0
3 1
3 0
3 2
1 2
2 2
6
4 ...

output:

YES 1 1 1 1 1 1 
YES 1 1 1 5 1 4 
YES 1 1 1 2 1 2 
YES 2 3 2 1 1 1 
YES 1 1 3 1 7 3 
YES 1 4 1 1 4 1 
YES 1 1 2 1 1 2 
YES 1 2 8 3 1 3 
YES 1 1 1 1 1 1 
YES 1 1 1 1 2 1 
YES 2 1 1 1 1 1 
YES 1 2 1 1 1 2 
YES 4 1 2 1 1 1 
YES 2 7 1 2 1 2 
YES 1 1 2 1 1 2 
YES 1 2 1 2 1 1 
YES 2 2 1 1 7 5 
YES 1 4 1 1...

result:

ok 50 testow OK.

Test #16:

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

input:

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

output:

YES 3 2 2 1 1 1 
YES 7 2 2 2 1 1 
YES 2 2 2 2 2 2 
YES 3 2 1 1 2 1 
YES 2 1 3 2 1 1 
YES 7 2 1 1 2 2 
YES 2 2 2 2 4 2 
YES 1 8 1 2 3 5 
YES 3 7 4 1 1 1 
YES 1 3 5 8 1 2 
YES 2 2 6 3 3 2 
YES 3 1 1 2 2 1 
YES 1 3 1 2 1 2 
YES 1 3 3 1 7 1 
YES 2 8 1 3 1 3 
YES 2 2 3 6 3 2 
YES 1 3 3 1 8 2 
YES 1 1 1 2...

result:

ok 50 testow OK.

Test #17:

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

input:

50
6
5 2
5 3
4 3
4 1
4 2
5 1
6
3 0
5 1
1 0
5 0
6 1
6 0
6
1 2
2 4
1 4
3 4
1 3
2 2
6
4 2
4 3
4 4
4 5
5 2
5 4
6
5 0
4 0
3 1
6 2
5 2
3 0
6
2 7
4 4
3 6
2 8
2 6
2 4
6
8 4
9 1
8 3
8 2
8 5
8 1
6
2 4
2 1
2 0
2 3
3 0
3 3
6
9 1
4 1
9 2
5 1
7 1
4 2
6
2 2
4 2
4 3
6 2
5 2
5 3
6
2 7
2 5
4 3
3 5
2 6
2 3
6
5 6
6 5
5...

output:

YES 1 1 1 1 1 1 
YES 2 1 2 1 1 1 
YES 1 1 1 1 1 2 
YES 1 1 1 1 2 2 
YES 2 1 2 1 1 1 
YES 1 2 3 1 1 2 
YES 1 5 1 1 1 1 
YES 2 2 1 1 1 1 
YES 1 1 1 2 2 1 
YES 2 1 1 2 1 1 
YES 1 1 2 3 1 2 
YES 2 1 1 1 4 1 
YES 2 1 2 1 1 1 
YES 8 3 5 1 2 1 
YES 2 2 2 2 2 2 
YES 2 2 4 2 2 2 
YES 2 2 6 3 2 3 
YES 2 2 2 2...

result:

ok 50 testow OK.

Test #18:

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

input:

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

output:

YES 1 1 1 2 2 3 
YES 1 1 3 4 7 1 
YES 1 1 1 1 4 4 
YES 1 1 1 1 1 1 
YES 1 1 1 1 1 2 
YES 1 1 1 1 1 2 
YES 1 1 1 2 2 1 
YES 4 1 2 1 1 1 
YES 5 2 1 2 7 1 
YES 1 1 1 2 4 1 
YES 2 8 5 1 1 3 
YES 1 1 1 1 1 1 
YES 1 2 2 1 1 1 
YES 1 1 2 1 1 1 
YES 1 2 2 1 1 1 
YES 1 1 2 1 1 2 
YES 1 2 2 3 1 1 
YES 1 5 1 1...

result:

ok 50 testow OK.

Test #19:

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

input:

50
6
8 9
12 10
6 2
10 9
12 9
6 9
6
2 6
2 5
1 5
0 6
1 6
0 5
6
2 5
2 9
3 5
2 7
2 6
3 6
6
3 6
3 4
3 5
2 4
1 4
1 5
6
2 2
4 3
4 1
2 0
4 0
4 2
6
5 3
7 5
4 3
4 4
6 3
6 5
6
5 6
6 6
7 6
5 3
3 5
3 3
6
2 0
7 4
7 3
7 0
7 2
7 1
6
1 3
1 7
1 6
2 3
1 4
2 6
6
9 3
5 2
7 2
9 2
4 3
4 2
6
1 4
3 6
1 6
3 4
2 6
3 5
6
3 2
3...

output:

YES 2 1 7 2 1 2 
YES 1 1 1 1 1 1 
YES 1 2 1 2 1 1 
YES 1 1 1 1 1 2 
YES 2 1 1 2 1 1 
YES 1 1 1 2 2 1 
YES 1 1 1 3 2 2 
YES 5 1 1 1 1 1 
YES 1 2 1 1 2 1 
YES 1 2 2 1 1 1 
YES 2 1 1 1 1 1 
YES 2 1 1 1 2 1 
YES 1 2 2 1 1 1 
YES 1 2 1 1 1 4 
YES 1 2 1 1 3 2 
YES 2 1 1 2 2 7 
YES 2 2 2 2 2 2 
YES 2 7 1 5...

result:

ok 50 testow OK.

Test #20:

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

input:

50
6
11 18
6 8
12 18
10 15
10 18
6 15
6
7 3
6 3
6 4
6 8
8 3
9 3
6
3 1
1 2
1 1
3 2
2 1
2 2
6
2 4
3 9
2 6
2 8
3 8
2 9
6
1 2
2 0
2 1
0 0
2 2
0 2
6
3 4
4 4
1 4
1 2
3 2
2 4
6
2 5
2 6
4 4
3 5
4 3
2 3
6
4 0
7 0
4 3
7 1
6 3
7 2
6
6 2
6 5
6 4
6 3
6 1
7 1
6
6 2
11 3
8 3
9 2
8 2
11 2
6
2 5
2 3
2 1
3 3
3 4
2 4
...

output:

YES 1 7 1 3 1 4 
YES 1 1 4 4 1 1 
YES 1 1 1 1 1 1 
YES 2 1 2 1 1 1 
YES 1 1 1 2 1 1 
YES 1 1 1 2 2 1 
YES 1 1 1 2 1 2 
YES 3 1 2 1 2 1 
YES 1 1 1 1 1 5 
YES 2 1 1 2 1 1 
YES 2 1 2 1 1 1 
YES 2 1 1 3 2 1 
YES 1 2 1 1 2 1 
YES 7 2 1 5 1 2 
YES 1 2 1 1 1 4 
YES 1 1 1 2 1 2 
YES 2 1 2 1 1 1 
YES 1 7 2 2...

result:

ok 50 testow OK.

Test #21:

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

input:

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

output:

YES 1 1 2 1 1 2 
YES 2 2 1 3 1 1 
YES 3 1 1 3 1 7 
YES 2 1 1 2 1 1 
YES 1 1 1 1 1 1 
YES 1 1 1 2 1 1 
YES 2 1 1 1 1 1 
YES 2 1 1 1 2 1 
YES 1 4 1 1 2 1 
YES 2 1 1 1 1 2 
YES 1 1 4 2 1 1 
YES 1 1 3 3 1 7 
YES 1 1 1 1 1 1 
YES 2 2 1 1 1 1 
YES 1 1 2 1 1 1 
YES 2 1 2 1 1 1 
YES 2 1 1 2 1 1 
YES 1 2 3 1...

result:

ok 50 testow OK.

Test #22:

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

input:

50
6
3 2
5 3
3 3
5 4
5 2
4 2
6
3 5
4 4
2 5
5 3
4 3
2 3
6
8 6
9 3
8 3
8 4
4 3
9 6
6
0 6
3 6
3 7
1 6
0 7
0 8
6
6 4
6 3
5 3
4 4
5 4
4 3
6
1 0
0 2
0 4
1 1
0 1
0 0
6
4 3
3 4
2 3
2 4
3 3
2 5
6
3 4
5 4
2 4
2 2
4 2
4 4
6
6 3
6 5
7 5
4 4
4 3
5 3
6
7 4
8 4
7 1
9 4
5 1
5 3
6
3 6
3 7
7 6
5 6
4 6
6 6
6
0 8
1 4
0...

output:

YES 1 1 2 1 1 1 
YES 1 2 1 1 1 2 
YES 1 1 1 2 4 1 
YES 1 1 1 2 1 4 
YES 1 1 1 1 1 1 
YES 1 2 2 1 1 1 
YES 1 2 1 1 1 1 
YES 1 1 1 2 2 1 
YES 2 1 1 2 1 1 
YES 1 1 3 1 2 2 
YES 1 4 5 1 1 1 
YES 2 1 2 1 1 1 
YES 1 1 4 1 2 1 
YES 1 2 1 2 1 1 
YES 1 2 1 1 1 1 
YES 1 1 1 1 2 2 
YES 1 2 1 1 1 2 
YES 1 1 2 2...

result:

ok 50 testow OK.

Test #23:

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

input:

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

output:

YES 2 2 1 1 1 1 
YES 1 1 1 1 1 1 
YES 1 5 1 4 1 1 
YES 2 1 2 1 1 1 
YES 1 2 1 2 1 3 
YES 1 2 1 1 2 1 
YES 8 2 1 1 5 3 
YES 1 1 1 1 1 1 
YES 2 1 1 1 1 1 
YES 1 2 1 1 1 1 
YES 1 2 1 1 1 2 
YES 1 1 2 4 1 1 
YES 1 1 2 2 1 1 
YES 1 2 2 1 1 1 
YES 2 1 5 2 7 1 
YES 4 2 1 1 1 1 
YES 3 1 7 1 1 3 
YES 1 1 1 1...

result:

ok 50 testow OK.

Test #24:

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

input:

50
6
0 4
3 6
2 4
3 7
3 8
0 6
6
2 12
2 9
3 9
2 8
2 10
3 8
6
6 6
7 4
6 5
7 5
7 6
6 4
6
3 2
2 0
1 1
2 2
1 0
1 2
6
5 3
5 1
4 1
4 2
4 3
6 3
6
4 3
3 1
4 4
2 3
2 1
2 2
6
9 0
8 3
8 0
7 1
7 0
7 3
6
8 1
8 0
3 0
5 1
5 0
6 0
6
5 4
9 7
10 7
10 4
9 5
9 4
6
12 6
12 8
13 6
12 2
16 2
12 7
6
0 1
2 2
1 2
0 2
2 1
1 1
6...

output:

YES 2 1 2 1 1 3 
YES 2 1 1 1 2 1 
YES 1 1 1 1 1 1 
YES 1 2 1 1 1 1 
YES 1 2 1 1 1 1 
YES 1 2 1 2 1 1 
YES 4 1 1 2 1 1 
YES 1 1 2 1 1 2 
YES 4 1 1 1 2 1 
YES 1 1 3 4 7 1 
YES 1 1 1 1 1 1 
YES 1 2 1 1 1 1 
YES 1 1 1 2 2 1 
YES 1 2 1 1 1 2 
YES 1 3 1 2 2 1 
YES 1 2 1 1 2 1 
YES 3 2 1 1 1 2 
YES 1 4 1 1...

result:

ok 50 testow OK.

Test #25:

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

input:

50
6
5 7
6 7
2 6
4 4
4 7
2 4
6
1 1
2 1
1 3
1 2
2 3
2 2
6
8 3
7 5
9 3
8 4
7 3
7 4
6
2 3
0 4
1 3
0 5
0 3
1 4
6
13 5
14 2
12 2
12 5
12 3
13 2
6
6 8
8 8
8 9
7 8
7 9
6 9
6
2 2
3 2
1 2
3 0
1 0
3 1
6
2 4
0 2
1 4
3 4
0 4
2 2
6
4 3
5 5
5 3
6 5
3 4
3 3
6
6 3
5 6
6 5
3 3
6 4
3 6
6
6 8
4 6
5 8
6 7
6 6
4 8
6
2 0...

output:

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

result:

ok 50 testow OK.

Test #26:

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

input:

50
6
2 2
2 1
3 1
4 3
2 3
4 4
6
6 9
6 12
6 8
6 11
7 8
7 11
6
2 9
4 10
1 5
1 9
4 9
1 10
6
5 0
5 1
4 2
4 1
5 2
4 0
6
5 5
6 6
4 5
6 7
6 5
4 6
6
2 4
2 3
3 3
2 2
2 0
3 2
6
1 3
1 5
5 6
4 6
3 6
3 3
6
8 3
8 5
9 4
4 3
9 3
8 4
6
3 3
4 2
5 0
5 1
3 0
3 2
6
9 5
9 3
5 5
7 3
5 3
7 5
6
5 1
4 1
3 1
5 2
5 3
3 2
6
5 2
...

output:

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

result:

ok 50 testow OK.

Test #27:

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

input:

2
6
2 3
0 3
2 2
1 2
0 2
1 3
6
2 0
3 0
4 0
5 0
6 0
1 0

output:

YES 1 1 1 1 1 1 
YES 1 1 1 1 1 1 

result:

ok 2 testow OK.

Test #28:

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

input:

50
49
1 5
1 4
4 0
0 6
5 0
2 1
6 0
1 0
4 3
4 1
2 2
3 6
6 2
3 0
3 1
6 1
6 4
5 2
3 3
1 3
0 1
5 5
0 4
5 3
2 6
4 6
0 2
5 1
0 0
6 5
4 5
5 4
4 2
0 5
2 0
2 5
1 1
1 6
6 6
4 4
3 4
2 3
2 4
6 3
0 3
1 2
3 5
3 2
5 6
60
6 5
6 14
6 10
6 2
6 3
3 3
3 1
4 5
4 2
4 11
3 15
4 7
5 10
4 14
4 10
5 2
4 3
3 5
6 13
4 9
3 7
3 1...

output:

YES 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
YES 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
NO
YES 122 226 47 171 188 10 140 82 230 106 253 212 16 456 15 465 73 24 ...

result:

ok 50 testow OK.

Test #29:

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

input:

50
7
2 2
5 4
6 2
4 2
4 4
3 4
2 4
7
1 5
0 6
0 4
0 5
1 3
1 4
0 3
7
2 5
3 10
4 8
4 10
2 10
4 9
2 8
7
10 1
5 1
8 1
9 2
9 1
8 3
8 2
7
5 1
7 1
4 2
4 4
4 1
6 2
6 1
7
17 2
14 0
9 0
17 3
17 4
16 0
14 2
7
0 2
0 0
1 0
1 1
0 4
0 1
1 4
7
5 14
4 14
4 11
0 5
0 11
5 13
4 13
7
3 2
0 0
5 0
5 1
4 2
3 0
6 0
7
4 0
5 2
1...

output:

YES 2 1 3 2 1 1 1 
YES 1 2 1 1 1 1 1 
YES 3 1 1 1 1 1 2 
YES 1 3 1 2 1 1 1 
YES 1 1 2 4 1 2 1 
YES 1 2 5 1 1 2 3 
YES 2 1 1 1 1 1 1 
YES 1 1 2 6 4 1 1 
YES 1 3 1 2 1 2 1 
YES 1 1 3 1 1 1 1 
YES 1 1 1 1 1 1 3 
YES 1 2 2 1 2 1 1 
YES 2 1 3 1 1 1 1 
YES 1 2 1 1 2 1 6 
YES 3 1 1 1 1 1 2 
YES 1 1 4 2 2 1...

result:

ok 50 testow OK.

Test #30:

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

input:

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

output:

YES 3 1 1 1 2 2 1 
YES 2 1 1 4 2 1 1 
YES 2 1 1 1 1 2 2 
YES 2 2 1 1 2 1 1 
YES 6 2 1 1 1 2 1 
YES 2 2 1 1 1 2 1 
YES 2 3 1 2 1 5 1 
YES 1 1 1 1 3 1 1 
YES 5 1 2 1 3 2 1 
YES 1 3 2 2 1 5 1 
YES 1 2 1 1 1 1 1 
YES 1 1 1 1 1 3 1 
YES 1 1 2 1 1 1 1 
YES 3 1 1 2 1 1 1 
YES 1 1 1 1 3 2 1 
YES 4 1 1 1 2 1...

result:

ok 50 testow OK.

Test #31:

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

input:

50
7
5 7
6 7
4 7
4 8
7 7
7 9
4 2
7
6 1
5 2
6 2
7 1
8 1
7 2
5 1
7
2 4
1 1
2 5
1 4
3 5
3 4
1 5
7
5 4
5 5
3 5
3 6
3 4
4 4
4 5
7
5 6
4 6
3 6
3 3
5 7
4 7
3 7
7
0 4
1 3
2 3
0 5
1 4
0 3
2 5
7
2 8
5 7
4 7
2 7
3 7
2 9
3 8
7
7 7
7 9
7 10
9 5
7 5
8 10
8 9
7
8 11
6 9
8 10
7 11
8 9
6 6
6 11
7
6 2
5 2
7 2
5 5
5 3...

output:

YES 1 1 1 3 2 2 5 
YES 1 1 1 1 2 1 1 
YES 1 3 1 1 1 1 1 
YES 1 1 1 3 1 1 1 
YES 1 1 1 3 1 1 1 
YES 1 1 2 2 1 1 2 
YES 1 3 1 1 1 1 2 
YES 2 1 1 6 2 1 1 
YES 1 2 1 1 1 3 1 
YES 1 1 2 1 2 2 1 
YES 2 1 6 1 1 1 2 
YES 1 1 1 3 1 1 1 
YES 1 2 1 1 1 1 1 
YES 1 2 1 1 1 1 1 
YES 1 3 2 1 1 1 1 
YES 1 1 1 3 2 2...

result:

ok 50 testow OK.

Test #32:

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

input:

50
7
10 3
10 0
6 0
12 1
11 2
10 2
12 0
7
2 5
3 1
1 1
1 2
2 1
1 5
3 5
7
2 12
5 10
5 8
4 8
2 9
2 8
3 8
7
1 7
1 9
2 7
2 9
1 8
2 8
1 5
7
1 5
3 5
1 3
1 6
3 4
2 5
3 3
7
2 2
4 2
4 3
3 2
2 3
0 2
3 3
7
8 4
9 5
10 2
8 2
8 6
9 4
8 5
7
1 8
1 3
3 6
1 9
1 6
3 7
2 8
7
2 2
1 2
3 2
1 3
3 4
2 3
1 4
7
9 2
6 1
9 1
11 3...

output:

YES 1 2 4 1 2 1 1 
YES 1 1 1 3 1 1 1 
YES 5 2 2 1 3 1 1 
YES 1 1 1 1 1 1 2 
YES 1 1 2 3 1 1 1 
YES 1 1 1 1 1 2 1 
YES 1 1 6 2 2 1 1 
YES 1 3 1 1 2 1 2 
YES 1 1 2 1 2 1 2 
YES 1 3 1 1 1 1 2 
YES 2 1 4 1 2 1 1 
YES 4 2 1 2 1 1 1 
YES 1 2 1 1 2 2 1 
YES 2 1 3 1 2 1 1 
YES 1 2 1 1 1 3 1 
YES 2 1 4 1 1 1...

result:

ok 50 testow OK.

Test #33:

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

input:

50
7
3 3
3 4
4 3
3 2
4 2
1 2
1 4
7
10 4
6 2
11 3
11 2
9 2
9 4
11 4
7
8 6
8 8
8 7
6 6
7 8
6 8
6 3
7
6 5
7 4
5 5
6 2
7 2
5 2
5 3
7
2 5
3 5
2 4
3 6
2 7
3 4
2 6
7
8 7
7 8
7 9
9 7
7 7
8 8
7 4
7
8 9
6 6
8 10
6 9
7 9
6 10
8 11
7
8 1
7 1
9 0
7 2
9 2
7 0
8 0
7
9 8
8 5
8 7
8 9
9 9
9 7
8 8
7
3 3
4 5
5 3
3 5
7 ...

output:

YES 1 2 1 1 1 2 2 
YES 1 3 1 1 2 1 1 
YES 1 1 1 2 1 1 3 
YES 1 2 1 1 2 1 2 
YES 1 1 1 1 2 1 1 
YES 1 1 1 1 1 2 3 
YES 1 3 1 1 1 2 1 
YES 1 1 2 2 2 1 1 
YES 1 2 1 1 1 1 1 
YES 2 1 2 1 3 1 1 
YES 1 1 1 1 1 1 2 
YES 1 1 3 1 2 1 1 
YES 1 1 1 3 1 2 1 
YES 1 1 1 1 2 1 1 
YES 2 4 1 6 1 1 1 
YES 2 2 1 3 1 1...

result:

ok 50 testow OK.

Test #34:

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

input:

50
100
25 7
17 5
22 7
27 4
23 4
25 5
20 5
16 4
11 4
21 5
20 7
14 6
24 8
20 8
29 6
17 4
28 8
10 7
26 7
23 8
13 6
20 6
23 5
11 8
21 8
19 6
13 4
29 4
26 8
24 7
27 8
10 8
28 7
10 6
13 7
16 5
28 5
13 8
15 6
14 4
11 5
17 7
11 7
18 6
19 4
12 6
29 7
10 5
24 5
26 6
14 5
17 6
28 6
13 5
19 7
16 7
12 4
26 4
17 ...

output:

YES 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
YES 2 19 2 2 1 2 2 2 17 55 1 607 2 19 184 184 184 55 2 55 
YES 6 33 33 33 7 33 1 33 1 33 13 33 ...

result:

ok 50 testow OK.

Test #35:

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

input:

20
208
43084695 121670368
64084287 121249054
84789063 129104243
43111011 121653667
70260346 121249054
84789063 128641969
123055367 121584279
43110545 121671591
43116571 121666497
43120695 121667255
61024570 125320326
97639998 124897259
43121497 121667545
43014605 121680179
43121652 121667224
4095451...

output:

YES 2237 6176059 3290447 12830 6427611 462274 547737 466 3578 494 3059717 1791485 14 903 80 1265908 1856720 5572818 3801376 270 290510 33802 11428 217633 8941 146 41 243 1961138 5640711 370 80856 4714766 1720934 2009599 22834 2655488 54 5560 228751 352 251449 73864 39 41640773 65 11977 2198843 15316...

result:

ok 20 testow OK.

Test #36:

score: 0
Accepted
time: 32ms
memory: 6964kb

input:

16
798
10577381 60726
10577477 46893
28762196 46893
10577461 46893
21261954 46893
10577381 62056
14752310 46893
10577381 109670
10577381 71632
13549441 46893
24658290 46893
26993271 46893
10577631 46893
11355974 46893
10577615 46893
10577381 84666
10577381 78016
10577381 85198
18290160 46893
1057748...

output:

YES 266 1 70757 1 70757 266 70757 266 266 70757 70757 70757 1 70757 1 266 266 266 70757 1 1 266 70757 266 1 1 1 1 70757 70757 70757 70757 1 1 266 1 266 266 1 266 266 70757 266 266 1 266 1 1 70757 266 1 70757 1 70757 70757 70757 1 70757 1 266 266 266 266 266 70757 266 1 1 70757 70757 70757 1 266 266 ...

result:

ok 16 testow OK.

Test #37:

score: 0
Accepted
time: 56ms
memory: 7056kb

input:

13
1450
6689018 2395831
6696589 2576334
6682498 2386644
6682764 2387239
6688236 2395849
6683074 2393026
6682764 2391743
6682498 2392869
6644560 2386681
9002528 2568639
6644404 5413411
6682693 2386203
6694420 2575999
6682651 2386160
6689452 2395831
6688236 2395833
9002432 2740063
6682666 2386737
6682...

output:

NO
YES 5 5 5 25 5 125 5 5 15 5 5 15 5 5 5 5 5 5 15 5 15 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 25 5 5 5 5 15 5 5 5 5 5 5 5 5 15 5 25 5 25 5 5 5 5 25 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 25 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 15 5 5 5 5 15 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 25 5 5 5 5 15 5 25 5 5 5 5 5 ...

result:

ok 13 testow OK.

Test #38:

score: 0
Accepted
time: 21ms
memory: 7060kb

input:

30
1944
44685283 3918162
44685271 3923553
44685350 3921534
44685324 3910111
46087141 3777622
44685400 3910888
44688306 3777993
44685328 3912135
44685342 3912388
44685371 3920222
44685313 3916474
44685318 3920988
44689845 3778074
51832661 3777622
44685283 3916687
44685271 3916216
47654101 3777622
446...

output:

YES 43 42 50 4 130580 70 148 14 38 9 37 6 67 130580 35 42 130580 54 14 20 19 25 54 43 45 20 6 130580 9 66 9 54 14 130580 3001392 36 45 45 66 24 54 36 70 36 9 43 20 15 20 130580 49 66 130580 7244 4 63 20 130580 155 50 45 20 6 37 35 26 2 120 10 130580 70 25 4 70 44 50 114 130580 47 38 130580 50 42 38 ...

result:

ok 30 testow OK.

Test #39:

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

input:

11
1169
952 303
932 158
652 163
887 303
352 418
602 53
347 98
447 368
952 118
602 113
597 618
452 358
632 48
907 648
582 103
587 118
832 648
902 148
332 358
882 53
682 53
437 598
602 558
932 308
702 148
382 558
352 568
907 398
947 298
947 398
637 648
942 118
652 658
442 118
442 418
392 148
357 398
3...

output:

YES 5 5 5 15 5 5 5 5 5 5 5 5 5 25 5 5 5 5 5 5 5 5 5 5 5 5 5 25 5 5 5 5 5 5 5 5 25 5 5 5 5 15 5 5 5 5 5 5 5 5 5 5 5 15 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 25 5 5 5 5 5 5 5 5 5 5 5 5 5 5 15 125 15 5 5 5 5 5 5 5 15 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 15 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 15 5 25 5...

result:

ok 11 testow OK.

Test #40:

score: 0
Accepted
time: 51ms
memory: 7008kb

input:

12
1918
19986896 94336
19497276 2320
19497244 94336
19497308 1036
19497243 102166
28867812 94336
19497313 3104
19497243 108400
29881195 0
19497306 3157
36296043 0
39220459 0
25353067 0
19497937 104076
19497293 3390
37899755 0
19497791 102233
19497702 104076
19497293 2733
21393098 167732
19497552 968...

output:

YES 73396 37 8 17 156 73396 42 156 94336 7 94336 94336 94336 36 15 94336 146 235 35 369204 150 6 19 151 15 151 36 16 37 89 149 73396 6992 151 73396 35 190 94336 9 35 73396 8 73396 149 94336 4 89 35 491 17 25 94336 7533585 156 11 235 2 94336 17 42 25 50 19 94336 1 2 2 94336 1 89 15143 18678805 323150...

result:

ok 12 testow OK.

Test #41:

score: 0
Accepted
time: 85ms
memory: 7120kb

input:

12
1941
194439360 10224121
95083934 10316590
95092225 10224499
95085450 10224337
95089782 10224379
95083991 10300990
95083997 10315525
95084059 10224414
95083430 10643389
95083821 10307180
95083589 10321015
95083646 10302558
95092394 10224485
95083684 10312368
95083821 10299160
95083865 10317025
950...

output:

NO
YES 50 63 32 186 45 18 124 444 46938 63 94 124 186 218 94 52 542 87 32 186 81 219 76 34 63 94 94 233356 45 137 542 233356 443 18 34 34 413 478 413 34 233356 142 100 94 137 65 100 413 444 94 255 76 233356 65 87 110 32 99 6 34 34 413 162 37 413 25 444 76 32 443 76 94 413 56 444 100 99 478 413 65 18...

result:

ok 12 testow OK.

Test #42:

score: 0
Accepted
time: 48ms
memory: 7068kb

input:

3
1998
667191 296
513123 296
383046 296
396892 296
334284 597
510369 296
602476 296
513171 297
630168 597
513570 297
513300 297
513525 297
513078 361
410136 597
495018 296
513139 296
597660 597
513471 296
513078 793
600369 296
347829 296
346023 597
407427 296
581406 296
387862 296
685552 296
513078 ...

output:

YES 301 1 301 602 301 301 602 1 301 1 1 1 3 301 301 2 301 1 3 301 301 301 301 301 602 602 3 1 1 602 2 301 1 3 3 1 2 301 1 602 301 301 602 602 602 602 301 301 301 301 301 301 3 301 301 301 301 301 1 2 301 2 1 301 301 301 301 301 301 301 301 301 3 301 301 301 301 301 301 2 2 2 3 602 3 602 301 1 1 301 ...

result:

ok 3 testow OK.