QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#202878#2477. ExcavationPhantomThreshold#AC ✓224ms5132kbC++202.9kb2023-10-06 13:54:242023-10-06 13:54:24

Judging History

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

  • [2023-10-06 13:54:24]
  • 评测
  • 测评结果:AC
  • 用时:224ms
  • 内存:5132kb
  • [2023-10-06 13:54:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	int n;
	char ch;
	cin>>n>>ch;
	vector<string> a(n+5);
	string tt;
	getline(cin,tt);
	for(int i=1;i<=n;i++)
	{
		getline(cin,tt);
//		tt="BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB";
		a[i]=' '+tt;
	}
	if(ch=='B')
	{
		int tmp=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				if(a[i][j]=='B')
				{
					tmp|=1<<((i+j)%2);
				}
			}
		}
		if(tmp==3)
		{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	auto inb=[&](int x,int y){return 1<=x and x<=n and 1<=y and y<=n;};
	vector<vector<int>> G(n*n+5);
	auto addedge=[&](int u,int v)
	{
		G[v].push_back(u);
	};
	auto hs=[&](int x,int y){return (x-1)*n+y;};
	vector<int> dx={1,0,-1,0,1,1,-1,-1};
	vector<int> dy={0,1,0,-1,1,-1,1,-1};
	vector<int> ndx={1,2,-2,1,-1,2,-1,-2};
	vector<int> ndy={2,1,1,-2,2,-1,-2,-1};
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[i][j]=='K')
			{
				for(int d=0;d<8;d++)
				{
					int nx=i+dx[d],ny=j+dy[d];
					if(inb(nx,ny) and a[nx][ny]!='.')
						addedge(hs(i,j),hs(nx,ny));
				}
				cnt++;
			}
			else if(a[i][j]=='Q')
			{
				for(int d=0;d<8;d++)
				{
					for(int t=1;t<=n;t++)
					{
						int nx=i+dx[d]*t,ny=j+dy[d]*t;
						if(inb(nx,ny) and a[nx][ny]!='.')
						{
							addedge(hs(i,j),hs(nx,ny));
							break;
						}
					}
				}
				cnt++;
			}
			else if(a[i][j]=='R')
			{
				for(int d=0;d<4;d++)
				{
					for(int t=1;t<=n;t++)
					{
						int nx=i+dx[d]*t,ny=j+dy[d]*t;
						if(inb(nx,ny) and a[nx][ny]!='.')
						{
							addedge(hs(i,j),hs(nx,ny));
							break;
						}
					}
				}
				cnt++;
			}
			else if(a[i][j]=='B')
			{
				for(int d=4;d<8;d++)
				{
					for(int t=1;t<=n;t++)
					{
						int nx=i+dx[d]*t,ny=j+dy[d]*t;
						if(inb(nx,ny) and a[nx][ny]!='.')
						{
							addedge(hs(i,j),hs(nx,ny));
							break;
						}
					}
				}
				cnt++;
			}
			else if(a[i][j]=='N')
			{
				for(int d=0;d<8;d++)
				{
					int nx=i+ndx[d],ny=j+ndy[d];
					if(inb(nx,ny) and a[nx][ny]!='.')
						addedge(hs(i,j),hs(nx,ny));
				}
				cnt++;
			}
		}
	}
	vector<int> pa(n*n+5),vis(n*n+5),ord;
	function<void(int)> dfs=[&](int u)
	{
		vis[u]=1;
		for(auto v:G[u])
		{
			if(not vis[v])
			{
				pa[v]=u;
				dfs(v);
			}
		}
		ord.push_back(u);
	};
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
		{
			if(a[i][j]=='.')continue;
			ord.clear();
			fill(pa.begin(),pa.end(),0);
			fill(vis.begin(),vis.end(),0);
			dfs(hs(i,j));
			if((int)ord.size()==cnt)
			{
				cout<<"YES"<<endl;
				for(auto u:ord)
				{
					int v=pa[u];
					if(v)
					{
						cout<<(u-1)/n+1<<' '<<(u-1)%n+1<<' ';
						cout<<(v-1)/n+1<<' '<<(v-1)%n+1<<"\n";
					}
				}
				return 0;
			}
		}
	cout<<"NO"<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3544kb

