QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#22845#2882. New White-Black TreeQyc_AK_NOI2022#AC ✓210ms37000kbC++118.6kb2022-03-10 18:13:272022-04-30 01:47:12

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 01:47:12]
  • 评测
  • 测评结果:AC
  • 用时:210ms
  • 内存:37000kb
  • [2022-03-10 18:13:27]
  • 提交

answer

#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<set>
#include<ctime>
#include<assert.h>
#define _INT_INF ((int)0x3f3f3f3f)
#define _UINT_MAX ((unsigned int)0xffffffff)
#define _INT_MAX ((int)0x7fffffff)
#define _LL_INF ((long long)0x3f3f3f3f3f3f3f3f)
#define _ULL_MAX ((unsigned long long)0xffffffffffffffff)
#define _LL_MAX ((long long)0x7fffffffffffffff)
namespace FastIO{
	#define inline __attribute__((always_inline)) inline
#ifdef LOCAL
	#define getChar getchar()
#else
	#define BUF_SIZE 33554432
	char __buff__[BUF_SIZE];char *__p1__=__buff__,*__p2__=__buff__;
	#define getChar (__p1__==__p2__&&(__p2__=(__p1__=__buff__)+fread(__buff__,1,BUF_SIZE,stdin),__p1__==__p2__)?EOF:*__p1__++)
#endif
	inline int read(){
		register int x=0;register char c=getChar;
		while(c<'0'||c>'9')	c=getChar;while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getChar;return x;
	}
	inline int reads(){
		register int x=0,y=1;register char c=getChar;
		while(c<'0'||c>'9') y&=(c!='-'),c=getChar;while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getChar;return y?x:-x;
	}
	inline long long readl(){
		register long long x=0;register char c=getChar;
		while(c<'0'||c>'9') c=getChar;while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getChar;return x;
	}
	inline int readsl(){
		register long long x=0;register int y=1;register char c=getChar;
		while(c<'0'||c>'9') y&=(c!='-'),c=getChar;while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getChar;return y?x:-x;
	}
	inline void read(char *s){
		register char c=getChar;while(c=='\n'||c=='\r'||c==' '||c=='\t') c=getChar;
        while(c!='\n'&&c!='\r'&&c!=' '&&c!='\t'&&c!=EOF) *s=c,s++,c=getChar;*s=0;
	}
	#undef getChar
	#define EN write('\n')
	#define SPACE write(' ')
#ifdef LOCAL
	#define RET 0
	inline void write(register int x){printf("%d",x);}
	inline void writeEN(register int x){printf("%d\n",x);}
	inline void writeSP(register int x){printf("%d ",x);}
	inline void write(register long long x){printf("%lld",x);}
	inline void writeEN(register long long x){printf("%lld\n",x);}
	inline void writeSP(register long long x){printf("%lld ",x);}
	inline void write(register char c){printf("%c",c);}
	inline void write(const char *c){printf("%s",c);}
#else
	#undef BUF_SIZE
	#define RET fwrite(__buffW__,1,__bb__,stdout),0
	#define BUFW_SIZE 33554432
	char __buffW__[BUFW_SIZE];int __bb__;
	char __stack__[28];
	inline void write(register int x,register short base=10){
		if(!x) return __buffW__[__bb__++]='0',void();if(x<0) __buffW__[__bb__++]='-',x=-x;
		register short top=0;
		while(x) __stack__[++top]=(x%base)^48,x/=base;while(top) __buffW__[__bb__++]=__stack__[top--];
	}
	inline void writeEN(register int x,register short base=10){
		if(!x) return __buffW__[__bb__++]='0',__buffW__[__bb__++]='\n',void();if(x<0) __buffW__[__bb__++]='-',x=-x;
		register short top=0;
		while(x) __stack__[++top]=(x%base)^48,x/=base;while(top) __buffW__[__bb__++]=__stack__[top--];__buffW__[__bb__++]='\n';
	}
	inline void writeSP(register int x,register short base=10){
		if(!x) return __buffW__[__bb__++]='0',__buffW__[__bb__++]=' ',void();if(x<0) __buffW__[__bb__++]='-',x=-x;
		register short top=0;
		while(x) __stack__[++top]=(x%base)^48,x/=base;while(top) __buffW__[__bb__++]=__stack__[top--];__buffW__[__bb__++]=' ';
	}
	inline void write(register long long x,register short base=10){
		if(!x) return __buffW__[__bb__++]='0',void();if(x<0) __buffW__[__bb__++]='-',x=-x;
		register short top=0;
		while(x) __stack__[++top]=(x%base)^48,x/=base;while(top) __buffW__[__bb__++]=__stack__[top--];
	}
	inline void writeEN(register long long x,register short base=10){
		if(!x) return __buffW__[__bb__++]='0',__buffW__[__bb__++]='\n',void();if(x<0) __buffW__[__bb__++]='-',x=-x;
		register short top=0;
		while(x) __stack__[++top]=(x%base)^48,x/=base;while(top) __buffW__[__bb__++]=__stack__[top--];__buffW__[__bb__++]='\n';
	}
	inline void writeSP(register long long x,register short base=10){
		if(!x) return __buffW__[__bb__++]='0',__buffW__[__bb__++]=' ',void();if(x<0) __buffW__[__bb__++]='-',x=-x;
		register short top=0;
		while(x) __stack__[++top]=(x%base)^48,x/=base;while(top) __buffW__[__bb__++]=__stack__[top--];__buffW__[__bb__++]=' ';
	}
	inline void write(register char c){__buffW__[__bb__++]=c;}
	inline void write(const char *c){while(*c) __buffW__[__bb__++]=*c,c++;}
	#undef BUFW_SIZE
#endif
#undef inline
}//namespace FastIO
using namespace FastIO;
namespace lib{
#define inline __attribute__((always_inline)) inline
	inline void chkMin(int &a,const int &b){(a>b)&&(a=b);}
	inline void chkMin(long long &a,const long long &b){(a>b)&&(a=b);}
	inline void chkMax(int &a,const int &b){(a<b)&&(a=b);}
	inline void chkMax(long long &a,const long long &b){(a<b)&&(a=b);}
	inline int min(const int &a,const int &b){return a>b?b:a;}
	inline long long min(const long long &a,const long long &b){return a>b?b:a;}
	inline int max(const int &a,const int &b){return a>b?a:b;}
	inline long long max(const long long &a,const long long &b){return a>b?a:b;}
	inline void swap(int &a,int &b){a^=b;b^=a;a^=b;}
	inline void swap(long long &a,long long &b){a^=b;b^=a;a^=b;}
	inline int abs(const int &a){return a>0?a:-a;}
	inline long long abs(const long long &a){return a>0?a:-a;}
#undef inline
}
#define N 300006
struct Node{
	int u,deg;
	__attribute__((always_inline))inline int operator < (const Node &o){return deg==o.deg?u<o.u:deg<o.deg;}
	__attribute__((always_inline))inline int operator == (const Node &o){return u==o.u&&deg==o.deg;}
};
__attribute__((always_inline))inline void swap(Node &a,Node &b){lib::swap(a.u,b.u);lib::swap(a.deg,b.deg);}
struct Heap{
	Node a[N*30];
	int size;
	inline void push(const Node &x){
		int i=++size,fa;a[size]=x;
		while(i>1){
			fa=i>>1;
			if(a[fa]<a[i]) return;
			swap(a[fa],a[i]);i=fa;
		}
	}
	inline void pop(){
		int i=1,ls,rs;a[1]=a[size--];
		while((i<<1)<=size){
			ls=i<<1;rs=ls|1;
			if(rs<=size&&a[rs]<a[ls]) ls=rs;
			if(a[i]<a[ls]) return;
			swap(a[ls],a[i]);i=ls;
		}
	}
};
struct DeletableHeap{
	Heap ins,dele;
//		int debug;
	inline Node top(){
		while(dele.size&&ins.a[1]==dele.a[1]) ins.pop(),dele.pop();
		return ins.a[1];
	}
	inline void pop(){
		while(dele.size&&ins.a[1]==dele.a[1]) ins.pop(),dele.pop();
//			assert(ins.size);
//			if(debug) printf("	pop : %d %d size= %d\n",ins.a[1].u,ins.a[1].deg,size());
		ins.pop();
	}
	__attribute__((always_inline))inline void push(const Node &x){
//			if(debug) printf("ins : %d %d size= %d\n",x.u,x.deg,size());
		ins.push(x);
	}
	__attribute__((always_inline))inline void del(const Node &x){
//			if(debug) printf("del : %d %d size= %d\n",x.u,x.deg,size());
		dele.push(x);
	}
	__attribute__((always_inline))inline void clear(){ins.size=dele.size=0;}
	__attribute__((always_inline))inline int size(){return ins.size-dele.size;}
	__attribute__((always_inline))inline int empty(){return ins.size==dele.size;}
};
int n;
int w[N],b[N];
DeletableHeap que,queW,queB;
int u[N],v[N];
char col[N];
int tot;
inline void add(int a,int b,char ch){u[++tot]=a;v[tot]=b;col[tot]=ch;}
inline void output(){
	write("Yes\n");
	for(int i=1;i<n;i++) writeSP(u[i]),writeSP(v[i]),write(col[i]),EN;
}
#define FAIL {write("No\n");goto OVER;}
int main(){
//		printf("%lld\n",3*sizeof que);
int $=read();while($--){
	n=read();tot=0;
	int W=0,B=0;
	for(int i=1;i<=n;i++) w[i]=read(),b[i]=read(),W+=w[i],B+=b[i];
	if((W&1)||(B&1)) FAIL;
	if(W+B!=n+n-2) FAIL;
	if(n==1){
		if(w[1]||b[1]) FAIL;
		write("Yes\n");continue;
	}
	for(int i=1;i<=n;i++)if(w[i]+b[i]>=n||!(w[i]+b[i])) FAIL;
	que.clear();queW.clear();queB.clear();
//		queW.debug=1;
	for(int i=1;i<=n;i++){
		que.push((Node){i,w[i]+b[i]});
		if(w[i]+b[i]>1&&w[i]) queW.push((Node){i,-w[i]});
		if(w[i]+b[i]>1&&b[i]) queB.push((Node){i,-b[i]});
	}
	while(que.size()>2){
		int u=que.top().u,v;que.pop();
		if(w[u]+b[u]>1) FAIL;
		if(w[u]){
			if(queW.empty()) FAIL;
			v=queW.top().u;queW.pop();
			que.del((Node){v,w[v]+b[v]});
			if(w[v]+b[v]>1&&b[v]) queB.del((Node){v,-b[v]});
			w[v]--;
			que.push((Node){v,w[v]+b[v]});
			if(w[v]+b[v]>1&&w[v]) queW.push((Node){v,-w[v]});
			if(w[v]+b[v]>1&&b[v]) queB.push((Node){v,-b[v]});
			add(u,v,'W');
		}
		else if(b[u]){
			if(queB.empty()) FAIL;
			v=queB.top().u;queB.pop();
			que.del((Node){v,w[v]+b[v]});
			if(w[v]+b[v]>1&&w[v]) queW.del((Node){v,-w[v]});
			b[v]--;
			que.push((Node){v,w[v]+b[v]});
			if(w[v]+b[v]>1&&b[v]) queB.push((Node){v,-b[v]});
			if(w[v]+b[v]>1&&w[v]) queW.push((Node){v,-w[v]});
			add(u,v,'B');
		}
	}
	W=que.top().u;que.pop();
	B=que.top().u;
	if(w[W]!=w[B]||b[W]!=b[B]) FAIL;
	add(W,B,w[W]?'W':'B');
	output();
OVER:;
}
	return RET;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

Yes
3 1 W
1 2 B
2 4 W
No
Yes
Yes
1 2 B
No
No

result:

ok 3 'Yes' out of 6 cases (6 test cases)

Test #2:

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

input:

23072
2
1 0
1 0
2
0 1
0 1
3
1 0
1 0
2 0
3
2 0
0 1
0 1
3
0 2
1 0
1 0
3
1 0
1 1
0 1
3
0 1
0 1
0 2
4
3 0
1 0
1 0
1 0
4
1 0
1 0
2 0
2 0
4
1 0
0 1
3 0
0 1
4
2 0
0 1
2 0
0 1
4
1 0
2 0
1 0
0 2
4
1 0
2 0
1 1
0 1
4
1 0
1 0
2 1
0 1
4
1 0
1 0
1 2
1 0
4
1 1
1 0
1 1
1 0
4
0 2
0 1
0 1
2 0
4
2 1
0 1
0 1
0 1
4
1 0
...

output:

Yes
1 2 W
Yes
1 2 B
Yes
1 3 W
2 3 W
No
No
Yes
1 2 W
2 3 B
Yes
1 3 B
2 3 B
Yes
2 1 W
3 1 W
1 4 W
Yes
1 3 W
2 4 W
3 4 W
No
No
No
Yes
1 2 W
2 3 W
3 4 B
Yes
1 3 W
2 3 W
3 4 B
No
Yes
2 1 W
1 3 B
3 4 W
No
No
No
No
Yes
1 4 B
3 2 W
2 4 B
Yes
1 3 W
2 3 B
3 4 B
Yes
1 2 B
2 3 W
3 4 B
Yes
1 3 B
2 3 B
3 4 B
Yes
...

result:

ok 11912 'Yes' out of 23072 cases (23072 test cases)

Test #3:

score: 0
Accepted
time: 36ms
memory: 21928kb

input:

25000
12
4 1
1 0
1 0
2 0
1 0
0 2
0 1
1 1
1 0
1 2
1 0
1 1
12
1 0
2 0
0 2
1 0
0 1
2 0
0 1
1 0
0 3
0 2
1 0
0 5
12
0 1
0 1
1 0
0 1
0 2
0 2
4 5
1 0
0 1
0 1
1 0
1 0
12
2 0
1 0
1 0
1 3
1 0
1 0
1 0
1 0
0 3
1 0
0 3
0 3
12
0 1
1 1
0 1
0 2
0 1
5 0
0 1
0 1
1 1
1 1
3 0
1 0
12
0 2
0 1
0 1
0 1
1 1
3 0
0 4
0 3
2 0
...

output:

Yes
2 1 W
3 1 W
5 1 W
7 6 B
6 10 B
9 4 W
4 1 W
1 8 B
8 10 W
10 12 B
11 12 W
No
Yes
1 7 B
2 7 B
3 7 W
4 7 B
8 7 W
9 5 B
5 6 B
6 7 B
10 7 B
11 7 W
7 12 W
No
No
No
Yes
2 8 B
3 8 B
4 12 B
6 1 W
7 1 W
9 5 W
5 1 W
1 8 B
8 12 B
11 10 W
10 12 B
Yes
3 12 W
4 12 W
7 1 W
1 10 W
8 11 W
9 2 B
2 5 B
5 6 B
6 10 B
...

result:

ok 13004 'Yes' out of 25000 cases (25000 test cases)

Test #4:

score: 0
Accepted
time: 39ms
memory: 21956kb

input:

23076
13
0 3
0 2
2 0
1 1
3 0
0 2
1 0
1 0
1 0
2 0
1 0
1 2
1 0
13
0 1
3 2
1 2
1 0
0 1
0 1
0 1
2 0
0 1
1 4
1 0
0 1
1 0
13
0 3
0 1
0 1
0 1
2 0
0 1
0 1
1 0
6 0
2 0
0 1
3 0
0 1
13
7 1
1 2
2 0
1 0
0 1
1 0
0 1
0 1
1 0
1 0
2 0
1 0
1 0
13
0 1
0 1
0 1
1 1
1 1
3 0
1 1
0 1
0 1
1 5
0 1
0 1
1 1
13
0 1
1 1
1 0
1 0
...

output:

No
Yes
1 10 B
4 2 W
5 10 B
6 2 B
7 3 B
9 10 B
11 2 W
12 2 B
2 8 W
8 3 W
3 10 B
10 13 W
No
Yes
4 1 W
5 2 B
6 1 W
7 1 B
8 2 B
2 1 W
9 1 W
10 1 W
12 1 W
1 3 W
3 11 W
11 13 W
Yes
1 10 B
2 10 B
3 10 B
8 10 B
9 4 B
4 6 W
11 5 B
5 6 W
6 7 W
7 10 B
10 13 W
12 13 B
Yes
1 13 B
3 8 W
4 8 W
5 2 W
2 13 B
7 6 B
9...

result:

ok 11876 'Yes' out of 23076 cases (23076 test cases)

Test #5:

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

input:

12720
1
0 0
2
1 0
1 0
2
0 1
0 1
3
0 0
2 0
2 0
3
1 0
2 0
1 0
3
2 0
0 0
0 2
3
0 1
2 0
0 1
3
1 0
1 0
0 2
3
1 1
0 1
1 0
3
0 0
1 1
1 1
3
0 0
0 2
0 2
3
0 1
0 1
0 2
4
0 0
0 0
3 0
3 0
4
3 0
2 0
0 0
1 0
4
1 0
3 0
1 0
1 0
4
2 0
0 0
2 0
2 0
4
1 0
2 0
1 0
2 0
4
0 2
1 0
3 0
0 0
4
0 0
3 0
1 2
0 0
4
0 1
1 0
0 1
3 ...

output:

Yes
Yes
1 2 W
Yes
1 2 B
No
Yes
1 2 W
2 3 W
No
No
No
Yes
2 1 B
1 3 W
No
No
Yes
1 3 B
2 3 B
No
No
Yes
1 2 W
3 2 W
2 4 W
No
Yes
1 2 W
2 4 W
3 4 W
No
No
No
No
No
No
No
No
No
No
Yes
1 3 W
3 2 W
2 4 B
Yes
1 2 B
3 2 W
2 4 W
No
No
No
Yes
2 1 W
1 4 B
3 4 W
No
No
No
No
No
No
No
No
No
No
No
Yes
1 2 W
2 3 B
3 4...

result:

ok 851 'Yes' out of 12720 cases (12720 test cases)

Test #6:

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

input:

33907
8
0 1
1 0
0 2
2 0
1 2
0 1
1 0
3 0
8
1 0
2 2
1 0
0 2
0 1
3 0
1 0
0 1
8
1 0
0 1
0 2
3 2
0 1
1 0
1 0
2 0
8
1 1
0 2
3 0
0 0
0 2
1 1
1 0
2 0
8
1 1
2 1
0 2
0 2
1 0
1 0
0 0
3 0
8
0 2
2 0
1 0
1 0
1 1
0 2
3 1
0 0
8
3 1
1 0
1 0
0 2
0 2
2 1
0 0
1 0
8
0 2
1 2
0 0
1 0
3 0
1 1
2 0
0 1
8
2 1
0 2
1 2
1 0
0 1
...

output:

Yes
1 3 B
2 8 W
3 5 B
6 5 B
5 4 W
4 8 W
7 8 W
Yes
1 6 W
3 2 W
5 2 B
7 6 W
6 2 W
2 4 B
4 8 B
Yes
1 4 W
2 3 B
3 4 B
5 4 B
6 4 W
4 8 W
7 8 W
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
2 3 B
3 1 B
1 6 W
7 4 B
4 5 W
5 6 W
6 8 W...

result:

ok 1643 'Yes' out of 33907 cases (33907 test cases)

Test #7:

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

input:

10165
1
0 0
2
1 0
1 0
2
0 1
0 1
3
2 0
2 0
0 0
3
2 0
0 0
2 0
3
0 0
2 0
2 0
3
2 0
1 0
1 0
3
1 0
2 0
1 0
3
1 0
1 0
2 0
3
2 0
0 2
0 0
3
2 0
0 0
0 2
3
0 2
2 0
0 0
3
0 2
0 0
2 0
3
0 0
2 0
0 2
3
0 0
0 2
2 0
3
2 0
0 1
0 1
3
0 1
2 0
0 1
3
0 1
0 1
2 0
3
1 0
1 0
0 2
3
1 0
0 2
1 0
3
0 2
1 0
1 0
3
1 1
1 0
0 1
3
...

output:

Yes
Yes
1 2 W
Yes
1 2 B
No
No
No
Yes
2 1 W
1 3 W
Yes
1 2 W
2 3 W
Yes
1 3 W
2 3 W
No
No
No
No
No
No
No
No
No
No
No
No
Yes
2 1 W
1 3 B
Yes
2 1 B
1 3 W
Yes
1 2 W
2 3 B
Yes
1 3 W
2 3 B
Yes
1 2 B
2 3 W
Yes
1 3 B
2 3 W
No
No
No
No
No
No
Yes
2 1 B
1 3 B
Yes
1 2 B
2 3 B
Yes
1 3 B
2 3 B
No
No
No
No
No
No
No
...

result:

ok 1159 'Yes' out of 10165 cases (10165 test cases)

Test #8:

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

input:

50000
6
2 2
0 0
1 0
1 0
0 0
0 4
6
0 2
0 4
1 0
1 2
0 0
0 0
6
0 1
3 0
1 0
0 0
4 1
0 0
6
0 0
3 2
0 0
0 1
1 3
0 0
6
0 2
1 0
0 1
0 0
0 1
1 4
6
0 3
0 0
2 1
0 0
0 2
0 2
6
0 2
0 0
1 3
2 0
1 1
0 0
6
2 0
1 0
0 1
0 0
1 0
0 5
6
0 0
2 1
1 0
0 0
5 0
0 1
6
2 1
0 1
0 0
1 0
1 0
4 0
6
0 0
0 0
0 2
0 4
2 0
0 2
6
0 0
2 ...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
2 1 W
3 1 B
5 1 W
1 4 W
4 6 W
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
1 4 W
2 4 W
4 5 W
5 3 B
3 6 B
No
No
Yes
3 2 B
4 2 B
5 1 B
1 2 W
2 6 B
No
No
No
No
No
No
Yes
1 4 W
2 ...

result:

ok 3607 'Yes' out of 50000 cases (50000 test cases)

Test #9:

score: 0
Accepted
time: 40ms
memory: 23920kb

input:

26462
9
1 0
0 1
1 1
3 1
1 3
0 1
0 1
1 0
1 0
9
1 0
3 3
1 0
0 1
1 1
1 0
0 1
0 1
1 1
9
2 0
0 1
0 3
2 1
0 1
0 1
2 0
2 0
0 1
9
3 2
1 0
1 0
1 0
1 0
1 0
0 2
0 2
0 2
9
0 1
2 0
1 1
0 3
2 0
0 1
0 1
1 1
2 0
9
1 0
0 2
1 0
0 2
1 1
1 0
1 0
0 2
3 1
9
2 1
0 1
0 3
2 0
1 0
0 1
0 1
2 0
1 1
9
1 2
3 1
1 0
1 0
0 2
1 0
0 ...

output:

Yes
1 4 W
2 5 B
6 5 B
7 3 B
3 4 W
8 4 W
4 5 B
5 9 W
Yes
1 2 W
3 2 W
4 2 B
6 2 W
7 2 B
2 5 B
5 9 W
8 9 B
No
No
Yes
1 4 B
6 4 B
4 3 B
3 2 W
2 5 W
5 9 W
7 8 B
8 9 W
Yes
1 9 W
3 9 W
6 5 W
5 2 B
2 4 B
4 8 B
7 9 W
8 9 B
Yes
2 3 B
5 1 W
6 3 B
3 1 B
1 4 W
4 8 W
7 9 B
8 9 W
Yes
3 2 W
4 2 W
6 1 W
7 1 B
1 5 B
...

result:

ok 13715 'Yes' out of 26462 cases (26462 test cases)

Test #10:

score: 0
Accepted
time: 37ms
memory: 22016kb

input:

23076
13
2 2
0 2
0 1
2 0
2 0
0 2
1 0
0 2
0 1
1 1
0 1
0 2
2 0
13
0 1
3 0
3 0
1 0
0 1
0 1
3 1
1 0
0 1
1 0
3 0
0 1
3 0
13
1 3
0 1
4 0
0 1
1 0
0 2
0 1
0 1
1 0
1 0
2 0
2 0
0 3
13
2 1
0 1
0 1
1 0
1 2
1 0
2 1
1 0
1 0
1 0
0 1
0 4
2 1
13
2 0
4 0
1 0
0 1
1 0
1 3
2 0
2 0
1 0
1 0
0 2
2 0
1 0
13
2 1
0 1
0 1
1 0
...

output:

Yes
3 1 B
7 1 W
9 2 B
2 6 B
6 8 B
8 12 B
11 1 B
1 4 W
4 5 W
5 13 W
12 10 B
10 13 W
No
Yes
2 1 B
4 13 B
5 3 W
7 1 B
8 6 B
6 13 B
9 3 W
10 3 W
3 11 W
11 12 W
12 1 W
1 13 B
Yes
2 12 B
3 12 B
4 1 W
6 7 W
8 13 W
9 1 W
1 5 B
10 5 W
5 12 B
11 7 B
7 13 W
12 13 B
No
No
No
Yes
1 3 B
2 3 B
4 3 B
5 3 B
7 9 W
8 ...

result:

ok 11905 'Yes' out of 23076 cases (23076 test cases)

Test #11:

score: 0
Accepted
time: 39ms
memory: 24012kb

input:

21428
14
1 2
0 1
0 1
1 0
1 2
0 1
1 0
1 0
1 0
2 0
1 2
3 0
1 0
3 1
14
1 0
0 1
2 0
1 0
0 1
1 0
2 2
1 0
0 1
1 0
4 1
1 0
0 4
0 2
14
1 0
1 2
0 1
1 0
2 0
1 4
0 1
1 4
0 2
1 0
1 0
1 0
0 1
0 1
14
0 1
0 1
1 2
1 1
0 1
0 1
0 1
0 1
0 1
3 0
0 2
0 1
2 1
3 2
14
1 1
1 1
0 1
1 0
8 0
0 1
0 1
0 1
0 1
0 1
0 1
1 0
0 2
0 3...

output:

Yes
2 1 B
3 5 B
4 12 W
6 11 B
7 14 W
8 10 W
9 12 W
10 14 W
12 1 W
1 5 B
5 11 W
11 14 B
13 14 W
Yes
1 11 W
2 13 B
4 11 W
5 13 B
6 3 W
3 7 W
8 11 W
9 7 B
10 7 W
7 13 B
12 11 W
11 14 B
13 14 B
No
No
No
No
No
No
No
No
No
No
No
Yes
1 9 B
2 9 B
3 10 W
4 7 B
5 9 B
6 7 B
8 10 W
12 10 W
13 7 W
7 9 B
9 10 B
1...

result:

ok 11112 'Yes' out of 21428 cases (21428 test cases)

Test #12:

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

input:

66282
1
0 0
2
1 1
1 1
2
1 1
1 0
2
1 1
0 1
2
1 1
0 0
2
1 0
1 1
2
1 0
1 0
2
1 0
0 1
2
1 0
0 0
2
0 1
1 1
2
0 1
1 0
2
0 1
0 1
2
0 1
0 0
2
0 0
1 1
2
0 0
1 0
2
0 0
0 1
2
0 0
0 0
3
2 2
2 2
2 2
3
2 2
2 2
2 1
3
2 2
2 2
2 0
3
2 2
2 2
1 2
3
2 2
2 2
1 1
3
2 2
2 2
1 0
3
2 2
2 2
0 2
3
2 2
2 2
0 1
3
2 2
2 2
0 0
3
...

output:

Yes
No
No
No
No
No
Yes
1 2 W
No
No
No
No
Yes
1 2 B
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
...

result:

ok 119 'Yes' out of 66282 cases (66282 test cases)

Test #13:

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

input:

60000
5
0 0
0 2
1 4
1 3
4 3
5
0 0
0 3
2 1
2 0
0 1
5
0 0
0 2
0 2
3 0
3 0
5
0 0
0 1
2 3
4 0
0 3
5
0 0
0 0
1 0
4 4
3 2
5
0 0
0 1
0 0
0 3
4 0
5
0 0
0 2
2 4
3 2
2 4
5
0 0
0 1
3 2
4 2
4 4
5
0 0
0 0
4 3
0 1
1 4
5
0 0
0 0
4 1
4 4
3 3
5
0 0
0 0
4 4
1 3
0 3
5
0 0
0 1
0 3
3 4
4 3
5
0 0
0 3
2 1
2 3
1 0
5
0 0
0 ...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
...

result:

ok 0 'Yes' out of 60000 cases (60000 test cases)

Test #14:

score: 0
Accepted
time: 188ms
memory: 34176kb

input:

1
300000
1 1
0 2
0 1
1 0
0 2
0 1
0 2
1 0
0 1
1 1
0 4
2 2
0 1
1 1
1 1
3 1
0 1
2 2
0 1
0 8
1 1
1 1
2 4
1 0
1 0
0 1
2 1
1 1
0 1
1 1
0 1
2 2
0 1
0 3
2 0
7 3
1 0
1 0
1 1
1 0
2 1
0 2
1 0
2 0
2 2
0 1
1 0
1 0
0 3
0 1
1 0
2 0
1 3
1 0
0 1
0 1
1 0
3 1
2 0
0 1
1 2
0 1
2 3
1 0
3 0
0 1
1 0
0 1
0 1
2 0
2 0
2 1
1 1...

output:

Yes
3 30769 B
4 92220 W
6 155025 B
8 92220 W
9 30769 B
13 155025 B
17 287 B
19 30769 B
24 157058 W
25 92220 W
26 59507 B
29 79890 B
31 155025 B
33 157058 B
37 95333 W
38 157058 W
40 223452 W
43 19894 W
46 216449 B
47 92220 W
48 93940 W
50 293357 B
51 95333 W
54 108438 W
55 287 B
56 1808 B
57 110281 ...

result:

ok 1 'Yes' out of 1 cases (1 test case)

Test #15:

score: 0
Accepted
time: 210ms
memory: 37000kb

input:

1
300000
1 0
0 1
1 0
0 4
1 2
0 1
0 1
0 1
0 1
0 1
2 1
4 1
0 1
2 1
1 0
0 1
1 0
1 0
0 1
1 0
4 1
3 3
1 0
1 0
1 0
0 2
1 0
4 2
0 1
1 0
1 0
1 0
0 1
0 1
0 1
1 0
1 0
0 1
4 1
1 0
6 4
0 1
0 1
1 0
0 1
0 1
0 1
0 1
1 0
0 1
1 0
2 3
1 0
1 0
2 1
2 2
1 0
2 0
1 0
3 1
0 1
2 2
1 0
0 1
3 10
1 1
1 0
1 0
1 0
1 0
1 0
0 1
0 ...

output:

Yes
1 32000 W
2 54994 B
3 32000 W
6 54994 B
7 83719 B
8 15496 B
9 46538 B
10 54994 B
13 59778 B
15 32000 W
16 83719 B
17 38491 W
18 69012 W
19 111260 B
20 131701 W
23 16017 W
24 32000 W
25 37830 W
27 38491 W
29 124383 B
30 69012 W
31 82848 W
32 131701 W
33 175547 B
34 177211 B
35 15496 B
36 168140 W...

result:

ok 1 'Yes' out of 1 cases (1 test case)

Test #16:

score: 0
Accepted
time: 186ms
memory: 31940kb

input:

1
300000
1 0
0 1
1 0
0 1
0 1
1 0
0 1
0 1
1 0
1 0
1 0
0 1
0 1
17 25
0 1
1 0
1 0
1 0
0 1
0 1
0 1
0 1
1 0
0 1
0 1
0 1
1 0
0 1
2 0
1 0
1 0
0 1
1 0
0 1
0 1
1 0
1 0
1 0
1 0
0 1
1 0
1 0
0 1
0 1
0 1
0 1
1 0
0 1
1 0
0 1
0 1
0 1
4 3
1 0
0 1
0 1
0 1
0 1
1 0
0 1
1 0
0 1
0 1
1 0
1 0
0 1
0 1
1 0
14 14
0 1
0 1
0 1...

output:

Yes
1 150293 W
2 150293 B
3 150293 W
4 211921 B
5 150293 B
6 150293 W
7 211921 B
8 150293 B
9 150293 W
10 150293 W
11 150293 W
12 211921 B
13 150293 B
15 211921 B
16 150293 W
17 179819 W
18 203152 W
19 150293 B
20 211921 B
21 150293 B
22 211921 B
23 150293 W
24 150293 B
25 211921 B
26 150293 B
27 17...

result:

ok 1 'Yes' out of 1 cases (1 test case)

Test #17:

score: 0
Accepted
time: 128ms
memory: 33348kb

input:

1
300000
1 0
1 0
0 1
0 1
1 0
1 0
1 0
1 0
1 0
1 0
1 0
0 1
0 1
1 0
1 0
1 0
0 1
1 0
0 1
0 1
1 0
1 0
0 1
1 0
0 1
0 1
0 1
1 0
0 1
1 0
0 1
1 0
0 1
1 0
1 0
1 0
1 0
0 1
0 1
0 1
1 0
0 1
1 0
0 1
0 1
1 0
1 0
1 0
0 1
0 1
1 0
1 0
1 0
1 0
0 1
0 1
1 0
0 1
1 0
0 1
1 0
1 0
1 0
0 1
1 0
0 1
1 0
0 1
0 1
1 0
0 1
1 0
1 0...

output:

Yes
1 78478 W
2 78478 W
3 13628 B
4 13628 B
5 78478 W
6 78478 W
7 78478 W
8 78478 W
9 78478 W
10 78478 W
11 78478 W
12 13628 B
13 13628 B
14 78478 W
15 78478 W
16 78478 W
17 13628 B
18 78478 W
19 13628 B
20 13628 B
21 78478 W
22 78478 W
23 13628 B
24 78478 W
25 13628 B
26 13628 B
27 13628 B
28 78478...

result:

ok 1 'Yes' out of 1 cases (1 test case)

Test #18:

score: 0
Accepted
time: 119ms
memory: 30872kb

input:

1
300000
0 1
1 0
1 0
0 1
0 1
1 0
1 0
1 0
0 1
0 1
0 1
1 0
0 1
1 0
0 1
0 1
0 1
0 1
1 0
1 0
0 1
0 1
0 1
1 0
1 0
0 1
0 1
0 1
0 1
0 1
0 1
1 0
1 0
0 1
0 1
1 0
0 1
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
0 1
1 0
0 1
0 1
0 1
0 1
1 0
0 1
0 1
1 0
1 0
1 0
0 1
0 1
1 0
1 0
0 1
0 1
1 0
1 0
1 0
1 0
1 0
1 0
0 1
1 0
1 0
0 1...

output:

Yes
1 99999 B
2 182618 W
3 182618 W
4 99999 B
5 99999 B
6 182618 W
7 182618 W
8 182618 W
9 99999 B
10 99999 B
11 99999 B
12 182618 W
13 99999 B
14 182618 W
15 99999 B
16 99999 B
17 99999 B
18 99999 B
19 182618 W
20 182618 W
21 99999 B
22 99999 B
23 99999 B
24 182618 W
25 182618 W
26 99999 B
27 99999...

result:

ok 1 'Yes' out of 1 cases (1 test case)

Test #19:

score: 0
Accepted
time: 104ms
memory: 23924kb

input:

395
845
1 0
1 0
1 0
1 0
1 0
0 1
0 1
0 1
0 1
0 1
1 0
1 0
0 1
1 0
1 0
1 0
0 1
1 0
0 1
0 1
1 0
0 1
0 1
0 1
1 0
0 1
0 1
1 0
1 0
1 0
0 1
1 0
1 0
0 1
1 0
1 0
0 1
1 0
1 0
0 1
0 1
0 1
1 0
1 0
0 1
1 0
27 51
1 0
1 0
1 0
1 0
0 1
0 1
0 1
1 0
1 0
3 6
0 1
1 0
0 1
1 0
1 0
0 1
1 0
1 0
0 1
1 0
1 0
1 0
1 0
0 1
0 1
0 ...

output:

Yes
1 194 W
2 47 W
3 194 W
4 47 W
5 119 W
6 47 B
7 47 B
8 47 B
9 47 B
10 47 B
11 194 W
12 47 W
13 47 B
14 119 W
15 194 W
16 47 W
17 47 B
18 119 W
19 47 B
20 47 B
21 194 W
22 47 B
23 47 B
24 47 B
25 47 W
26 47 B
27 47 B
28 119 W
29 194 W
30 47 W
31 47 B
32 119 W
33 194 W
34 47 B
35 256 W
36 490 W
37 ...

result:

ok 395 'Yes' out of 395 cases (395 test cases)

Test #20:

score: 0
Accepted
time: 133ms
memory: 34068kb

input:

1
300000
2 0
0 2
2 0
1 1
1 1
1 1
2 0
2 0
2 0
2 0
1 1
0 2
2 0
2 0
0 2
1 1
1 1
1 1
0 2
0 2
0 2
2 0
2 0
0 2
0 2
2 0
2 0
0 2
0 2
1 1
1 1
2 0
1 1
1 1
1 1
2 0
2 0
1 1
2 0
1 1
1 1
2 0
2 0
2 0
1 1
2 0
1 1
0 2
1 1
1 1
1 1
2 0
0 2
1 1
0 2
0 2
2 0
2 0
1 1
1 1
1 1
2 0
2 0
2 0
0 2
1 1
2 0
0 2
1 1
1 1
2 0
0 2
1 1...

output:

Yes
5613 2 B
2 12 B
12 15 B
15 19 B
19 20 B
20 21 B
21 24 B
24 25 B
25 28 B
28 29 B
29 48 B
48 53 B
53 55 B
55 56 B
56 65 B
65 68 B
68 72 B
72 76 B
76 82 B
82 97 B
97 98 B
98 101 B
101 104 B
104 111 B
111 112 B
112 113 B
113 117 B
117 121 B
121 131 B
131 135 B
135 144 B
144 151 B
151 155 B
155 157 B...

result:

ok 1 'Yes' out of 1 cases (1 test case)

Test #21:

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

input:

1
10
2 0
1 1
1 1
0 2
0 1
2 0
2 0
0 2
1 1
1 0

output:

Yes
5 4 B
4 8 B
8 2 B
2 1 W
1 6 W
6 7 W
7 3 W
3 9 B
9 10 W

result:

ok 1 'Yes' out of 1 cases (1 test case)

Test #22:

score: 0
Accepted
time: 65ms
memory: 24004kb

input:

398
588
2 0
1 1
0 2
0 2
1 1
2 0
2 0
0 2
1 1
0 2
2 0
2 0
1 1
0 2
1 1
2 0
2 0
1 1
1 1
0 2
0 2
1 1
1 1
2 0
2 0
1 1
1 1
1 1
1 1
1 1
2 0
1 1
2 0
1 1
0 2
1 1
2 0
2 0
1 1
1 1
2 0
1 1
1 1
0 2
0 2
1 1
2 0
0 2
2 0
2 0
1 1
1 1
2 0
2 0
1 1
0 2
2 0
0 2
1 1
2 0
1 1
0 2
0 2
1 1
0 2
0 2
2 0
1 1
2 0
0 2
0 2
1 1
1 1
...

output:

Yes
331 1 W
1 6 W
6 7 W
7 11 W
11 12 W
12 16 W
16 17 W
17 24 W
24 25 W
25 31 W
31 33 W
33 37 W
37 38 W
38 41 W
41 47 W
47 49 W
49 50 W
50 53 W
53 54 W
54 57 W
57 60 W
60 67 W
67 69 W
69 74 W
74 79 W
79 91 W
91 93 W
93 95 W
95 99 W
99 102 W
102 105 W
105 106 W
106 107 W
107 113 W
113 114 W
114 123 W
...

result:

ok 398 'Yes' out of 398 cases (398 test cases)

Test #23:

score: 0
Accepted
time: 123ms
memory: 31044kb

input:

2
201114
2 0
2 0
0 2
0 2
1 1
1 1
0 2
0 2
0 2
0 2
1 1
1 1
1 1
1 1
0 2
0 2
0 2
1 1
1 1
0 2
0 2
1 1
0 2
0 2
1 1
1 1
2 0
1 1
0 2
1 1
2 0
0 2
0 2
0 2
2 0
2 0
0 2
1 1
2 0
0 2
1 1
1 1
1 1
0 2
0 2
2 0
0 2
0 2
1 1
1 1
0 2
0 2
0 2
0 2
0 2
2 0
1 1
1 1
0 2
1 1
0 2
1 1
0 2
0 2
1 1
2 0
0 2
1 1
1 1
1 1
2 0
1 1
0 2...

output:

Yes
93760 1 W
1 2 W
2 27 W
27 31 W
31 35 W
35 36 W
36 39 W
39 46 W
46 56 W
56 66 W
66 71 W
71 77 W
77 80 W
80 81 W
81 83 W
83 85 W
85 88 W
88 91 W
91 92 W
92 94 W
94 95 W
95 97 W
97 100 W
100 103 W
103 110 W
110 118 W
118 130 W
130 132 W
132 136 W
136 145 W
145 148 W
148 152 W
152 156 W
156 159 W
15...

result:

ok 2 'Yes' out of 2 cases (2 test cases)

Test #24:

score: 0
Accepted
time: 183ms
memory: 32420kb

input:

1
300000
2 1
3 0
1 0
1 2
0 1
0 1
2 1
0 1
0 1
3 0
1 0
1 0
1 2
1 2
1 2
2 1
3 0
2 1
0 3
0 1
0 1
0 1
1 2
1 2
1 2
2 1
2 1
0 1
0 3
0 3
0 1
1 2
0 3
0 1
1 0
0 3
0 1
2 1
1 0
2 1
2 1
0 1
1 0
1 0
2 1
2 1
0 1
1 0
1 2
1 2
1 2
2 1
0 1
2 1
3 0
1 0
1 2
1 0
3 0
1 0
2 1
1 0
1 0
0 1
0 3
1 2
1 0
2 1
1 0
2 1
0 1
3 0
1 0...

output:

Yes
3 2 W
5 19 B
6 29 B
8 30 B
9 33 B
11 10 W
12 17 W
20 36 B
21 65 B
22 80 B
28 88 B
31 142 B
34 154 B
35 55 W
37 165 B
39 59 W
42 169 B
43 72 W
44 78 W
47 194 B
48 89 W
53 213 B
56 121 W
58 136 W
60 151 W
62 158 W
63 199 W
64 231 B
67 221 W
69 252 W
71 237 B
73 269 W
74 243 B
75 267 B
76 280 W
81 ...

result:

ok 1 'Yes' out of 1 cases (1 test case)

Test #25:

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

input:

1
30
0 1
3 0
1 2
1 0
0 1
2 0
2 1
1 0
2 1
0 3
3 0
1 0
1 0
1 2
0 1
0 1
1 0
1 0
0 1
0 1
1 0
0 2
1 2
1 2
1 2
0 1
3 0
1 2
1 2
1 0

output:

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

result:

ok 1 'Yes' out of 1 cases (1 test case)

Test #26:

score: 0
Accepted
time: 95ms
memory: 24040kb

input:

203
1480
2 1
1 2
2 1
1 2
0 3
2 1
1 0
1 0
1 0
0 1
1 2
1 2
0 1
0 3
1 0
1 0
2 1
1 2
1 2
0 1
1 2
1 0
0 1
2 1
2 1
0 1
0 1
0 1
2 1
2 1
1 0
1 0
1 0
1 0
0 1
1 0
1 0
2 1
2 1
2 1
1 2
1 2
1 0
0 1
1 2
0 1
0 1
2 1
2 1
0 1
1 2
2 1
1 2
3 0
3 0
1 0
1 2
2 1
1 0
1 0
0 1
2 1
1 0
2 1
1 0
0 1
1 0
1 0
1 0
1 0
2 1
1 0
0 1...

output:

Yes
7 54 W
8 55 W
9 100 W
10 5 B
13 14 B
15 130 W
16 150 W
20 110 B
22 155 W
23 111 B
26 119 B
27 122 B
28 134 B
31 164 W
32 178 W
33 190 W
34 191 W
35 143 B
36 200 W
37 221 W
43 233 W
44 147 B
46 167 B
47 182 B
50 188 B
56 273 W
59 281 W
60 293 W
61 198 B
63 348 W
65 359 W
66 199 B
67 363 W
68 368 ...

result:

ok 203 'Yes' out of 203 cases (203 test cases)

Test #27:

score: 0
Accepted
time: 156ms
memory: 32372kb

input:

2
168857
0 1
0 1
0 1
1 2
1 0
1 2
0 3
0 1
1 2
2 1
1 2
0 3
1 2
1 2
2 1
1 0
1 0
0 1
1 2
0 3
3 0
1 0
0 1
0 1
2 1
2 1
1 0
1 2
1 0
2 1
1 0
1 0
1 2
2 1
1 0
0 1
0 1
2 1
1 2
0 1
1 2
1 2
1 0
1 2
2 1
1 0
2 1
1 0
1 0
3 0
1 2
2 1
1 2
0 1
2 1
1 2
1 2
0 1
0 1
1 0
1 2
0 1
1 0
1 2
1 0
2 1
2 1
0 1
0 1
1 2
1 0
1 0
0 1...

output:

Yes
1 7 B
2 12 B
3 20 B
5 21 W
8 79 B
16 50 W
17 89 W
18 88 B
22 95 W
23 108 B
24 137 B
27 128 W
29 136 W
31 146 W
32 150 W
35 183 W
36 153 B
37 164 B
40 258 B
43 222 W
46 247 W
48 259 W
49 298 W
54 261 B
58 272 B
59 293 B
60 306 W
62 309 B
63 345 W
65 352 W
68 372 B
69 379 B
71 358 W
72 378 W
73 41...

result:

ok 2 'Yes' out of 2 cases (2 test cases)

Test #28:

score: 0
Accepted
time: 86ms
memory: 32244kb

input:

1
300000
1 0
0 1
0 1
1 0
1 0
1 0
0 1
1 0
1 0
0 1
0 1
1 0
1 0
0 1
1 0
1 0
1 0
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
1 0
1 0
1 0
0 1
0 1
1 0
0 1
0 1
0 1
0 1
0 1
1 0
1 0
0 1
0 1
0 1
1 0
1 0
1 0
0 1
1 0
0 1
0 1
1 0
1 0
1 0
0 1
0 1
1 0
1 0
0 1
0 1
0 1
1 0
1 0
1 0
0 1
0 1
0 1
0 1
0 1
0 1
1 0
0 1
0 1
0 1
0 1...

output:

Yes
1 237601 W
2 237601 B
3 237601 B
4 237601 W
5 237601 W
6 237601 W
7 237601 B
8 237601 W
9 237601 W
10 237601 B
11 237601 B
12 237601 W
13 237601 W
14 237601 B
15 237601 W
16 237601 W
17 237601 W
18 237601 B
19 237601 B
20 237601 B
21 237601 B
22 237601 B
23 237601 B
24 237601 B
25 237601 B
26 23...

result:

ok 1 'Yes' out of 1 cases (1 test case)

Test #29:

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

input:

1
20
1 0
0 1
1 0
1 0
0 1
1 0
0 1
1 0
0 1
1 0
0 1
1 0
1 0
12 7
1 0
1 0
0 1
0 1
1 0
1 0

output:

Yes
1 14 W
2 14 B
3 14 W
4 14 W
5 14 B
6 14 W
7 14 B
8 14 W
9 14 B
10 14 W
11 14 B
12 14 W
13 14 W
15 14 W
16 14 W
17 14 B
18 14 B
19 14 W
14 20 W

result:

ok 1 'Yes' out of 1 cases (1 test case)

Test #30:

score: 0
Accepted
time: 49ms
memory: 23928kb

input:

400
598
1 0
0 1
0 1
0 1
1 0
1 0
1 0
1 0
1 0
1 0
1 0
0 1
0 1
1 0
1 0
0 1
0 1
1 0
0 1
0 1
1 0
1 0
1 0
0 1
0 1
1 0
1 0
1 0
1 0
0 1
0 1
0 1
0 1
1 0
1 0
0 1
1 0
0 1
1 0
0 1
1 0
1 0
1 0
1 0
1 0
0 1
1 0
0 1
0 1
1 0
1 0
0 1
1 0
1 0
0 1
0 1
0 1
1 0
0 1
1 0
1 0
0 1
0 1
0 1
1 0
1 0
1 0
0 1
1 0
0 1
0 1
0 1
1 0
...

output:

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

result:

ok 400 'Yes' out of 400 cases (400 test cases)

Test #31:

score: 0
Accepted
time: 60ms
memory: 28944kb

input:

4
59759
0 1
1 0
0 1
0 1
0 1
1 0
0 1
0 1
0 1
1 0
1 0
1 0
0 1
1 0
0 1
0 1
0 1
0 1
0 1
1 0
0 1
1 0
1 0
1 0
1 0
0 1
1 0
0 1
1 0
0 1
1 0
0 1
1 0
1 0
1 0
0 1
1 0
0 1
0 1
1 0
0 1
0 1
0 1
0 1
0 1
1 0
1 0
0 1
0 1
0 1
1 0
0 1
1 0
1 0
1 0
0 1
1 0
0 1
0 1
0 1
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
0 1
0 1
1 0
...

output:

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

result:

ok 4 'Yes' out of 4 cases (4 test cases)

Test #32:

score: 0
Accepted
time: 76ms
memory: 26072kb

input:

396
985
2 1
1 0
1 2
0 3
0 1
2 1
0 3
2 1
0 1
0 3
3 0
0 1
3 0
2 1
1 0
1 0
0 1
1 0
1 0
1 2
0 1
1 0
1 2
0 1
2 1
3 0
1 0
1 2
1 2
2 1
1 0
2 1
0 1
0 1
1 2
1 0
1 2
1 2
1 2
3 0
1 2
2 1
1 0
0 3
2 1
1 2
0 1
1 2
1 0
1 2
1 0
0 1
1 0
1 2
0 1
2 1
2 1
3 0
0 3
2 1
0 1
1 2
1 2
0 1
0 1
2 1
1 2
0 1
0 1
0 1
0 1
2 1
3 0
...

output:

Yes
2 11 W
5 4 B
9 7 B
12 10 B
15 13 W
16 26 W
17 44 B
18 40 W
19 58 W
21 59 B
22 73 W
24 88 B
27 94 W
31 112 W
33 90 B
34 101 B
36 123 W
43 124 W
47 102 B
49 135 W
51 151 W
52 114 B
53 162 W
55 172 B
61 173 B
64 202 B
65 209 B
68 212 B
69 234 B
70 243 B
71 245 B
74 204 W
75 218 W
77 249 B
79 256 B
...

result:

ok 396 'Yes' out of 396 cases (396 test cases)

Test #33:

score: 0
Accepted
time: 55ms
memory: 24064kb

input:

4011
76
1 1
0 2
2 0
1 1
1 1
1 1
2 0
1 1
1 1
1 1
1 1
1 1
1 1
0 2
2 0
2 0
1 1
2 0
0 2
2 0
2 0
1 0
0 1
2 0
1 1
0 2
1 1
2 0
1 1
1 1
2 0
0 2
2 0
0 2
1 1
1 1
2 0
2 0
0 2
0 2
1 1
1 1
0 2
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
0 2
1 1
2 0
1 1
1 1
0 2
2 0
2 0
2 0
1 1
2 0
1 1
1 1
2 0
1 1
2 0
1 1
2 0
0 2
0 2
1 1
0 2
...

output:

Yes
22 3 W
3 7 W
7 15 W
15 16 W
16 18 W
18 20 W
20 21 W
21 24 W
23 2 B
2 14 B
14 19 B
19 26 B
24 28 W
26 32 B
28 31 W
31 33 W
32 34 B
33 37 W
34 39 B
37 38 W
38 54 W
39 40 B
40 43 B
43 52 B
52 57 B
54 58 W
57 70 B
58 59 W
59 60 W
60 62 W
62 65 W
65 67 W
67 69 W
69 75 W
70 71 B
71 73 B
73 1 B
1 76 W
...

result:

ok 4005 'Yes' out of 4011 cases (4011 test cases)

Test #34:

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

input:

300000
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0
1
0 0...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 300000 'Yes' out of 300000 cases (300000 test cases)

Test #35:

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

input:

14
9
0 1
3 2
0 1
1 1
0 1
0 1
1 0
1 2
0 1
5
1 0
2 1
1 0
0 2
0 1
10
0 2
1 0
1 1
0 2
0 2
1 1
1 2
2 0
0 1
0 1
9
0 1
1 0
2 1
1 3
1 0
0 1
1 0
0 2
2 0
6
0 1
2 2
1 0
1 0
2 0
0 1
7
0 1
0 2
1 0
1 1
0 3
0 2
0 1
10
0 1
0 1
1 0
2 1
1 3
0 2
1 1
0 1
0 2
1 0
7
0 2
0 1
0 2
0 2
0 1
0 2
0 2
6
1 0
1 1
0 1
0 1
1 1
3 0
9...

output:

Yes
1 2 B
3 8 B
5 2 B
6 4 B
4 2 W
7 2 W
2 8 W
8 9 B
Yes
1 2 W
3 2 W
2 4 B
4 5 B
Yes
2 8 W
8 3 W
3 1 B
1 4 B
4 5 B
5 7 B
9 6 B
6 7 W
7 10 B
Yes
1 4 B
2 3 W
5 9 W
6 4 B
7 3 W
3 8 B
8 4 B
4 9 W
Yes
1 2 B
3 2 W
4 5 W
5 2 W
2 6 B
Yes
1 5 B
3 4 W
4 2 B
2 5 B
5 6 B
6 7 B
Yes
1 5 B
2 5 B
3 4 W
8 6 B
6 9 B
9...

result:

ok 14 'Yes' out of 14 cases (14 test cases)

Test #36:

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

input:

1328
7
1 1
2 1
0 1
1 1
1 1
0 1
1 0
6
2 0
1 1
1 0
0 1
0 3
0 1
8
2 2
1 0
1 1
1 0
1 0
1 0
0 2
1 1
9
2 0
0 1
1 0
1 4
0 1
0 1
1 0
1 0
2 1
7
2 0
1 0
1 1
1 1
1 0
1 0
3 0
9
0 1
1 1
2 2
0 1
1 0
0 1
1 0
1 0
2 2
10
1 1
1 1
0 3
0 1
1 0
1 1
2 1
1 0
2 0
1 0
8
0 1
1 0
0 2
2 0
0 1
0 1
2 2
1 1
9
1 3
2 1
0 2
0 2
1 0
...

output:

Yes
3 1 B
1 2 W
6 2 B
2 4 W
4 5 B
5 7 W
Yes
3 1 W
1 2 W
2 5 B
4 5 B
5 6 B
Yes
2 1 W
4 1 W
5 3 W
3 1 B
1 7 B
6 8 W
7 8 B
Yes
2 4 B
3 1 W
1 9 W
5 4 B
6 4 B
7 4 W
4 9 B
8 9 W
Yes
2 7 W
5 1 W
1 7 W
6 3 W
3 4 B
4 7 W
Yes
1 3 B
4 9 B
5 3 W
6 2 B
2 9 W
7 3 W
3 9 B
8 9 W
Yes
4 3 B
5 7 W
8 9 W
9 1 W
1 3 B
3 ...

result:

ok 1328 'Yes' out of 1328 cases (1328 test cases)

Test #37:

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

input:

666
10
2 2
1 0
1 2
1 0
0 1
1 1
0 1
1 2
0 1
1 0
12
1 1
0 1
0 1
2 0
1 0
1 0
2 1
0 1
1 1
1 1
2 1
1 2
11
0 1
0 3
0 1
0 1
1 0
1 0
0 1
2 2
1 0
1 0
2 3
10
0 1
2 0
1 1
1 1
2 0
1 0
1 0
0 1
2 1
2 1
16
1 1
0 1
0 1
1 0
1 1
1 0
1 3
1 0
0 3
0 1
2 0
1 2
2 1
1 2
0 1
0 1
18
1 0
1 0
0 1
1 1
0 1
2 0
2 0
0 1
2 0
2 2
1 ...

output:

Yes
2 1 W
4 1 W
5 1 B
1 3 B
7 8 B
9 3 B
3 6 W
6 8 B
8 10 W
Yes
2 12 B
3 1 B
1 4 W
4 7 W
5 11 W
6 7 W
7 9 B
8 10 B
9 11 W
10 12 W
11 12 B
Yes
1 2 B
3 11 B
4 2 B
2 8 B
5 8 W
6 11 W
7 11 B
9 8 W
8 11 B
10 11 W
Yes
1 3 B
3 2 W
2 5 W
5 9 W
6 10 W
7 4 W
4 9 B
8 10 B
9 10 W
Yes
2 7 B
3 9 B
4 11 W
6 13 W
8 ...

result:

ok 666 'Yes' out of 666 cases (666 test cases)

Test #38:

score: 0
Accepted
time: 39ms
memory: 21884kb

input:

13385
12
1 0
1 0
1 1
1 0
3 0
2 1
1 0
1 0
2 0
1 0
3 2
1 0
15
1 2
0 2
1 1
1 1
1 0
1 0
1 1
0 1
4 1
0 2
1 1
1 0
1 0
1 1
0 1
18
0 1
1 0
0 1
1 0
1 1
2 1
1 0
0 1
2 0
1 1
1 2
0 1
0 1
1 1
1 1
1 4
1 1
0 3
18
1 1
1 2
0 1
1 0
0 1
0 2
0 1
0 1
1 0
1 2
1 2
1 1
1 3
0 1
0 1
0 2
0 1
2 2
10
1 0
1 0
1 1
0 2
1 0
0 2
1 0...

output:

Yes
1 5 W
2 11 W
4 5 W
5 6 W
7 9 W
8 11 W
9 3 W
3 11 B
10 6 W
6 11 B
11 12 W
Yes
5 9 W
6 9 W
8 1 B
12 9 W
13 1 W
1 2 B
2 10 B
10 3 B
3 4 W
4 7 B
7 9 W
9 11 B
11 14 W
14 15 B
Yes
1 16 B
2 6 W
3 16 B
4 9 W
7 5 W
5 18 B
8 11 B
9 6 W
6 16 B
12 18 B
13 10 B
10 11 W
11 14 B
14 15 W
15 16 B
16 17 W
17 18 B...

result:

ok 13385 'Yes' out of 13385 cases (13385 test cases)

Test #39:

score: 0
Accepted
time: 61ms
memory: 23960kb

input:

19978
10
3 1
0 1
2 0
1 1
1 2
0 1
1 0
1 0
2 0
1 0
20
2 0
2 1
1 0
2 1
0 3
1 0
1 1
1 1
0 1
0 1
1 0
1 0
3 1
2 1
2 1
1 0
1 1
0 1
0 1
1 1
17
0 1
1 0
0 2
1 1
1 0
1 1
1 0
0 3
0 2
2 0
2 0
1 1
1 2
1 0
3 1
0 1
1 1
10
1 4
1 0
0 2
0 1
1 0
0 1
0 1
1 2
0 1
0 2
11
0 1
0 3
0 1
1 1
0 1
0 1
1 3
1 1
0 2
0 1
1 1
17
1 0
...

output:

Yes
2 5 B
6 1 B
7 1 W
8 1 W
1 3 W
3 9 W
9 4 W
4 5 B
5 10 W
Yes
3 13 W
6 1 W
1 2 W
9 5 B
10 5 B
5 2 B
2 4 W
11 13 W
12 14 W
16 15 W
18 4 B
4 7 W
7 8 B
8 13 W
13 14 B
14 15 W
15 17 B
17 20 W
19 20 B
Yes
1 8 B
2 15 W
5 10 W
7 11 W
10 15 W
11 4 W
4 3 B
3 8 B
8 9 B
9 13 B
14 6 W
6 12 B
12 13 W
13 15 B
15...

result:

ok 19978 'Yes' out of 19978 cases (19978 test cases)

Test #40:

score: 0
Accepted
time: 177ms
memory: 32972kb

input:

2
169106
1 0
2 0
1 2
0 2
3 1
0 1
0 1
0 1
1 0
0 1
3 1
2 1
1 0
1 0
0 1
1 0
1 1
0 1
1 1
0 1
1 2
1 1
4 4
0 1
1 0
0 1
1 0
1 0
0 1
0 1
1 0
0 1
3 0
0 1
1 0
1 3
3 0
1 1
2 3
0 1
1 0
1 0
5 2
0 1
1 0
0 1
1 0
1 1
0 1
1 0
2 1
0 1
1 3
2 1
0 1
3 3
1 1
1 1
2 1
0 1
0 1
1 0
0 1
1 1
2 0
0 1
1 0
1 0
0 1
1 1
2 2
1 1
1 0...

output:

Yes
1 42564 W
6 41903 B
7 41903 B
8 62973 B
9 83947 W
10 67006 B
13 26304 W
14 42564 W
15 41903 B
16 67201 W
18 62973 B
20 67006 B
24 71868 B
25 83947 W
26 76900 B
27 85243 W
28 90140 W
29 116483 B
30 135409 B
31 94831 W
32 22710 B
34 40484 B
35 129822 W
40 41903 B
41 136806 W
42 147493 W
44 46940 B...

result:

ok 2 'Yes' out of 2 cases (2 test cases)

Test #41:

score: 0
Accepted
time: 161ms
memory: 26456kb

input:

4
50069
1 1
1 1
2 1
0 1
1 0
2 0
0 1
2 0
1 1
1 0
0 1
2 2
1 0
1 0
0 2
1 0
1 0
3 0
1 0
0 3
1 1
1 0
1 3
1 3
0 1
0 1
0 1
0 1
0 3
0 1
1 0
1 0
0 1
0 1
1 0
1 1
1 0
1 0
0 1
0 1
1 0
2 0
2 2
4 1
1 0
1 4
1 0
2 1
1 1
1 1
0 1
1 0
0 2
1 1
0 1
1 0
3 2
1 2
1 0
0 2
0 2
1 1
2 0
1 0
1 0
1 0
1 0
0 2
0 1
1 2
1 1
0 1
0 2
...

output:

Yes
4 15167 B
5 18408 W
7 21834 B
10 16868 W
11 2464 B
13 18408 W
14 21551 W
16 24075 W
17 44606 W
19 48889 W
22 3770 W
25 15167 B
26 21834 B
27 45532 B
28 2464 B
30 4643 B
31 3794 W
32 7216 W
33 14735 B
34 15167 B
35 8217 W
37 12016 W
38 12122 W
39 21834 B
40 29327 B
41 12804 W
45 14362 W
47 14889 ...

result:

ok 4 'Yes' out of 4 cases (4 test cases)

Test #42:

score: 0
Accepted
time: 128ms
memory: 26068kb

input:

20
18335
0 1
1 2
1 0
0 2
0 3
0 1
1 0
0 1
1 1
1 2
1 2
1 2
1 2
1 1
0 1
1 0
2 0
0 1
1 3
1 0
1 2
0 1
1 0
1 1
2 1
0 1
1 1
1 3
1 3
3 1
2 0
0 1
2 0
1 2
1 0
3 1
1 0
2 1
1 3
1 0
1 0
5 5
1 0
1 0
2 1
0 1
2 5
0 1
1 0
2 1
1 0
1 1
2 3
0 1
0 2
4 1
1 0
0 1
0 1
0 1
2 1
0 1
0 1
2 0
1 0
0 4
1 1
1 0
1 0
1 0
1 0
0 2
0 1...

output:

Yes
1 4146 B
3 3318 W
6 9908 B
7 6911 W
8 15615 B
15 4146 B
16 12380 W
18 4818 B
20 2878 W
22 5175 B
23 2894 W
26 8859 B
32 9908 B
35 3135 W
37 3318 W
40 5376 W
41 6911 W
43 7118 W
44 10271 W
46 12613 B
48 13614 B
49 11403 W
51 11760 W
54 14807 B
57 12380 W
58 15615 B
59 112 B
60 1146 B
62 1291 B
63...

result:

ok 20 'Yes' out of 20 cases (20 test cases)

Test #43:

score: 0
Accepted
time: 69ms
memory: 33228kb

input:

1
300000
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0...

output:

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

result:

ok 1 'Yes' out of 1 cases (1 test case)

Test #44:

score: 0
Accepted
time: 82ms
memory: 35436kb

input:

1
300000
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1...

output:

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

result:

ok 1 'Yes' out of 1 cases (1 test case)

Test #45:

score: 0
Accepted
time: 92ms
memory: 26488kb

input:

1
300000
1 0
1 0
1 0
0 1
1 0
0 1
1 0
0 1
0 1
0 1
1 0
0 1
1 0
1 0
1 0
0 1
0 1
1 0
0 1
0 1
1 0
0 1
1 0
0 1
1 0
1 0
0 1
1 0
0 1
1 0
0 1
0 1
0 1
1 0
0 1
0 1
1 0
1 0
1 0
0 1
1 0
0 1
0 1
0 1
0 1
1 0
0 1
0 1
0 1
1 0
0 1
0 1
0 1
0 1
1 0
1 0
0 1
0 1
1 0
0 1
1 0
0 1
1 0
1 0
0 1
0 1
1 0
0 1
0 1
0 1
1 0
1 0
0 1...

output:

No

result:

ok 0 'Yes' out of 1 cases (1 test case)

Test #46:

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

input:

1
300000
1 0
0 1
0 1
0 1
1 0
0 1
0 1
0 1
1 0
1 0
0 1
0 1
1 0
0 1
0 1
1 0
1 0
1 0
1 0
0 1
0 1
1 0
0 1
1 0
0 1
1 0
1 0
1 0
1 0
1 0
1 0
0 1
1 0
0 1
1 0
0 1
1 0
1 0
0 1
0 1
0 1
1 0
1 0
0 1
1 0
0 1
0 1
1 0
1 0
0 1
0 1
1 0
0 1
0 1
0 1
1 0
0 1
0 1
0 1
0 1
0 1
1 0
1 0
1 0
0 1
0 1
1 0
0 1
0 1
0 1
1 0
1 0
0 1...

output:

No

result:

ok 0 'Yes' out of 1 cases (1 test case)

Test #47:

score: 0
Accepted
time: 103ms
memory: 27188kb

input:

1
300000
1 0
1 0
0 1
0 1
0 1
1 0
0 1
1 0
0 1
1 0
0 1
0 1
0 1
1 0
1 0
0 1
0 1
0 1
0 1
0 1
1 0
0 1
1 0
1 0
0 1
1 0
0 1
0 1
1 0
0 1
0 1
0 1
0 1
0 1
1 0
0 1
0 1
1 0
0 1
1 0
0 1
0 1
1 0
0 1
0 1
1 0
0 1
0 1
0 1
0 1
0 1
1 0
0 1
1 0
0 1
0 1
0 1
1 0
1 0
1 0
0 1
1 0
1 0
1 0
0 1
1 0
0 1
1 0
1 0
1 0
1 0
0 1
1 0...

output:

No

result:

ok 0 'Yes' out of 1 cases (1 test case)

Test #48:

score: 0
Accepted
time: 29ms
memory: 21920kb

input:

405
524
0 1
0 1
1 0
0 1
1 0
1 0
1 0
0 1
1 0
1 0
0 1
0 1
0 1
0 1
1 0
0 1
0 1
0 1
1 0
0 1
1 0
1 0
1 0
1 0
1 0
1 0
1 0
0 1
0 1
7 4
0 1
0 1
0 1
1 0
1 0
1 0
1 0
1 0
0 1
1 0
1 0
1 0
1 0
1 0
0 1
0 1
1 0
0 1
0 1
50 15
0 1
0 1
0 1
1 0
0 1
1 0
0 1
0 1
1 0
1 0
1 0
1 0
1 0
0 1
0 1
0 1
1 0
0 1
0 1
1 0
1 0
0 1
1 ...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
...

result:

ok 7 'Yes' out of 405 cases (405 test cases)

Test #49:

score: 0
Accepted
time: 25ms
memory: 21940kb

input:

3997
67
1 0
1 0
1 1
0 1
0 1
0 1
0 1
0 1
1 0
0 1
0 1
2 2
1 0
0 1
0 1
1 0
1 0
0 1
0 1
0 1
0 1
1 0
0 1
0 1
0 1
0 1
1 0
0 1
0 1
0 1
0 1
0 1
1 0
0 1
1 0
1 0
2 0
0 1
3 6
0 1
0 1
0 1
0 1
1 0
0 1
1 0
0 1
0 1
1 0
1 0
1 0
1 0
1 0
1 0
1 0
0 1
7 17
1 0
1 0
1 0
28 2
0 1
1 0
0 1
0 1
1 0
0 1
95
1 0
1 0
3 2
0 1
1 0...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
1 17 B
2 17 B
3 17 B
4 17 W
5 17 W
6 17 W
7 17 W
8 17 B
9 17 W
10 17 B
11 17 B
12 17 B
13 17 W
14 17 W
16 17 B
18 17 W
19 17 W
20 17 B
21 17 W
22 17 W
23 17 B
24 17 W
25 17 B
26 17 B
27 17 W
28 17 B
30 17 W
31 17 B
32 17 B
33 17 W
34 17 B
35 17 W
3...

result:

ok 315 'Yes' out of 3997 cases (3997 test cases)

Test #50:

score: 0
Accepted
time: 37ms
memory: 21892kb

input:

4025
67
1 0
1 0
1 0
1 0
1 0
1 0
1 0
8 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
5 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
23 0
1 0
1 0
1 0
1 0
18 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
3 0
1 0
12 0
1 0
1 0
1 0
1 0
1 0
1 0
3 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
54
1 0
1 0
1 0
1 0
1 ...

output:

Yes
1 33 W
2 33 W
3 33 W
4 33 W
5 33 W
6 33 W
7 38 W
9 33 W
10 38 W
11 33 W
12 38 W
13 33 W
14 38 W
15 33 W
16 38 W
17 33 W
18 38 W
19 33 W
21 38 W
22 48 W
23 33 W
24 38 W
25 48 W
26 33 W
27 38 W
28 48 W
29 33 W
30 38 W
31 48 W
32 8 W
34 33 W
35 38 W
36 48 W
37 8 W
39 33 W
40 38 W
41 48 W
42 8 W
43 ...

result:

ok 4025 'Yes' out of 4025 cases (4025 test cases)

Test #51:

score: 0
Accepted
time: 41ms
memory: 26080kb

input:

2011
179
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 2
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 79
0 1
0 1
0 1
0 1
0 2
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 ...

output:

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

result:

ok 2011 'Yes' out of 2011 cases (2011 test cases)

Test #52:

score: 0
Accepted
time: 11ms
memory: 11676kb

input:

1
300000
262675 267778
43279 175147
121184 171593
235566 120418
140167 34601
89828 129090
207278 255877
133629 104994
212162 130149
83462 37339
148883 251891
223122 247624
293652 14655
19958 103437
210431 168892
283885 28109
14352 277760
241524 6771
236581 156296
56271 145418
290148 77745
36067 2884...

output:

No

result:

ok 0 'Yes' out of 1 cases (1 test case)

Test #53:

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

input:

1
300000
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 299999
299999 2999...

output:

No

result:

ok 0 'Yes' out of 1 cases (1 test case)

Test #54:

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

input:

1
300000
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0...

output:

No

result:

ok 0 'Yes' out of 1 cases (1 test case)

Test #55:

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

input:

1
300000
15000 20784
9103 22377
3737 17620
16793 26158
26669 6007
3319 8421
1424 2350
16536 887
22865 14935
12957 22768
5477 5775
1645 29025
13797 25593
25601 9393
4220 24398
21672 12615
24074 15096
6949 29842
25668 19365
12044 4146
15489 5754
9384 22716
10174 6574
7080 8137
7435 5370
11054 14615
15...

output:

No

result:

ok 0 'Yes' out of 1 cases (1 test case)

Test #56:

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

input:

1
300000
1971 2294
2945 25
2868 2904
2843 2105
1769 1096
364 1934
2566 2049
2091 2052
2939 2912
1617 436
1156 1737
1252 306
2127 1786
1397 1871
2201 1951
138 2728
1674 980
757 2253
2468 686
2506 2171
2176 1155
581 1435
2681 1980
722 1864
2190 1522
1987 941
700 1159
574 1277
1379 1449
1668 2353
1028 ...

output:

No

result:

ok 0 'Yes' out of 1 cases (1 test case)

Test #57:

score: 0
Accepted
time: 8ms
memory: 9692kb

input:

1
300000
101 248
255 37
168 55
278 215
21 288
117 230
226 98
129 93
289 138
220 65
11 265
38 172
152 177
46 81
270 187
35 182
82 32
31 53
261 23
87 115
45 33
189 112
285 197
21 117
104 28
289 60
107 298
140 40
114 147
295 230
279 67
99 161
131 250
28 215
180 213
21 178
125 60
114 116
264 22
177 243
...

output:

No

result:

ok 0 'Yes' out of 1 cases (1 test case)

Test #58:

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

input:

4009
59
1 1
0 0
2 1
1 0
2 0
2 2
2 1
0 0
2 1
1 2
0 1
2 1
1 2
1 1
1 0
1 0
0 1
2 2
0 1
1 1
0 2
2 0
0 2
2 2
1 1
2 2
0 1
0 1
0 1
2 1
2 1
1 1
2 2
0 2
0 2
2 2
0 0
0 0
0 2
2 0
0 2
2 2
0 0
1 1
1 0
2 0
0 0
0 2
2 1
2 2
1 1
2 2
1 2
2 1
2 2
1 1
2 0
1 0
2 0
63
2 0
2 0
3 2
0 0
0 1
1 1
3 0
0 3
2 1
1 1
3 3
0 0
2 1
0...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
...

result:

ok 0 'Yes' out of 4009 cases (4009 test cases)

Test #59:

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

input:

4020
93
3 71
14 80
80 47
2 10
50 21
78 59
12 61
63 28
7 59
61 6
90 45
56 51
73 24
65 40
65 61
41 43
67 54
72 92
80 12
56 40
7 11
79 75
61 74
8 52
34 88
56 49
24 50
78 85
16 20
15 24
56 49
2 77
34 90
43 70
84 90
70 25
58 69
74 46
83 14
55 56
17 25
82 47
62 82
51 5
81 29
3 36
74 70
64 48
86 19
40 21
3...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
...

result:

ok 0 'Yes' out of 4020 cases (4020 test cases)

Test #60:

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

input:

397
602
0 2
0 1
0 4
6 2
6 3
2 3
6 6
5 4
2 1
2 1
6 0
5 0
5 2
0 4
5 3
4 0
5 1
2 1
4 0
3 1
4 2
1 6
0 4
6 1
2 4
2 2
5 1
3 2
4 5
1 4
5 5
0 6
0 6
1 2
5 5
1 4
2 6
4 5
5 5
3 6
2 1
4 2
0 6
4 1
0 2
3 2
2 2
1 2
4 1
6 0
3 4
1 3
0 0
0 6
1 6
2 4
0 4
3 6
5 1
6 0
4 0
6 1
6 1
2 1
6 0
4 3
1 1
0 5
0 3
1 1
5 1
4 1
1 2
...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
...

result:

ok 0 'Yes' out of 397 cases (397 test cases)

Test #61:

score: 0
Accepted
time: 62ms
memory: 27056kb

input:

1
300000
1 0
1 0
218829 0
1 0
1 0
248591 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
158281 0
56375 0
1 0
297030 0
1 0
132934 0
148635 0
72063 0
289146 0
1 0
99680 0
206100 0
1 0
8954 0
1 0
1 0
203542 0
1 0
1 0
25207 0
1 0
140934 0
123070 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
1 0
83312 0
1 0
179468 0
...

output:

No

result:

ok 0 'Yes' out of 1 cases (1 test case)

Test #62:

score: 0
Accepted
time: 67ms
memory: 28756kb

input:

1
300000
0 1
0 1
0 159896
0 1
0 1
0 1
0 20309
0 94091
0 1
0 1
0 1
0 1
0 1
0 112999
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 1
0 289698
0 103394
0 1
0 1
0 1
0 182667
0 1
0 105865
0 1
0 1
0 1
0 1
0 1
0 73965
0 1
0 1
0 1
0 1
0 1
0 1
0 43984
0 1
0 1
0 1
0 1
0...

output:

No

result:

ok 0 'Yes' out of 1 cases (1 test case)

Test #63:

score: 0
Accepted
time: 96ms
memory: 30380kb

input:

1
300000
1 0
1 0
1 0
1 0
1 0
51149 244943
54973 75789
0 1
1 0
1 0
0 1
0 1
1 0
7269 32589
0 1
1 0
0 1
1 0
1 0
0 1
1 0
1 0
120809 2039
1 0
0 1
0 1
0 1
1 0
150396 127250
0 1
1 0
0 1
1 0
0 1
1 0
1 0
10042 10308
1 0
0 1
1 0
1 0
110349 107052
0 1
0 1
0 1
1 0
1 0
0 1
0 1
100403 74129
0 1
1 0
0 1
0 1
1 0
1 ...

output:

No

result:

ok 0 'Yes' out of 1 cases (1 test case)