QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#202828#2477. Excavationwhsyhyyh#AC ✓9ms4752kbC++142.3kb2023-10-06 13:39:122023-10-06 13:39:13

Judging History

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

  • [2023-10-06 13:39:13]
  • 评测
  • 测评结果:AC
  • 用时:9ms
  • 内存:4752kb
  • [2023-10-06 13:39:12]
  • 提交

answer

#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC option("arch=native","tune=native","no-zero-upper")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define N 110
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define drep(i,r,l) for(int i=r;i>=l;i--)
using namespace std;
int rd() {
	int res=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') f*=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') res=(res<<1)+(res<<3)+(ch^48),ch=getchar();
	return res*f;
}
int n;char ch,mp[N][N];
struct node {
	int x,y,id;
}q[N*N];int tot,fa[N*N],pos[N][N];
vector<int>G[N*N];
int find(int x) {
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
void merge(int x,int y) {
	if(find(x)!=find(y)) fa[find(x)]=find(y),G[x].push_back(y),G[y].push_back(x);
}
void Rook() {
	rep(i,1,n) rep(j,1,n) if(mp[i][j]==ch) {
		drep(k,j-1,1) if(mp[i][k]==ch) merge(pos[i][j],pos[i][k]);
		drep(k,i-1,1) if(mp[k][j]==ch) merge(pos[i][j],pos[k][j]);
	}
}
void Bishop() {
	rep(i,1,n) rep(j,1,n) if(mp[i][j]==ch) {
		rep(k,1,min(i-1,j-1)) if(mp[i-k][j-k]==ch) merge(pos[i][j],pos[i-k][j-k]);
		rep(k,1,min(i-1,n-j)) if(mp[i-k][j+k]==ch) merge(pos[i][j],pos[i-k][j+k]);
	}
}
int dx[]={-1,-2,1,2};
int dy[]={-2,-1,-2,-1};
void Knight() {
	rep(i,1,n) rep(j,1,n) if(mp[i][j]==ch) {
		rep(k,0,3) {
			int x=i+dx[k],y=j+dy[k];
			if(x>=1&&x<=n&&y>=1&&y<=n&&mp[x][y]==ch) merge(pos[i][j],pos[x][y]);
		}
	}
}
int Dx[]={-1,-1,-1,0};
int Dy[]={-1,0,1,-1};
void King() {
	rep(i,1,n) rep(j,1,n) if(mp[i][j]==ch) {
		rep(k,0,3) {
			int x=i+Dx[k],y=j+Dy[k];
			if(x>=1&&x<=n&&y>=1&&y<=n&&mp[x][y]==ch) merge(pos[i][j],pos[x][y]);
		}
	}
}
void dfs(int x,int fat) {
	for(auto v:G[x]) if(v!=fat) {
		dfs(v,x);
		printf("%d %d %d %d\n",q[v].x,q[v].y,q[x].x,q[x].y);
	}
}
int main() {
	n=rd();ch=getchar();
	rep(i,1,n) scanf("%s",mp[i]+1);
	rep(i,1,n) {
		rep(j,1,n) if(mp[i][j]==ch) {
			q[++tot]=(node) {i,j,tot},pos[i][j]=tot;
			fa[tot]=tot;
		}
	}
	if(ch=='R') Rook();
	if(ch=='Q') Rook(),Bishop();
	if(ch=='B') Bishop();
	if(ch=='N') Knight();
	if(ch=='K') King();
	rep(i,1,tot) if(find(i)!=find(1)) {
		puts("NO");
		return 0;
	}
	puts("YES");
	dfs(1,0);
	return 0;
}

详细

Test #1:

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

input:

5 K
.....
.....
.K...
...K.
.....

output:

NO

result:

ok 

Test #2:

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

input:

5 K
.....
.K...
.....
...K.
.....

output:

NO

result:

ok 

Test #3:

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

input:

5 K
.....
.....
.....
..K.K
.....

output:

NO

result:

ok 

Test #4:

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

input:

5 K
.....
.K...
.....
.K...
.....

output:

NO

result:

ok 

Test #5:

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

input:

5 K
.....
..K..
.K.K.
..K..
.....

output:

YES
4 3 3 2
3 2 2 3
3 4 2 3

result:

ok 

Test #6:

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

input:

5 K
..K.K
..K..
.K...
.K...
..KK.

output:

NO

result:

ok 

Test #7:

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

input:

5 Q
.Q...
.....
..Q..
.....
.....

output:

NO

result:

ok 

Test #8:

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

input:

5 Q
.....
....Q
.....
.....
..Q..

output:

NO

result:

ok 

Test #9:

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

input:

5 Q
Q....
.....
....Q
..Q..
.....

output:

NO

result:

ok 

Test #10:

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

input:

5 Q
Q....
....Q
.....
.....
.....

output:

NO

result:

ok 

Test #11:

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

input:

5 Q
....Q
.....
.....
.....
...Q.

output:

NO

result:

ok 

Test #12:

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

input:

5 R
.....
.....
...R.
R....
.....

output:

NO

result:

ok 

Test #13:

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

input:

5 R
.....
.R...
..R..
.....
.....

output:

NO

result:

ok 

Test #14:

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

input:

5 R
.....
....R
...R.
..R.R
...R.

output:

NO

result:

ok 

Test #15:

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

input:

5 R
R.R.R
.....
.....
.....
.R.R.

output:

NO

result:

ok 

Test #16:

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

input:

5 R
...R.
.....
.R.R.
.....
R....

output:

NO

result:

ok 

Test #17:

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

input:

5 B
.....
.....
.....
.B...
.B...

output:

NO

result:

ok 

Test #18:

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

input:

5 B
.....
..BB.
.....
.....
.....

output:

NO

result:

ok 

Test #19:

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

input:

5 B
.....
B...B
.....
....B
.....

output:

NO

result:

ok 

Test #20:

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

input:

5 B
B.B.B
.B.B.
B.B.B
.B.B.
...B.

output:

NO

result:

ok 

Test #21:

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

input:

5 B
B....
.B...
..B..
.BBB.
..B..

output:

NO

result:

ok 

Test #22:

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

input:

5 N
....N
...N.
..N..
.N...
N....

output:

NO

result:

ok 

Test #23:

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

input:

5 N
.....
.N...
.N...
.....
.....

output:

NO

result:

ok 

Test #24:

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

input:

5 N
.....
...NN
.....
.....
.....

output:

NO

result:

ok 

Test #25:

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

input:

5 N
.....
.....
.N.N.
..N..
.N...

output:

NO

result:

ok 

Test #26:

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

input:

5 N
N....
...N.
.N.N.
.....
.....

output:

NO

result:

ok 

Test #27:

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

input:

10 Q
QQQ.QQQQQQ
QQQ.QQQQQQ
QQQ.QQQQQQ
....QQQQQ.
..........
..........
..........
..........
..........
...Q......

output:

NO

result:

ok 

Test #28:

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

input:

10 B
B.B.B...B.
.B.B...B.B
..B...B.B.
.....B.B.B
....B.B.B.
.....B.B.B
B.....B.B.
.......B..
..........
..........

output:

NO

result:

ok 

Test #29:

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

input:

10 R
RRR.RRRRRR
RRR.RRRRRR
RRR.RRRRRR
....RRRRRR
....RRRRRR
....RRRRRR
..........
..........
..........
...R......

output:

NO

result:

ok 

Test #30:

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

input:

10 N
N.N...N...
....N.....
.N...N....
..........
......N...
.....N....
.......N..
..........
.N........
..........

output:

NO

result:

ok 

Test #31:

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

input:

10 K
KK...KKKKK
.K.KKKKKKK
..K..KKKKK
.....KKKKK
.....KKKKK
....K.....
...KK.....
..K..K....
.....K.K..
..........

output:

NO

result:

ok 

Test #32:

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

input:

10 Q
QQQ.QQQQQQ
QQQ.QQQQQQ
QQQ.QQQQQQ
....QQQQQ.
..........
..........
..........
..........
..........
..........

output:

YES
1 10 1 9
1 9 1 8
1 8 1 7
1 7 1 6
1 6 1 5
1 5 1 3
1 3 1 2
1 2 1 1
2 10 2 9
2 9 2 8
2 8 2 7
2 7 2 6
2 6 2 5
2 5 2 3
2 3 2 2
2 2 2 1
3 10 3 9
3 9 3 8
3 8 3 7
3 7 3 6
3 6 3 5
4 9 4 8
4 8 4 7
4 7 4 6
4 6 4 5
4 5 3 5
3 5 3 3
3 3 3 2
3 2 3 1
3 1 2 1
2 1 1 1

result:

ok 

Test #33:

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

input:

10 B
B.B.B...B.
.B.B...B.B
..B...B.B.
.....B.B.B
....B.B.B.
.....B.B.B
......B.B.
.......B..
..........
..........

output:

YES
2 10 1 9
1 9 2 8
4 10 3 9
3 9 2 8
2 8 3 7
6 10 5 9
5 9 4 8
4 8 3 7
3 7 1 5
1 5 2 4
7 9 6 8
6 8 5 7
5 7 4 6
4 6 2 4
2 4 1 3
1 3 2 2
8 8 7 7
7 7 6 6
6 6 5 5
5 5 3 3
3 3 2 2
2 2 1 1

result:

ok 

Test #34:

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

input:

10 R
RRR.RRRRRR
RRR.RRRRRR
RRR.RRRRRR
....RRRRRR
....RRRRRR
....RRRRRR
..........
..........
..........
..........

output:

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

result:

ok 

Test #35:

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

input:

10 N
N.N...N...
....N.....
.N...N....
..........
......N...
.....N....
.......N..
..........
..........
..........

output:

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

result:

ok 

Test #36:

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

input:

10 K
KK...KKKKK
.K.KKKKKKK
..K..KKKKK
.....KKKKK
.....KKKKK
....K.....
...KK.....
..K..K....
.....K....
..........

output:

YES
1 2 1 1
1 10 1 9
2 10 1 9
1 9 1 8
3 10 2 9
2 9 1 8
1 8 1 7
4 10 3 9
3 9 2 8
2 8 1 7
1 7 1 6
5 9 4 8
4 8 3 7
3 7 2 6
2 6 1 6
5 10 4 9
4 9 3 8
3 8 2 7
2 7 1 6
1 6 2 5
8 3 7 4
7 4 6 5
9 6 8 6
8 6 7 5
7 5 6 5
6 5 5 6
5 6 4 6
5 7 4 6
4 6 3 6
5 8 4 7
4 7 3 6
3 6 2 5
2 5 2 4
2 4 3 3
3 3 2 2
2 2 1 1

result:

ok 

Test #37:

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

input:

2 K
K.
KK

output:

YES
2 1 1 1
2 2 1 1

result:

ok 

Test #38:

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

input:

1 B
B

output:

YES

result:

ok 

Test #39:

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

input:

2 B
BB
BB

output:

NO

result:

ok 

Test #40:

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

input:

3 B
BBB
BBB
BBB

output:

NO

result:

ok 

Test #41:

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

input:

5 B
BBBBB
BBBBB
BBBBB
BBBBB
BBBBB

output:

NO

result:

ok 

Test #42:

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

input:

17 B
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBB
BBBBBBB...

output:

NO

result:

ok 

Test #43:

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

input:

100 B
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

NO

result:

ok 

Test #44:

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

input:

100 B
....................................................................................................
....................................................................................................
...............................................................................................

output:

YES

result:

ok 

Test #45:

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

input:

100 B
....................................................................................................
....................................................................................................
...............................................................................................

output:

NO

result:

ok 

Test #46:

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

input:

100 B
.....B.....................B.....B......B......B...........................BB.B.......B....B.....B..
..........B..............B......BB...............B....................................B.....BB......
................B...............B........B..............B......B...B.B......B.........B.B......

output:

NO

result:

ok 

Test #47:

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

input:

100 B
......B...B.......B....B.......B.BB...B....B.....B...........BB.............B.BB....B.......B....BBB
.........B.B......B......B..........B....BB.................B....B........B.................B......B
B..B.BB.....B..B..........BB..BBB....B.B.B..B.B.BB...B...B......B....B...B.B..BB..BBBB.........

output:

NO

result:

ok 

Test #48:

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

input:

100 B
.B..B..B.B..B.........B..........B...B.BB.......B.B...BB...B...B.........B..B.BB..BB.B..B.B.....B..B
BB..BB.....B..B........B........B.BB.B....B.BBB......B...B..BB..B.B..........BB.B.....BBBB...B...B..
.....B.B.B...B....B.............B..BB.BB......BB.B...BBB.BB..B...B..........B..B.....BB........

output:

NO

result:

ok 

Test #49:

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

input:

3 B
BBB
B.B
BBB

output:

NO

result:

ok 

Test #50:

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

input:

19 B
BBBBBBBBBBBBBBBBBBB
B.................B
B.................B
B.................B
B.................B
B.................B
B.................B
B.................B
B.................B
B.................B
B.................B
B.................B
B.................B
B.................B
B.................

output:

NO

result:

ok 

Test #51:

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

input:

100 B
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
B..................................................................................................B
B..............................................................................................

output:

NO

result:

ok 

Test #52:

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

input:

3 B
B.B
.B.
B.B

output:

YES
1 3 2 2
3 1 2 2
3 3 2 2
2 2 1 1

result:

ok 

Test #53:

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

input:

21 B
B...................B
.B.................B.
..B...............B..
...B.............B...
....B...........B....
.....B.........B.....
......B.......B......
.......B.....B.......
........B...B........
.........B.B.........
..........B..........
.........B.B.........
........B...B........
.......B....

output:

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

result:

ok 

Test #54:

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

input:

99 B
B.................................................................................................B
.B...............................................................................................B.
..B...............................................................................................

output:

YES
1 99 2 98
2 98 3 97
3 97 4 96
4 96 5 95
5 95 6 94
6 94 7 93
7 93 8 92
8 92 9 91
9 91 10 90
10 90 11 89
11 89 12 88
12 88 13 87
13 87 14 86
14 86 15 85
15 85 16 84
16 84 17 83
17 83 18 82
18 82 19 81
19 81 20 80
20 80 21 79
21 79 22 78
22 78 23 77
23 77 24 76
24 76 25 75
25 75 26 74
26 74 27 73
2...

result:

ok 

Test #55:

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

input:

29 B
B.BBB.BBB.BBB.BBB.BBB.BBB.BBB
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
B.B.B.B.B.B.B.B.B.B.B.B.B...

output:

NO

result:

ok 

Test #56:

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

input:

100 B
B.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BBB.BB
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B....

output:

NO

result:

ok 

Test #57:

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

input:

31 B
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
.B.B.B....

output:

YES
1 31 2 30
3 31 2 30
2 30 1 29
1 29 2 28
5 31 4 30
4 30 3 29
3 29 2 28
2 28 1 27
1 27 2 26
7 31 6 30
6 30 5 29
5 29 4 28
4 28 3 27
3 27 2 26
2 26 1 25
1 25 2 24
9 31 8 30
8 30 7 29
7 29 6 28
6 28 5 27
5 27 4 26
4 26 3 25
3 25 2 24
2 24 1 23
1 23 2 22
11 31 10 30
10 30 9 29
9 29 8 28
8 28 7 27
7 2...

result:

ok 

Test #58:

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

input:

100 B
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.
.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B....

output:

YES
2 100 1 99
1 99 2 98
4 100 3 99
3 99 2 98
2 98 1 97
1 97 2 96
6 100 5 99
5 99 4 98
4 98 3 97
3 97 2 96
2 96 1 95
1 95 2 94
8 100 7 99
7 99 6 98
6 98 5 97
5 97 4 96
4 96 3 95
3 95 2 94
2 94 1 93
1 93 2 92
10 100 9 99
9 99 8 98
8 98 7 97
7 97 6 96
6 96 5 95
5 95 4 94
4 94 3 93
3 93 2 92
2 92 1 91
...

result:

ok 

Test #59:

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

input:

100 B
.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B
B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.
.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B.B...

output:

YES
100 1 99 2
100 3 99 2
99 2 98 1
98 1 97 2
100 5 99 4
99 4 98 3
98 3 97 2
97 2 96 1
96 1 95 2
100 7 99 6
99 6 98 5
98 5 97 4
97 4 96 3
96 3 95 2
95 2 94 1
94 1 93 2
100 9 99 8
99 8 98 7
98 7 97 6
97 6 96 5
96 5 95 4
95 4 94 3
94 3 93 2
93 2 92 1
92 1 91 2
100 11 99 10
99 10 98 9
98 9 97 8
97 8 96...

result:

ok 

Test #60:

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

input:

1 K
K

output:

YES

result:

ok 

Test #61:

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

input:

2 K
KK
KK

output:

YES
1 2 1 1
2 1 1 1
2 2 1 1

result:

ok 

Test #62:

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

input:

3 K
KKK
KKK
KKK

output:

YES
1 3 1 2
2 3 1 2
1 2 1 1
3 1 2 1
3 2 2 1
2 1 1 1
3 3 2 2
2 2 1 1

result:

ok 

Test #63:

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

input:

5 K
KKKKK
KKKKK
KKKKK
KKKKK
KKKKK

output:

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

result:

ok 

Test #64:

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

input:

17 K
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKK
KKKKKKK...

output:

YES
1 17 1 16
2 17 1 16
1 16 1 15
3 17 2 16
2 16 1 15
1 15 1 14
4 17 3 16
3 16 2 15
2 15 1 14
1 14 1 13
5 17 4 16
4 16 3 15
3 15 2 14
2 14 1 13
1 13 1 12
6 17 5 16
5 16 4 15
4 15 3 14
3 14 2 13
2 13 1 12
1 12 1 11
7 17 6 16
6 16 5 15
5 15 4 14
4 14 3 13
3 13 2 12
2 12 1 11
1 11 1 10
8 17 7 16
7 16 6...

result:

ok 

Test #65:

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

input:

100 K
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK...

output:

YES
1 100 1 99
2 100 1 99
1 99 1 98
3 100 2 99
2 99 1 98
1 98 1 97
4 100 3 99
3 99 2 98
2 98 1 97
1 97 1 96
5 100 4 99
4 99 3 98
3 98 2 97
2 97 1 96
1 96 1 95
6 100 5 99
5 99 4 98
4 98 3 97
3 97 2 96
2 96 1 95
1 95 1 94
7 100 6 99
6 99 5 98
5 98 4 97
4 97 3 96
3 96 2 95
2 95 1 94
1 94 1 93
8 100 7 9...

result:

ok 

Test #66:

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

input:

100 K
....................................................................................................
....................................................................................................
...............................................................................................

output:

YES

result:

ok 

Test #67:

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

input:

100 K
....................................................................................................
....................................................................................................
...............................................................................................

output:

NO

result:

ok 

Test #68:

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

input:

100 K
....K....K.......K.........K...............K....................K...K...............................
..K...........................................................K..K.K.....K......KK....K.......K..K..
......K....K.......K.K................K.K.K......K.......K.......K...............K.............

output:

NO

result:

ok 

Test #69:

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

input:

100 K
...KK.............K..KK..K.....K...K..K.K..K....K.....K.K...........K.K.......K..K.....K.K.K.K...K.K
.........K........K..K.........K...K....KK...........K..K..............K....K.......K..........KK..K
K...........K...KK...K....K............K..K.........K..........K......K..KK...K.....KK..K......

output:

NO

result:

ok 

Test #70:

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

input:

100 K
K....K...KKK..KKK..K............K......K.K...K...K......KK...K...K...K..K..K......KKK....K........K.
KK......K.K......KK....K...KKKK..K.K.K.K....K..K...KK.K...........K..K.....K........K....KK.K...KK..
K..K..........KK....K...KK.K.K..........KK...KKK.KKKK.KK..K....KK.K...K.K.KK..KK.KK.......KK...

output:

NO

result:

ok 

Test #71:

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

input:

3 K
KKK
K.K
KKK

output:

YES
1 3 1 2
3 3 2 3
2 3 1 2
1 2 1 1
3 1 2 1
3 2 2 1
2 1 1 1

result:

ok 

Test #72:

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

input:

19 K
KKKKKKKKKKKKKKKKKKK
K.................K
K.................K
K.................K
K.................K
K.................K
K.................K
K.................K
K.................K
K.................K
K.................K
K.................K
K.................K
K.................K
K.................

output:

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

result:

ok 

Test #73:

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

input:

100 K
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
K..................................................................................................K
K..............................................................................................

output:

YES
1 100 1 99
100 99 99 100
100 100 99 100
99 100 98 100
98 100 97 100
97 100 96 100
96 100 95 100
95 100 94 100
94 100 93 100
93 100 92 100
92 100 91 100
91 100 90 100
90 100 89 100
89 100 88 100
88 100 87 100
87 100 86 100
86 100 85 100
85 100 84 100
84 100 83 100
83 100 82 100
82 100 81 100
81 1...

result:

ok 

Test #74:

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

input:

3 K
K.K
.K.
K.K

output:

YES
1 3 2 2
3 1 2 2
3 3 2 2
2 2 1 1

result:

ok 

Test #75:

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

input:

21 K
K...................K
.K.................K.
..K...............K..
...K.............K...
....K...........K....
.....K.........K.....
......K.......K......
.......K.....K.......
........K...K........
.........K.K.........
..........K..........
.........K.K.........
........K...K........
.......K....

output:

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

result:

ok 

Test #76:

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

input:

99 K
K.................................................................................................K
.K...............................................................................................K.
..K...............................................................................................

output:

YES
1 99 2 98
2 98 3 97
3 97 4 96
4 96 5 95
5 95 6 94
6 94 7 93
7 93 8 92
8 92 9 91
9 91 10 90
10 90 11 89
11 89 12 88
12 88 13 87
13 87 14 86
14 86 15 85
15 85 16 84
16 84 17 83
17 83 18 82
18 82 19 81
19 81 20 80
20 80 21 79
21 79 22 78
22 78 23 77
23 77 24 76
24 76 25 75
25 75 26 74
26 74 27 73
2...

result:

ok 

Test #77:

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

input:

29 K
K.KKK.KKK.KKK.KKK.KKK.KKK.KKK
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
K.K.K.K.K.K.K.K.K.K.K.K.K...

output:

YES
29 1 28 1
1 5 1 4
29 5 28 5
1 9 1 8
29 9 28 9
1 13 1 12
29 13 28 13
1 17 1 16
29 17 28 17
1 21 1 20
29 21 28 21
1 25 1 24
29 25 28 25
1 29 1 28
29 29 28 29
28 29 27 29
27 29 26 29
26 29 25 29
25 29 24 29
24 29 23 29
23 29 22 29
22 29 21 29
21 29 20 29
20 29 19 29
19 29 18 29
18 29 17 29
17 29 16...

result:

ok 

Test #78:

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

input:

100 K
K.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KKK.KK
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K....

output:

YES
100 1 99 1
1 5 1 4
100 5 99 5
1 9 1 8
100 9 99 9
1 13 1 12
100 13 99 13
1 17 1 16
100 17 99 17
1 21 1 20
100 21 99 21
1 25 1 24
100 25 99 25
1 29 1 28
100 29 99 29
1 33 1 32
100 33 99 33
1 37 1 36
100 37 99 37
1 41 1 40
100 41 99 41
1 45 1 44
100 45 99 45
1 49 1 48
100 49 99 49
1 53 1 52
100 53 ...

result:

ok 

Test #79:

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

input:

31 K
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
.K.K.K....

output:

YES
1 31 2 30
3 31 2 30
2 30 1 29
1 29 2 28
5 31 4 30
4 30 3 29
3 29 2 28
2 28 1 27
1 27 2 26
7 31 6 30
6 30 5 29
5 29 4 28
4 28 3 27
3 27 2 26
2 26 1 25
1 25 2 24
9 31 8 30
8 30 7 29
7 29 6 28
6 28 5 27
5 27 4 26
4 26 3 25
3 25 2 24
2 24 1 23
1 23 2 22
11 31 10 30
10 30 9 29
9 29 8 28
8 28 7 27
7 2...

result:

ok 

Test #80:

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

input:

100 K
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.
.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K....

output:

YES
2 100 1 99
1 99 2 98
4 100 3 99
3 99 2 98
2 98 1 97
1 97 2 96
6 100 5 99
5 99 4 98
4 98 3 97
3 97 2 96
2 96 1 95
1 95 2 94
8 100 7 99
7 99 6 98
6 98 5 97
5 97 4 96
4 96 3 95
3 95 2 94
2 94 1 93
1 93 2 92
10 100 9 99
9 99 8 98
8 98 7 97
7 97 6 96
6 96 5 95
5 95 4 94
4 94 3 93
3 93 2 92
2 92 1 91
...

result:

ok 

Test #81:

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

input:

100 K
.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K
K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.
.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K.K...

output:

YES
100 1 99 2
100 3 99 2
99 2 98 1
98 1 97 2
100 5 99 4
99 4 98 3
98 3 97 2
97 2 96 1
96 1 95 2
100 7 99 6
99 6 98 5
98 5 97 4
97 4 96 3
96 3 95 2
95 2 94 1
94 1 93 2
100 9 99 8
99 8 98 7
98 7 97 6
97 6 96 5
96 5 95 4
95 4 94 3
94 3 93 2
93 2 92 1
92 1 91 2
100 11 99 10
99 10 98 9
98 9 97 8
97 8 96...

result:

ok 

Test #82:

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

input:

1 N
N

output:

YES

result:

ok 

Test #83:

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

input:

2 N
NN
NN

output:

NO

result:

ok 

Test #84:

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

input:

3 N
NNN
NNN
NNN

output:

NO

result:

ok 

Test #85:

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

input:

5 N
NNNNN
NNNNN
NNNNN
NNNNN
NNNNN

output:

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

result:

ok 

Test #86:

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

input:

17 N
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNN
NNNNNNN...

output:

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

result:

ok 

Test #87:

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

input:

100 N
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

output:

YES
9 1 7 2
7 2 5 3
5 3 3 4
3 4 1 5
17 1 15 2
15 2 13 3
13 3 11 4
11 4 9 5
9 5 7 6
7 6 5 7
5 7 3 8
3 8 1 9
25 1 23 2
23 2 21 3
21 3 19 4
19 4 17 5
17 5 15 6
15 6 13 7
13 7 11 8
11 8 9 9
9 9 7 10
7 10 5 11
5 11 3 12
3 12 1 13
33 1 31 2
31 2 29 3
29 3 27 4
27 4 25 5
25 5 23 6
23 6 21 7
21 7 19 8
19 8 ...

result:

ok 

Test #88:

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

input:

100 N
....................................................................................................
....................................................................................................
...............................................................................................

output:

YES

result:

ok 

Test #89:

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

input:

100 N
....................................................................................................
....................................................................................................
...............................................................................................

output:

NO

result:

ok 

Test #90:

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

input:

100 N
........N.....NN...........N.N........N......N......N............NN........N.N..........N........N..
...........N..................N...........N....NN........N................N.......................N.
N..........N...........................N..N.................N......N.................N.........

output:

NO

result:

ok 

Test #91:

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

input:

100 N
.N...NN..N..N..N.N....NN........N..N.N..N..N......N...NN...N........N...................NN..........
....N....N...N.NNN...NN.NNN....NN................N...............N..........N.N....N.........N.N..N.
...NN..N......N....NN........N..N...N.....N......................N.N.N.......N...NN.....N.N....

output:

NO

result:

ok 

Test #92:

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

input:

100 N
......N...N.N.NN........NN.NN.........NN...NNN.NN..NNNN..N.N..NN....NN...N....N.N....NNN........N...
.NNNNNN.....NN......N.N..N.N........N.N......NNNNN.....N..NN..N.....N.N...N.N..N.....N..N.N.N.......
NN.....NNN..........N..N..NN....NN......NN.....N.N........NN....NN.NN..N.N...N...N.N....NN.....

output:

NO

result:

ok 

Test #93:

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

input:

3 N
NNN
N.N
NNN

output:

YES
1 2 3 1
3 1 2 3
2 3 1 1
3 3 2 1
2 1 1 3
1 3 3 2
3 2 1 1

result:

ok 

Test #94:

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

input:

19 N
NNNNNNNNNNNNNNNNNNN
N.................N
N.................N
N.................N
N.................N
N.................N
N.................N
N.................N
N.................N
N.................N
N.................N
N.................N
N.................N
N.................N
N.................

output:

NO

result:

ok 

Test #95:

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

input:

100 N
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
N..................................................................................................N
N..............................................................................................

output:

NO

result:

ok 

Test #96:

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

input:

3 N
N.N
.N.
N.N

output:

NO

result:

ok 

Test #97:

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

input:

21 N
N...................N
.N.................N.
..N...............N..
...N.............N...
....N...........N....
.....N.........N.....
......N.......N......
.......N.....N.......
........N...N........
.........N.N.........
..........N..........
.........N.N.........
........N...N........
.......N....

output:

NO

result:

ok 

Test #98:

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

input:

99 N
N.................................................................................................N
.N...............................................................................................N.
..N...............................................................................................

output:

NO

result:

ok 

Test #99:

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

input:

29 N
N.NNN.NNN.NNN.NNN.NNN.NNN.NNN
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
N.N.N.N.N.N.N.N.N.N.N.N.N...

output:

YES
1 29 2 27
15 1 14 3
14 3 13 5
13 5 12 7
12 7 11 9
11 9 10 11
10 11 9 13
9 13 8 15
8 15 7 17
7 17 6 19
6 19 5 21
5 21 4 23
4 23 3 25
3 25 2 27
17 1 16 3
16 3 15 5
15 5 14 7
14 7 13 9
13 9 12 11
12 11 11 13
11 13 10 15
10 15 9 17
9 17 8 19
8 19 7 21
7 21 6 23
6 23 5 25
5 25 4 27
19 1 18 3
18 3 17 ...

result:

ok 

Test #100:

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

input:

100 N
N.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NNN.NN
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N....

output:

YES
51 1 50 3
50 3 49 5
49 5 48 7
48 7 47 9
47 9 46 11
46 11 45 13
45 13 44 15
44 15 43 17
43 17 42 19
42 19 41 21
41 21 40 23
40 23 39 25
39 25 38 27
38 27 37 29
37 29 36 31
36 31 35 33
35 33 34 35
34 35 33 37
33 37 32 39
32 39 31 41
31 41 30 43
30 43 29 45
29 45 28 47
28 47 27 49
27 49 26 51
26 51...

result:

ok 

Test #101:

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

input:

31 N
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
.N.N.N....

output:

NO

result:

ok 

Test #102:

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

input:

100 N
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.
.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N....

output:

NO

result:

ok 

Test #103:

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

input:

100 N
.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N
N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.
.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N.N...

output:

NO

result:

ok 

Test #104:

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

input:

1 Q
Q

output:

YES

result:

ok 

Test #105:

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

input:

2 Q
QQ
QQ

output:

YES
1 2 1 1
2 2 2 1
2 1 1 1

result:

ok 

Test #106:

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

input:

3 Q
QQQ
QQQ
QQQ

output:

YES
1 3 1 2
1 2 1 1
2 3 2 2
2 2 2 1
3 3 3 2
3 2 3 1
3 1 2 1
2 1 1 1

result:

ok 

Test #107:

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

input:

5 Q
QQQQQ
QQQQQ
QQQQQ
QQQQQ
QQQQQ

output:

YES
1 5 1 4
1 4 1 3
1 3 1 2
1 2 1 1
2 5 2 4
2 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QQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

output:

YES
1 100 1 99
1 99 1 98
1 98 1 97
1 97 1 96
1 96 1 95
1 95 1 94
1 94 1 93
1 93 1 92
1 92 1 91
1 91 1 90
1 90 1 89
1 89 1 88
1 88 1 87
1 87 1 86
1 86 1 85
1 85 1 84
1 84 1 83
1 83 1 82
1 82 1 81
1 81 1 80
1 80 1 79
1 79 1 78
1 78 1 77
1 77 1 76
1 76 1 75
1 75 1 74
1 74 1 73
1 73 1 72
1 72 1 71
1 71 ...

result:

ok 

Test #110:

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

input:

100 Q
....................................................................................................
....................................................................................................
...............................................................................................

output:

YES

result:

ok 

Test #111:

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

input:

100 Q
....................................................................................................
....................................................................................................
...............................................................................................

output:

NO

result:

ok 

Test #112:

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

input:

100 Q
Q...........................................................Q...............Q.......................
.....Q...Q..Q............Q.......Q...................Q..............Q..Q...Q....Q..Q................
.......Q...Q.....Q.......Q...............................QQ.Q.......Q........Q...Q.Q...........

output:

YES
1 77 1 61
14 99 14 93
14 93 14 79
14 79 14 77
14 77 14 74
14 74 14 64
14 64 14 62
14 62 14 48
14 48 14 44
14 44 14 40
14 40 14 33
14 33 14 29
14 29 14 20
14 20 14 4
14 4 5 4
5 4 5 8
5 82 5 77
5 77 5 70
5 70 5 46
5 46 5 17
6 11 6 16
6 16 6 17
6 93 6 81
6 81 6 52
6 52 6 17
6 17 5 17
5 17 5 14
5 14...

result:

ok 

Test #113:

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

input:

100 Q
.............QQ..QQ...Q.....Q.Q.......Q.....Q..Q......Q...QQ......Q.......Q.QQQ.....Q....Q......Q...
.....QQQ...Q.......QQ.........Q......Q.....QQ...Q...Q.....Q........Q.....QQ....Q...........Q......Q.
QQ.......Q..Q........Q........Q.......Q.....Q..........Q..Q..Q.......Q........QQQ.QQ...Q.......

output:

YES
1 97 1 90
1 90 1 85
1 85 1 79
1 79 1 78
1 78 1 77
1 77 1 75
1 75 1 67
1 67 1 60
1 60 1 59
1 59 1 55
1 55 1 48
1 48 1 45
1 45 1 39
1 39 1 31
10 95 10 87
10 87 10 86
10 86 10 84
10 84 10 74
10 74 10 62
10 62 10 53
10 53 10 34
10 34 10 28
10 28 10 21
10 21 10 20
10 20 10 6
10 6 2 6
2 6 2 7
2 7 2 8
...

result:

ok 

Test #114:

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

input:

100 Q
Q.Q..QQ....QQ.QQQ.QQ..QQ..Q...Q....Q..Q..QQQ.Q.Q...QQ..Q.Q..............Q.....QQ.Q..Q..Q.....Q..Q...
...........Q.Q.QQQ.......QQ.Q..Q..Q...Q....Q...QQ.QQ............Q.QQQ.........Q....QQ............QQ.
Q..QQQQ.Q....Q.....Q......Q..Q.Q....Q.Q.Q.....Q....Q......QQ..Q.....Q.....QQQ.....Q.....Q..Q...

output:

YES
1 97 1 94
1 94 1 88
1 88 1 85
1 85 1 82
1 82 1 80
1 80 1 79
1 79 1 73
1 73 1 58
1 58 1 56
1 56 1 53
1 53 1 52
1 52 1 48
1 48 1 46
1 46 1 44
1 44 1 43
1 43 1 42
1 42 1 39
1 39 1 36
1 36 1 31
1 31 1 27
1 27 1 24
1 24 1 23
1 23 1 20
1 20 1 19
1 19 1 17
1 17 1 16
1 16 1 15
1 15 1 13
1 13 1 12
2 99 2...

result:

ok 

Test #115:

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

input:

3 Q
QQQ
Q.Q
QQQ

output:

YES
1 3 1 2
1 2 1 1
2 3 2 1
3 3 3 2
3 2 3 1
3 1 2 1
2 1 1 1

result:

ok 

Test #116:

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

input:

19 Q
QQQQQQQQQQQQQQQQQQQ
Q.................Q
Q.................Q
Q.................Q
Q.................Q
Q.................Q
Q.................Q
Q.................Q
Q.................Q
Q.................Q
Q.................Q
Q.................Q
Q.................Q
Q.................Q
Q.................

output:

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

result:

ok 

Test #117:

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

input:

100 Q
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
Q..................................................................................................Q
Q..............................................................................................

output:

YES
1 100 1 99
1 99 1 98
1 98 1 97
1 97 1 96
1 96 1 95
1 95 1 94
1 94 1 93
1 93 1 92
1 92 1 91
1 91 1 90
1 90 1 89
1 89 1 88
1 88 1 87
1 87 1 86
1 86 1 85
1 85 1 84
1 84 1 83
1 83 1 82
1 82 1 81
1 81 1 80
1 80 1 79
1 79 1 78
1 78 1 77
1 77 1 76
1 76 1 75
1 75 1 74
1 74 1 73
1 73 1 72
1 72 1 71
1 71 ...

result:

ok 

Test #118:

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

input:

3 Q
Q.Q
.Q.
Q.Q

output:

YES
1 3 1 1
3 3 3 1
3 1 1 1
2 2 1 1

result:

ok 

Test #119:

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

input:

21 Q
Q...................Q
.Q.................Q.
..Q...............Q..
...Q.............Q...
....Q...........Q....
.....Q.........Q.....
......Q.......Q......
.......Q.....Q.......
........Q...Q........
.........Q.Q.........
..........Q..........
.........Q.Q.........
........Q...Q........
.......Q....

output:

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

result:

ok 

Test #120:

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

input:

99 Q
Q.................................................................................................Q
.Q...............................................................................................Q.
..Q...............................................................................................

output:

YES
1 99 1 1
99 99 99 1
99 1 1 1
2 98 2 2
98 98 98 2
98 2 2 2
3 97 3 3
97 97 97 3
97 3 3 3
4 96 4 4
96 96 96 4
96 4 4 4
5 95 5 5
95 95 95 5
95 5 5 5
6 94 6 6
94 94 94 6
94 6 6 6
7 93 7 7
93 93 93 7
93 7 7 7
8 92 8 8
92 92 92 8
92 8 8 8
9 91 9 9
91 91 91 9
91 9 9 9
10 90 10 10
90 90 90 10
90 10 10 10...

result:

ok 

Test #121:

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

input:

29 Q
Q.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ
Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q
Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q
Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q
Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q
Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q
Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q
Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q
Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q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 76
1 76 1 74
1 74 1 72
1 72 1 70
1 70 1 68
1 68 1 66
1 66 1 64
1 64 1 62
1 62 1 60
1 60 1 58
1 58 1 56
1 56 1 54
1 54 1 52
1 52 1 50
1 50 1 48
1 48 1 46
1 46 1 44
1 44 1 42
1 42 ...

result:

ok 

Test #126:

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

input:

1 R
R

output:

YES

result:

ok 

Test #127:

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

input:

2 R
RR
RR

output:

YES
1 2 1 1
2 2 2 1
2 1 1 1

result:

ok 

Test #128:

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

input:

3 R
RRR
RRR
RRR

output:

YES
1 3 1 2
1 2 1 1
2 3 2 2
2 2 2 1
3 3 3 2
3 2 3 1
3 1 2 1
2 1 1 1

result:

ok 

Test #129:

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

input:

5 R
RRRRR
RRRRR
RRRRR
RRRRR
RRRRR

output:

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

result:

ok 

Test #130:

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

input:

17 R
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRR
RRRRRRR...

output:

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

result:

ok 

Test #131:

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

input:

100 R
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

output:

YES
1 100 1 99
1 99 1 98
1 98 1 97
1 97 1 96
1 96 1 95
1 95 1 94
1 94 1 93
1 93 1 92
1 92 1 91
1 91 1 90
1 90 1 89
1 89 1 88
1 88 1 87
1 87 1 86
1 86 1 85
1 85 1 84
1 84 1 83
1 83 1 82
1 82 1 81
1 81 1 80
1 80 1 79
1 79 1 78
1 78 1 77
1 77 1 76
1 76 1 75
1 75 1 74
1 74 1 73
1 73 1 72
1 72 1 71
1 71 ...

result:

ok 

Test #132:

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

input:

100 R
....................................................................................................
....................................................................................................
...............................................................................................

output:

YES

result:

ok 

Test #133:

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

input:

100 R
....................................................................................................
....................................................................................................
...............................................................................................

output:

NO

result:

ok 

Test #134:

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

input:

100 R
..........R............R....R....R.....R.RR.............R..........................R................
...R....R..........R......................R.R.......R......R.....................R..R.....R.R...R.R.
..........R...R........R..................R..R..............R...RR....R...R............R.......

output:

YES
1 84 1 57
1 57 1 43
2 4 2 9
4 5 4 9
10 95 10 86
10 86 10 64
10 64 10 40
10 40 10 27
10 27 10 12
10 12 10 5
21 100 21 94
21 94 21 86
21 86 21 68
21 68 21 60
21 60 21 58
21 58 21 51
21 51 21 28
21 28 21 5
48 95 48 85
48 85 48 77
48 77 48 70
48 70 48 67
48 67 48 41
48 41 48 37
48 37 48 5
48 5 21 5
...

result:

ok 

Test #135:

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

input:

100 R
R.....R.R..........R..R.....R....R.....RR.RR.RR.R.R...R.RR.R....RR................R.....R.R.R.....R.
....R...R.........R................R..........R...........R....R.......R.R..R.R.R.......RRRR.RRRR.R.
..R.......R....RRR.......R.........R....R.........R.RRR....R.....RRR.R.R..R..R.R....R....RRR...

output:

YES
1 99 1 93
1 93 1 91
1 91 1 89
1 89 1 83
1 83 1 66
1 66 1 65
1 65 1 60
1 60 1 58
1 58 1 57
1 57 1 55
1 55 1 51
1 51 1 49
1 49 1 47
1 47 1 46
1 46 1 44
1 44 1 43
1 43 1 41
1 41 1 40
1 40 1 34
1 34 1 29
1 29 1 23
1 23 1 20
1 20 1 9
2 5 2 9
2 99 2 97
2 97 2 96
2 96 2 95
2 95 2 94
2 94 2 92
2 92 2 91...

result:

ok 

Test #136:

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

input:

100 R
...R...R.....R........R....RRRR.R.RR.RR......R....R.R..R....RR.R.R..RR......RR...R....R...R...RRR...
....RR...R.R.R.R.R.RRR..R....R..R.R...RR.....R.R...RRR..R......R..R...R....R..RR.RRRR.R..RR..R....R.
R..R..RR.....R....RR.....RRRR..R..R.R.RRR.R...R.RRR.RR...R....R..R......R...........RR..R.R....

output:

YES
1 97 1 96
1 96 1 95
1 95 1 91
1 91 1 87
1 87 1 82
1 82 1 78
1 78 1 77
1 77 1 70
1 70 1 69
1 69 1 66
1 66 1 64
1 64 1 62
1 62 1 61
1 61 1 56
1 56 1 53
1 53 1 51
1 51 1 46
1 46 1 39
1 39 1 38
1 38 1 36
1 36 1 35
1 35 1 33
1 33 1 31
1 31 1 30
1 30 1 29
1 29 1 28
1 28 1 23
1 23 1 14
9 94 9 86
9 86 9...

result:

ok 

Test #137:

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

input:

3 B
B..
B..
..B

output:

NO

result:

ok 

Test #138:

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

input:

3 R
RRR
R.R
RRR

output:

YES
1 3 1 2
1 2 1 1
2 3 2 1
3 3 3 2
3 2 3 1
3 1 2 1
2 1 1 1

result:

ok 

Test #139:

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

input:

19 R
RRRRRRRRRRRRRRRRRRR
R.................R
R.................R
R.................R
R.................R
R.................R
R.................R
R.................R
R.................R
R.................R
R.................R
R.................R
R.................R
R.................R
R.................

output:

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

result:

ok 

Test #140:

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

input:

100 R
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
R..................................................................................................R
R..............................................................................................

output:

YES
1 100 1 99
1 99 1 98
1 98 1 97
1 97 1 96
1 96 1 95
1 95 1 94
1 94 1 93
1 93 1 92
1 92 1 91
1 91 1 90
1 90 1 89
1 89 1 88
1 88 1 87
1 87 1 86
1 86 1 85
1 85 1 84
1 84 1 83
1 83 1 82
1 82 1 81
1 81 1 80
1 80 1 79
1 79 1 78
1 78 1 77
1 77 1 76
1 76 1 75
1 75 1 74
1 74 1 73
1 73 1 72
1 72 1 71
1 71 ...

result:

ok 

Test #141:

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

input:

3 R
R.R
.R.
R.R

output:

NO

result:

ok 

Test #142:

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

input:

21 R
R...................R
.R.................R.
..R...............R..
...R.............R...
....R...........R....
.....R.........R.....
......R.......R......
.......R.....R.......
........R...R........
.........R.R.........
..........R..........
.........R.R.........
........R...R........
.......R....

output:

NO

result:

ok 

Test #143:

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

input:

99 R
R.................................................................................................R
.R...............................................................................................R.
..R...............................................................................................

output:

NO

result:

ok 

Test #144:

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

input:

29 R
R.RRR.RRR.RRR.RRR.RRR.RRR.RRR
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
R.R.R.R.R.R.R.R.R.R.R.R.R...

output:

YES
1 29 1 28
1 28 1 27
1 27 1 25
1 25 1 24
1 24 1 23
1 23 1 21
1 21 1 20
1 20 1 19
1 19 1 17
1 17 1 16
1 16 1 15
1 15 1 13
1 13 1 12
1 12 1 11
1 11 1 9
1 9 1 8
1 8 1 7
1 7 1 5
1 5 1 4
1 4 1 3
1 3 1 1
2 29 2 27
2 27 2 25
2 25 2 23
2 23 2 21
2 21 2 19
2 19 2 17
2 17 2 15
2 15 2 13
2 13 2 11
2 11 2 9
...

result:

ok 

Test #145:

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

input:

100 R
R.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RRR.RR
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R....

output:

YES
1 100 1 99
1 99 1 97
1 97 1 96
1 96 1 95
1 95 1 93
1 93 1 92
1 92 1 91
1 91 1 89
1 89 1 88
1 88 1 87
1 87 1 85
1 85 1 84
1 84 1 83
1 83 1 81
1 81 1 80
1 80 1 79
1 79 1 77
1 77 1 76
1 76 1 75
1 75 1 73
1 73 1 72
1 72 1 71
1 71 1 69
1 69 1 68
1 68 1 67
1 67 1 65
1 65 1 64
1 64 1 63
1 63 1 61
1 61 ...

result:

ok 

Test #146:

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

input:

31 R
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
.R.R.R....

output:

NO

result:

ok 

Test #147:

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

input:

100 R
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.
.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R....

output:

NO

result:

ok 

Test #148:

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

input:

100 R
.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R
R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.
.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R.R...

output:

NO

result:

ok