input:

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

output:

NO

result:

ok 

Test #2:

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

input:

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

output:

NO

result:

ok 

Test #3:

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

input:

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

output:

NO

result:

ok 

Test #4:

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

input:

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

output:

NO

result:

ok 

Test #5:

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

input:

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

output:

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

result:

ok 

Test #6:

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

input:

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

output:

NO

result:

ok 

Test #7:

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

input:

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

output:

NO

result:

ok 

Test #8:

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

input:

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

output:

NO

result:

ok 

Test #9:

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

input:

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

output:

NO

result:

ok 

Test #10:

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

input:

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

output:

NO

result:

ok 

Test #11:

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

input:

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

output:

NO

result:

ok 

Test #12:

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

input:

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

output:

NO

result:

ok 

Test #13:

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

input:

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

output:

NO

result:

ok 

Test #14:

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

input:

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

output:

NO

result:

ok 

Test #15:

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

input:

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

output:

NO

result:

ok 

Test #16:

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

input:

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

output:

NO

result:

ok 

Test #17:

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

input:

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

output:

NO

result:

ok 

Test #18:

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

input:

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

output:

NO

result:

ok 

Test #19:

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

input:

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

output:

NO

result:

ok 

Test #20:

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

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: 3428kb

input:

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

output:

NO

result:

ok 

Test #22:

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

input:

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

output:

NO

result:

ok 

Test #23:

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

input:

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

output:

NO

result:

ok 

Test #24:

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

input:

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

output:

NO

result:

ok 

Test #25:

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

input:

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

output:

NO

result:

ok 

Test #26:

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

input:

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

output:

NO

result:

ok 

Test #27:

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

input:

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

output:

NO

result:

ok 

Test #28:

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

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: 1ms
memory: 3456kb

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: 3500kb

input:

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

output:

NO

result:

ok 

Test #31:

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

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: 3436kb

input:

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

output:

YES
4 5 4 6
4 6 4 7
4 7 4 8
4 8 4 9
4 9 3 10
3 10 2 10
2 10 3 9
3 9 3 8
3 8 3 7
3 7 3 6
3 6 3 5
3 5 3 3
3 3 3 2
3 2 3 1
3 1 2 1
2 1 2 2
2 2 2 3
2 3 2 5
2 5 2 6
2 6 2 7
2 7 2 8
2 8 2 9
2 9 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 3
1 3 1 2
1 2 1 1

result:

ok 

Test #33:

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

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
3 3 5 5
4 10 5 9
8 8 7 9
7 9 6 10
6 10 5 9
5 9 6 8
6 8 7 7
7 7 6 6
6 6 5 5
5 5 4 6
4 6 5 7
5 7 4 8
4 8 3 9
3 9 2 10
2 10 1 9
1 9 2 8
2 8 3 7
3 7 1 5
1 5 2 4
2 4 1 3
1 3 2 2
2 2 1 1

result:

ok 

Test #34:

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

input:

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

output:

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

result:

ok 

Test #35:

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

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: 0ms
memory: 3500kb

input:

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

output:

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

result:

ok 

Test #37:

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

input:

2 K
K.
KK

output:

YES
2 2 2 1
2 1 1 1

result:

ok 

Test #38:

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

input:

1 B
B

output:

YES

result:

ok 

Test #39:

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

input:

2 B
BB
BB

output:

NO

result:

ok 

Test #40:

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

input:

3 B
BBB
BBB
BBB

output:

NO

result:

ok 

Test #41:

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

input:

5 B
BBBBB
BBBBB
BBBBB
BBBBB
BBBBB

output:

NO

result:

ok 

Test #42:

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

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: 0ms
memory: 3532kb

input:

100 B
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

NO

result:

ok 

Test #44:

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

input:

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

output:

YES

result:

ok 

Test #45:

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

input:

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

output:

NO

result:

ok 

Test #46:

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

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: 3448kb

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: 0ms
memory: 3452kb

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: 1ms
memory: 3436kb

input:

3 B
BBB
B.B
BBB

output:

NO

result:

ok 

Test #50:

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

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: 3464kb

input:

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

output:

NO

result:

ok 

Test #52:

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

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: 3548kb

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: 3572kb

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: 3492kb

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: 3468kb

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: 3584kb

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 1 4 2
3 31 4 30
7 1 8 2
7 31 8 30
11 1 12 2
11 31 12 30
15 1 16 2
15 31 16 30
19 1 20 2
19 31 20 30
23 1 24 2
23 31 24 30
27 1 28 2
27 31 28 30
31 29 30 30
31 31 30 30
30 30 29 31
29 31 28 30
28 30 29 29
29 29 30 28
31 27 30 28
30 28 29 27
29 27 30 26
31 25 30 26
30 26 29 25
29 25 30...

result:

ok 

Test #58:

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

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
3 1 4 2
4 100 5 99
7 1 8 2
8 100 9 99
11 1 12 2
12 100 13 99
15 1 16 2
16 100 17 99
19 1 20 2
20 100 21 99
23 1 24 2
24 100 25 99
27 1 28 2
28 100 29 99
31 1 32 2
32 100 33 99
35 1 36 2
36 100 37 99
39 1 40 2
40 100 41 99
43 1 44 2
44 100 45 99
47 1 48 2
48 100 49 99
51 1 52 2
52 100 53 99
55 1 ...

result:

ok 

Test #59:

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

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
1 100 2 99
4 1 5 2
3 100 4 99
8 1 9 2
7 100 8 99
12 1 13 2
11 100 12 99
16 1 17 2
15 100 16 99
20 1 21 2
19 100 20 99
24 1 25 2
23 100 24 99
28 1 29 2
27 100 28 99
32 1 33 2
31 100 32 99
36 1 37 2
35 100 36 99
40 1 41 2
39 100 40 99
44 1 45 2
43 100 44 99
48 1 49 2
47 100 48 99
52 1 53 2
51 100 ...

result:

ok 

Test #60:

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

input:

1 K
K

output:

YES

result:

ok 

Test #61:

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

input:

2 K
KK
KK

output:

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

result:

ok 

Test #62:

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

input:

3 K
KKK
KKK
KKK

output:

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

result:

ok 

Test #63:

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

input:

5 K
KKKKK
KKKKK
KKKKK
KKKKK
KKKKK

output:

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

result:

ok 

Test #64:

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

input:

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

output:

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

result:

ok 

Test #65:

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

input:

100 K
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK...

output:

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

result:

ok 

Test #66:

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

input:

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

output:

YES

result:

ok 

Test #67:

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

input:

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

output:

NO

result:

ok 

Test #68:

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

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: 4ms
memory: 3576kb

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: 6ms
memory: 3700kb

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: 3432kb

input:

3 K
KKK
K.K
KKK

output:

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

result:

ok 

Test #72:

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

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
2 1 3 1
3 1 4 1
4 1 5 1
5 1 6 1
6 1 7 1
7 1 8 1
8 1 9 1
9 1 10 1
10 1 11 1
11 1 12 1
12 1 13 1
13 1 14 1
14 1 15 1
15 1 16 1
16 1 17 1
17 1 18 1
19 1 18 1
18 1 19 2
19 2 19 3
19 3 19 4
19 4 19 5
19 5 19 6
19 6 19 7
19 7 19 8
19 8 19 9
19 9 19 10
19 10 19 11
19 11 19 12
19 12 19 13
19 13 19 14
19...

result:

ok 

Test #73:

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

input:

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

output:

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

result:

ok 

Test #74:

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

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: 1ms
memory: 3472kb

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: 3608kb

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: 3540kb

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 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 29
16 29 15 29
15 29 14 29
14 29 13 29
13 29 12 29
12 29 11 29
11 29 10 29
10 29 9 29
9 29 8 29
8 29 7 29
7 29 6 29
6 29 5 29
5 29 4 29
4 29 3 ...

result:

ok 

Test #78:

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

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
1 100 1 99
1 99 2 99
2 99 3 99
3 99 4 99
4 99 5 99
5 99 6 99
6 99 7 99
7 99 8 99
8 99 9 99
9 99 10 99
10 99 11 99
11 99 12 99
12 99 13 99
13 99 14 99
14 99 15 99
15 99 16 99
16 99 17 99
17 99 18 99
18 99 19 99
19 99 20 99
20 99 21 99
21 99 22 99
22 99 23 99
23 99 24 99
24 99 25 99
25 99 26 99
26...

result:

ok 

Test #79:

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

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 1 4 2
3 31 4 30
7 1 8 2
7 31 8 30
11 1 12 2
11 31 12 30
15 1 16 2
15 31 16 30
19 1 20 2
19 31 20 30
23 1 24 2
23 31 24 30
27 1 28 2
27 31 28 30
31 29 30 30
31 31 30 30
30 30 29 31
29 31 28 30
28 30 29 29
29 29 30 28
31 27 30 28
30 28 29 27
29 27 30 26
31 25 30 26
30 26 29 25
29 25 30...

result:

ok 

Test #80:

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

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
3 1 4 2
4 100 5 99
7 1 8 2
8 100 9 99
11 1 12 2
12 100 13 99
15 1 16 2
16 100 17 99
19 1 20 2
20 100 21 99
23 1 24 2
24 100 25 99
27 1 28 2
28 100 29 99
31 1 32 2
32 100 33 99
35 1 36 2
36 100 37 99
39 1 40 2
40 100 41 99
43 1 44 2
44 100 45 99
47 1 48 2
48 100 49 99
51 1 52 2
52 100 53 99
55 1 ...

result:

ok 

Test #81:

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

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
1 100 2 99
4 1 5 2
3 100 4 99
8 1 9 2
7 100 8 99
12 1 13 2
11 100 12 99
16 1 17 2
15 100 16 99
20 1 21 2
19 100 20 99
24 1 25 2
23 100 24 99
28 1 29 2
27 100 28 99
32 1 33 2
31 100 32 99
36 1 37 2
35 100 36 99
40 1 41 2
39 100 40 99
44 1 45 2
43 100 44 99
48 1 49 2
47 100 48 99
52 1 53 2
51 100 ...

result:

ok 

Test #82:

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

input:

1 N
N

output:

YES

result:

ok 

Test #83:

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

input:

2 N
NN
NN

output:

NO

result:

ok 

Test #84:

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

input:

3 N
NNN
NNN
NNN

output:

NO

result:

ok 

Test #85:

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

input:

5 N
NNNNN
NNNNN
NNNNN
NNNNN
NNNNN

output:

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

result:

ok 

Test #86:

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

input:

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

output:

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

result:

ok 

Test #87:

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

input:

100 N
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

output:

YES
3 100 5 99
4 1 6 2
5 100 7 99
9 1 11 2
8 100 10 99
19 1 21 2
22 1 24 2
13 100 15 99
24 1 26 2
25 1 27 2
16 100 18 99
18 100 20 99
30 1 32 2
22 100 24 99
21 100 23 99
39 1 41 2
24 100 26 99
46 1 48 2
49 1 51 2
30 100 32 99
31 100 33 99
57 1 59 2
64 1 66 2
33 100 35 99
34 100 36 99
35 100 37 99
36...

result:

ok 

Test #88:

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

input:

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

output:

YES

result:

ok 

Test #89:

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

input:

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

output:

NO

result:

ok 

Test #90:

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

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: 3632kb

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: 63ms
memory: 3708kb

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: 3444kb

input:

3 N
NNN
N.N
NNN

output:

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

result:

ok 

Test #94:

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

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: 1ms
memory: 3580kb

input:

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

output:

NO

result:

ok 

Test #96:

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

input:

3 N
N.N
.N.
N.N

output:

NO

result:

ok 

Test #97:

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

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: 3528kb

input:

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

output:

NO

result:

ok 

Test #99:

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

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
3 1 4 3
4 1 5 3
7 1 8 3
8 1 9 3
11 1 12 3
1 23 2 25
2 29 1 27
1 27 2 25
2 25 3 27
12 1 13 3
4 29 5 27
16 1 17 3
8 29 9 27
20 1 21 3
12 29 13 27
24 1 25 3
16 29 17 27
28 1 29 3
29 3 28 5
20 29 21 27
29 11 28 13
24 29 25 27
29 19 28 21
28 21 29 23
29 23 28 25
28 29 29 27
29 27 28 25
28 2...

result:

ok 

Test #100:

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

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
3 1 4 3
4 1 5 3
7 1 8 3
8 1 9 3
11 1 12 3
12 1 13 3
15 1 16 3
16 1 17 3
19 1 20 3
20 1 21 3
23 1 24 3
24 1 25 3
27 1 28 3
28 1 29 3
31 1 32 3
32 1 33 3
35 1 36 3
36 1 37 3
39 1 40 3
40 1 41 3
43 1 44 3
44 1 45 3
47 1 48 3
4 99 5 97
51 1 52 3
6 99 7 97
55 1 56 3
10 99 11 97
59 1 60 3
14 99 15 97
...

result:

ok 

Test #101:

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

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: 6ms
memory: 3544kb

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: 7ms
memory: 3540kb

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: 3436kb

input:

1 Q
Q

output:

YES

result:

ok 

Test #105:

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

input:

2 Q
QQ
QQ

output:

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

result:

ok 

Test #106:

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

input:

3 Q
QQQ
QQQ
QQQ

output:

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

result:

ok 

Test #107:

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

input:

5 Q
QQQQQ
QQQQQ
QQQQQ
QQQQQ
QQQQQ

output:

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

result:

ok 

Test #108:

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

input:

17 Q
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQQ...

output:

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

result:

ok 

Test #109:

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

input:

100 Q
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

output:

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

result:

ok 

Test #110:

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

input:

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

output:

YES

result:

ok 

Test #111:

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

input:

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

output:

NO

result:

ok 

Test #112:

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

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
48 11 53 16
22 100 28 100
28 100 33 95
49 34 64 34
71 46 75 50
85 9 87 11
58 99 71 99
85 24 85 37
75 6 77 8
77 8 93 8
89 17 89 16
92 13 89 16
88 60 94 60
90 54 90 56
81 98 86 98
82 83 90 83
89 86 95 92
95 51 95 40
95 40 89 40
89 40 89 46
96 62 98 64
100 45 100 47
100 47 100 49
100 49 100 60
91 7...

result:

ok 

Test #113:

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

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
59 95 62 92
59 70 64 75
84 62 92 54
96 25 97 26
97 3 98 4
98 1 98 4
100 5 100 9
100 9 100 17
100 17 100 26
100 26 95 21
95 21 99 21
99 21 99 9
99 9 99 5
99 5 98 4
98 4 98 9
98 9 98 13
98 13 98 14
98 14 98 16
98 16 98 17
98 17 98 20
98 20 98 26
98 62 97 62
97 62 97 64
97 64 98 65
98 65 98 69
99 8...

result:

ok 

Test #114:

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

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
49 12 54 17
62 100 63 100
78 99 80 97
96 1 96 4
88 98 91 95
95 63 95 65
95 40 98 43
100 9 100 13
100 13 100 15
100 15 100 24
98 30 100 30
100 40 100 46
98 88 98 86
98 86 99 85
100 72 100 76
100 76 100 79
100 79 100 81
100 81 100 82
100 82 100 83
100 83 100 87
100 87 100 89
100 89 100 95
100 100 ...

result:

ok 

Test #115:

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

input:

3 Q
QQQ
Q.Q
QQQ

output:

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

result:

ok 

Test #116:

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

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
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
19 1 18 1
18 1 18 19
18 19 17 19
17 19 17 1
17 1 16 1
16 1 16 19
16 19 15 19
15 19 15 1
15 1 14 1...

result:

ok 

Test #117:

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

input:

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

output:

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

result:

ok 

Test #118:

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

input:

3 Q
Q.Q
.Q.
Q.Q

output:

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

result:

ok 

Test #119:

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

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
21 1 21 21
21 21 20 20
20 20 20 2
20 2 19 3
19 3 19 19
19 19 18 18
18 18 18 4
18 4 17 5
17 5 17 17
17 17 16 16
16 16 16 6
16 6 15 7
15 7 15 15
15 15 14 14
14 14 14 8
14 8 13 9
13 9 13 13
13 13 12 12
12 12 12 10
12 10 11 11
11 11 10 10
10 10 10 12
10 12 9 13
9 13 9 9
9 9 8 8
8 8 8 14
8 14 7 15
7 ...

result:

ok 

Test #120:

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

input:

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

output:

YES
99 99 99 1
99 1 98 2
98 2 98 98
98 98 97 97
97 97 97 3
97 3 96 4
96 4 96 96
96 96 95 95
95 95 95 5
95 5 94 6
94 6 94 94
94 94 93 93
93 93 93 7
93 7 92 8
92 8 92 92
92 92 91 91
91 91 91 9
91 9 90 10
90 10 90 90
90 90 89 89
89 89 89 11
89 11 88 12
88 12 88 88
88 88 87 87
87 87 87 13
87 13 86 14
86...

result:

ok 

Test #121:

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

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
Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q.Q...

output:

YES
29 29 29 27
29 27 29 26
29 26 29 25
29 25 29 23
29 23 29 22
29 22 29 21
29 21 29 19
29 19 29 18
29 18 29 17
29 17 29 15
29 15 29 14
29 14 29 13
29 13 29 11
29 11 29 10
29 10 29 9
29 9 29 7
29 7 29 6
29 6 29 5
29 5 29 3
29 3 29 2
29 2 29 1
29 1 28 1
28 1 28 3
28 3 28 5
28 5 28 7
28 7 28 9
28 9 28...

result:

ok 

Test #122:

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

input:

100 Q
Q.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQQ.QQ
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....

output:

YES
100 1 100 2
100 2 100 3
100 3 100 5
100 5 100 6
100 6 100 7
100 7 100 9
100 9 100 10
100 10 100 11
100 11 100 13
100 13 100 14
100 14 100 15
100 15 100 17
100 17 100 18
100 18 100 19
100 19 100 21
100 21 100 22
100 22 100 23
100 23 100 25
100 25 100 26
100 26 100 27
100 27 100 29
100 29 100 30
1...

result:

ok 

Test #123:

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

input:

31 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.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
31 31 31 29
31 29 31 27
31 27 31 25
31 25 31 23
31 23 31 21
31 21 31 19
31 19 31 17
31 17 31 15
31 15 31 13
31 13 31 11
31 11 31 9
31 9 31 7
31 7 31 5
31 5 31 3
31 3 31 1
31 1 30 2
30 2 30 4
30 4 30 6
30 6 30 8
30 8 30 10
30 10 30 12
30 12 30 14
30 14 30 16
30 16 30 18
30 18 30 20
30 20 30 22
30...

result:

ok 

Test #124:

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

input:

100 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.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
100 2 100 4
100 4 100 6
100 6 100 8
100 8 100 10
100 10 100 12
100 12 100 14
100 14 100 16
100 16 100 18
100 18 100 20
100 20 100 22
100 22 100 24
100 24 100 26
100 26 100 28
100 28 100 30
100 30 100 32
100 32 100 34
100 34 100 36
100 36 100 38
100 38 100 40
100 40 100 42
100 42 100 44
100 44 10...

result:

ok 

Test #125:

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

input:

100 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.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
100 1 100 3
100 3 100 5
100 5 100 7
100 7 100 9
100 9 100 11
100 11 100 13
100 13 100 15
100 15 100 17
100 17 100 19
100 19 100 21
100 21 100 23
100 23 100 25
100 25 100 27
100 27 100 29
100 29 100 31
100 31 100 33
100 33 100 35
100 35 100 37
100 37 100 39
100 39 100 41
100 41 100 43
100 43 100 ...

result:

ok 

Test #126:

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

input:

1 R
R

output:

YES

result:

ok 

Test #127:

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

input:

2 R
RR
RR

output:

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

result:

ok 

Test #128:

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

input:

3 R
RRR
RRR
RRR

output:

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

result:

ok 

Test #129:

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

input:

5 R
RRRRR
RRRRR
RRRRR
RRRRR
RRRRR

output:

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

result:

ok 

Test #130:

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

input:

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

output:

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

result:

ok 

Test #131:

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

input:

100 R
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

output:

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

result:

ok 

Test #132:

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

input:

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

output:

YES

result:

ok 

Test #133:

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

input:

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

output:

NO

result:

ok 

Test #134:

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

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
7 1 10 1
17 2 26 2
4 23 16 23
12 53 15 53
16 35 28 35
17 44 19 44
8 57 20 57
15 68 21 68
31 95 36 95
42 14 43 14
39 49 43 49
22 46 23 46
40 51 45 51
28 38 34 38
34 38 56 38
33 10 55 10
24 15 51 15
44 56 53 56
46 50 59 50
20 65 32 65
37 8 62 8
28 57 34 57
12 77 42 77
42 77 48 77
14 63 20 63
20 63...

result:

ok 

Test #135:

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

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
8 6 12 6
14 15 23 15
19 13 22 13
19 3 22 3
23 7 31 7
23 1 30 1
28 2 34 2
40 2 51 2
35 1 52 1
26 21 27 21
18 33 27 33
19 34 27 34
21 14 29 14
29 24 36 24
10 62 23 62
22 42 28 42
28 20 30 20
18 41 25 41
25 41 33 41
12 68 14 68
34 27 36 27
36 27 47 27
43 23 46 23
50 3 54 3
36 13 59 13
46 11 58 11
8...

result:

ok 

Test #136:

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

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
7 4 10 4
6 46 8 46
11 1 19 1
12 26 15 26
15 17 18 17
18 17 19 17
24 18 27 18
13 23 17 23
10 36 15 36
10 30 14 30
15 47 20 47
8 74 11 74
10 73 11 73
8 68 14 68
11 90 12 90
8 89 10 89
14 82 15 82
16 70 19 70
23 54 24 54
22 24 28 24
24 25 26 25
23 11 24 11
16 3 24 3
33 11 34 11
30 18 32 18
14 34 30...

result:

ok 

Test #137:

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

input:

3 B
B..
B..
..B

output:

NO

result:

ok 

Test #138:

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

input:

3 R
RRR
R.R
RRR

output:

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

result:

ok 

Test #139:

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

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
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
19 1 18 1
18 1 18 19
18 19 17 19
17 19 17 1
17 1 16 1
16 1 16 19
16 19 15 19
15 19 15 1
15 1 14 1...

result:

ok 

Test #140:

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

input:

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

output:

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

result:

ok 

Test #141:

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

input:

3 R
R.R
.R.
R.R

output:

NO

result:

ok 

Test #142:

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

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: 3616kb

input:

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

output:

NO

result:

ok 

Test #144:

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

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
29 29 29 27
29 27 29 26
29 26 29 25
29 25 29 23
29 23 29 22
29 22 29 21
29 21 29 19
29 19 29 18
29 18 29 17
29 17 29 15
29 15 29 14
29 14 29 13
29 13 29 11
29 11 29 10
29 10 29 9
29 9 29 7
29 7 29 6
29 6 29 5
29 5 29 3
29 3 29 2
29 2 29 1
29 1 28 1
28 1 28 3
28 3 28 5
28 5 28 7
28 7 28 9
28 9 28...

result:

ok 

Test #145:

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

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
100 1 100 2
100 2 100 3
100 3 100 5
100 5 100 6
100 6 100 7
100 7 100 9
100 9 100 10
100 10 100 11
100 11 100 13
100 13 100 14
100 14 100 15
100 15 100 17
100 17 100 18
100 18 100 19
100 19 100 21
100 21 100 22
100 22 100 23
100 23 100 25
100 25 100 26
100 26 100 27
100 27 100 29
100 ...

result:

ok 

Test #146:

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

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: 224ms
memory: 3960kb

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: 222ms
memory: 4008kb

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