QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#231768#2477. ExcavationsuperduchackgvAC ✓155ms25300kbC++203.9kb2023-10-29 16:20:342023-10-29 16:20:34

Judging History

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

  • [2023-10-29 16:20:34]
  • 评测
  • 测评结果:AC
  • 用时:155ms
  • 内存:25300kb
  • [2023-10-29 16:20:34]
  • 提交

answer

#include<bits/stdc++.h>
#define fo(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
#define ff first
#define ss second
#define vt vector
#define ins insert
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;

typedef unsigned long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef map<int, int> mii;
typedef vt<int> vti;
const double Pi = acos(- 1.0);
template<typename T>ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {for(T x : vec) cout << x << ' '; cout << endl;return os;}
const int inf = INT_MAX;




void Duck(){
	int n; cin >> n;
	vt<string> s(n);
	char type; cin >> type;
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	//cout << s;
	vt<array<int, 2>> pos;
	vt<vti> rpos(n, vti(n, -1));
	for(int i = 0; i < n; i++){
		for(int j = 0;  j < n; j++){
			if(s[i][j] != '.'){
				pos.pb({i, j});
				rpos[i][j] = pos.size()-1;
			}
		}
	}
	int m = pos.size();
	auto moveQ = [&](int x, int y){
		vt<array<int, 2>> res;
		for(int i = 0; i < m; i++){
			auto[nx, ny] = pos[i];
			if(nx == x && ny == y) continue;
			if(abs(nx - x) == abs(ny - y) || nx == x || ny == y){
				res.pb({nx, ny});
			}
		}
		return res;
	};
	auto moveK = [&](int x, int y){
		vt<array<int, 2>> res;
		for(int i = 0; i < m; i++){
			auto[nx, ny] = pos[i];
			if(nx == x && ny == y) continue;
			if((abs(ny - y) <= 1 && abs(nx - x) <= 1)){
				res.pb({nx, ny});
			}
		}
		return res;
	};
	auto moveR = [&](int x, int y){
		vt<array<int, 2>> res;
		for(int i = 0; i < m; i++){
			auto[nx, ny] = pos[i];
			if(nx == x && ny == y) continue;
			if(nx == x || ny == y){
				res.pb({nx, ny});
			}
		}
		return res;
	};
	auto moveB = [&](int x, int y){
		vt<array<int, 2>> res;
		for(int i = 0; i < m; i++){
			auto[nx, ny] = pos[i];
			if(nx == x && ny == y) continue;
			if(abs(nx - x) == abs(ny - y)){
				res.pb({nx, ny});
			}
		}
		return res;
	};
	auto moveN = [&](int x, int y){
		vt<array<int, 2>> res;
		for(int i = 0; i < m; i++){
			auto[nx, ny] = pos[i];
			if(nx == x && ny == y) continue;
			if((abs(ny - y) == 2 && abs(nx - x) == 1) || (abs(nx - x) == 2 && abs(ny - y) == 1)){
				res.pb({nx, ny});
			}
		}
		return res;
	};
	
	
	//vt<vt<array<int,2>>> g(m); 
	vt<vti> g(m);
	vti deg(m);
	for(int i = 0; i < m; i++){
		auto [x, y] = pos[i];
		if(type == 'K'){
			auto near = moveK(x, y);
			for(auto [nx, ny] : near){
				g[i].pb(rpos[nx][ny]);
				deg[i]++;
			}
		}
		if(type == 'Q'){
			auto near = moveQ(x, y);
			for(auto [nx, ny] : near){
				g[i].pb(rpos[nx][ny]);
				deg[i]++;
			}
		}
		if(type == 'R'){
			auto near = moveR(x, y);
			for(auto [nx, ny] : near){
				g[i].pb(rpos[nx][ny]);
				deg[i]++;
			}
		}
		if(type == 'B'){
			auto near = moveB(x, y);
			for(auto [nx, ny] : near){
				g[i].pb(rpos[nx][ny]);
				deg[i]++;
			}
		}
		if(type == 'N'){
			auto near = moveN(x, y);
			for(auto [nx, ny] : near){
				g[i].pb(rpos[nx][ny]);
				deg[i]++;
			}
		}
	}
//	cout << g;
	vt<array<int, 4>> ans;
	vti vis(m, 0);
	function<void(int)> dfs = [&](int i){
		vis[i] = 1;
		for(auto j : g[i]){
			if(!vis[j]){
				dfs(j);
				ans.pb({pos[j][0] + 1, pos[j][1] + 1, pos[i][0] + 1, pos[i][1] + 1});
			}
		}
	};
	dfs(0);
	for(int i = 0; i < m; i++){
		if(!vis[i]){
			cout << "NO\n";
			return;
		}
	}
	cout << "YES\n";
	for(auto [x, y, z, t] : ans){
		cout << x << ' ' << y << ' ' << z << ' ' << t << '\n';
	} 
}



int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	/*Duck3*/
	int t = 1;
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
	#endif
	//cin >> t;
	while(t--) Duck();
	return 0;
}
/*
Test:

*/










詳細信息

Test #1:

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

input:

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

output:

NO

result:

ok 

Test #2:

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

input:

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

output:

NO

result:

ok 

Test #3:

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

input:

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

output:

NO

result:

ok 

Test #4:

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

input:

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

output:

NO

result:

ok 

Test #5:

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

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

input:

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

output:

NO

result:

ok 

Test #7:

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

input:

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

output:

NO

result:

ok 

Test #8:

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

input:

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

output:

NO

result:

ok 

Test #9:

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

input:

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

output:

NO

result:

ok 

Test #10:

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

input:

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

output:

NO

result:

ok 

Test #11:

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

input:

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

output:

NO

result:

ok 

Test #12:

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

input:

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

output:

NO

result:

ok 

Test #13:

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

input:

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

output:

NO

result:

ok 

Test #14:

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

input:

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

output:

NO

result:

ok 

Test #15:

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

input:

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

output:

NO

result:

ok 

Test #16:

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

input:

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

output:

NO

result:

ok 

Test #17:

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

input:

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

output:

NO

result:

ok 

Test #18:

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

input:

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

output:

NO

result:

ok 

Test #19:

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

input:

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

output:

NO

result:

ok 

Test #20:

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

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

input:

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

output:

NO

result:

ok 

Test #22:

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

input:

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

output:

NO

result:

ok 

Test #23:

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

input:

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

output:

NO

result:

ok 

Test #24:

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

input:

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

output:

NO

result:

ok 

Test #25:

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

input:

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

output:

NO

result:

ok 

Test #26:

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

input:

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

output:

NO

result:

ok 

Test #27:

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

input:

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

output:

NO

result:

ok 

Test #28:

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

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

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

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

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

input:

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

output:

YES
4 8 4 7
4 7 4 6
4 6 4 5
4 5 4 9
4 9 3 10
3 10 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 3 9
3 9 2 10
2 10 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
2 1 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: 0ms
memory: 3624kb

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

input:

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

output:

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

result:

ok 

Test #35:

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

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

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

input:

2 K
K.
KK

output:

YES
2 2 2 1
2 1 1 1

result:

ok 

Test #38:

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

input:

1 B
B

output:

YES

result:

ok 

Test #39:

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

input:

2 B
BB
BB

output:

NO

result:

ok 

Test #40:

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

input:

3 B
BBB
BBB
BBB

output:

NO

result:

ok 

Test #41:

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

input:

5 B
BBBBB
BBBBB
BBBBB
BBBBB
BBBBB

output:

NO

result:

ok 

Test #42:

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

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

input:

100 B
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

NO

result:

ok 

Test #44:

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

input:

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

output:

YES

result:

ok 

Test #45:

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

input:

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

output:

NO

result:

ok 

Test #46:

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

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

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

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

input:

3 B
BBB
B.B
BBB

output:

NO

result:

ok 

Test #50:

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

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

input:

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

output:

NO

result:

ok 

Test #52:

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

input:

3 B
B.B
.B.
B.B

output:

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

result:

ok 

Test #53:

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

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

result:

ok 

Test #54:

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

input:

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

output:

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

result:

ok 

Test #55:

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

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

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

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

result:

ok 

Test #58:

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

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

result:

ok 

Test #59:

score: 0
Accepted
time: 35ms
memory: 8552kb

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

result:

ok 

Test #60:

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

input:

1 K
K

output:

YES

result:

ok 

Test #61:

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

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

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

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

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

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

input:

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

output:

YES

result:

ok 

Test #67:

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

input:

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

output:

NO

result:

ok 

Test #68:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

input:

1 N
N

output:

YES

result:

ok 

Test #83:

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

input:

2 N
NN
NN

output:

NO

result:

ok 

Test #84:

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

input:

3 N
NNN
NNN
NNN

output:

NO

result:

ok 

Test #85:

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

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

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

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

input:

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

output:

YES

result:

ok 

Test #89:

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

input:

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

output:

NO

result:

ok 

Test #90:

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

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

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

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

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

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

input:

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

output:

NO

result:

ok 

Test #96:

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

input:

3 N
N.N
.N.
N.N

output:

NO

result:

ok 

Test #97:

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

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

input:

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

output:

NO

result:

ok 

Test #99:

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

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

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

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

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

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

input:

1 Q
Q

output:

YES

result:

ok 

Test #105:

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

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

input:

3 Q
QQQ
QQQ
QQQ

output:

YES
3 3 3 1
3 1 3 2
3 2 2 3
2 3 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: 3540kb

input:

5 Q
QQQQQ
QQQQQ
QQQQQ
QQQQQ
QQQQQ

output:

YES
5 5 5 3
5 3 5 2
5 2 5 1
5 1 5 4
5 4 4 5
4 5 4 3
4 3 4 2
4 2 4 1
4 1 4 4
4 4 3 5
3 5 3 3
3 3 3 2
3 2 3 1
3 1 3 4
3 4 2 5
2 5 2 3
2 3 2 2
2 2 2 1
2 1 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: 3732kb

input:

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

output:

YES
17 17 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 17 16
17 16 16 17
16 17 16 15
16 15 16 14
16 14 16 13
16 13 16 12
16 12 16 11
16 11 16 10
16 10 16 9
16 9 16 8
16 8 16 7
16 7 16...

result:

ok 

Test #109:

score: 0
Accepted
time: 155ms
memory: 25300kb

input:

100 Q
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

output:

YES
100 100 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 100 80
100 80 100 79
100 79 100 78
1...

result:

ok 

Test #110:

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

input:

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

output:

YES

result:

ok 

Test #111:

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

input:

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

output:

NO

result:

ok 

Test #112:

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

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
89 91 89 86
96 96 96 62
98 92 98 80
98 80 98 56
98 56 98 47
97 88 97 82
97 82 97 52
93 63 93 70
93 70 91 70
91 70 99 70
99 94 99 87
99 87 99 70
100 98 100 81
100 81 100 60
100 60 100 47
100 47 100 42
100 42 100 71
100 71 99 70
99 70 99 65
99 65 99 61
99 61 99 33
99 33 99 26
99 26 99 41
99 41 100...

result:

ok 

Test #113:

score: 0
Accepted
time: 9ms
memory: 4720kb

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
98 99 98 88
99 85 99 84
99 84 99 82
99 82 99 78
100 93 100 92
100 92 100 89
100 89 100 76
100 76 100 74
100 74 100 53
100 53 100 51
100 51 100 49
100 49 100 46
100 46 100 43
100 43 100 38
100 38 100 37
100 37 100 35
100 35 100 34
100 34 100 27
100 27 100 26
100 26 100 17
100 17 100 9
100 9 100 7...

result:

ok 

Test #114:

score: 0
Accepted
time: 14ms
memory: 6008kb

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
99 92 99 85
99 85 99 76
100 99 100 95
100 95 100 89
100 89 100 87
100 87 100 83
100 83 100 82
100 82 100 81
100 81 100 79
100 79 100 72
100 72 100 70
100 70 100 66
100 66 100 64
100 64 100 61
100 61 100 60
100 60 100 57
100 57 100 55
100 55 100 51
100 51 100 50
100 50 100 47
100 47 100 46
100 46...

result:

ok 

Test #115:

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

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

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

input:

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

output:

YES
100 100 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 100 80
100 80 100 79
100 79 100 78
1...

result:

ok 

Test #118:

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

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

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

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

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 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 29 26
29 26 28 27
28 27 28 25
28 25 28 23
28 23 28 21
28 21 28 1...

result:

ok 

Test #122:

score: 0
Accepted
time: 44ms
memory: 9644kb

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 99 100 97
100 97 100 95
100 95 100 94
100 94 100 93
100 93 100 91
100 91 100 90
100 90 100 89
100 89 100 87
100 87 100 86
100 86 100 85
100 85 100 83
100 83 100 82
100 82 100 81
100 81 100 79
100 79 100 78
100 78 100 77
100 77 100 75
100 75 100 74
100 74 100 73
100 73 100 71
100 71 100 70
10...

result:

ok 

Test #123:

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

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 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 31 27
31 27 30 28
30 28 30 26
30 26 30 24
30 24 30 22
30 22 30 20
30 20 30 18
30 18 30 16
30 16 30 14
30 14 30 12
30 12 30 10
30 10 ...

result:

ok 

Test #124:

score: 0
Accepted
time: 45ms
memory: 10428kb

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 100 100 98
100 98 100 94
100 94 100 92
100 92 100 90
100 90 100 88
100 88 100 86
100 86 100 84
100 84 100 82
100 82 100 80
100 80 100 78
100 78 100 76
100 76 100 74
100 74 100 72
100 72 100 70
100 70 100 68
100 68 100 66
100 66 100 64
100 64 100 62
100 62 100 60
100 60 100 58
100 58 100 56
1...

result:

ok 

Test #125:

score: 0
Accepted
time: 45ms
memory: 10632kb

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 97 100 95
100 95 100 93
100 93 100 91
100 91 100 89
100 89 100 87
100 87 100 85
100 85 100 83
100 83 100 81
100 81 100 79
100 79 100 77
100 77 100 75
100 75 100 73
100 73 100 71
100 71 100 69
100 69 100 67
100 67 100 65
100 65 100 63
100 63 100 61
100 61 100 59
100 59 100 57
100 57 100 55
10...

result:

ok 

Test #126:

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

input:

1 R
R

output:

YES

result:

ok 

Test #127:

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

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

input:

3 R
RRR
RRR
RRR

output:

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

result:

ok 

Test #129:

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

input:

5 R
RRRRR
RRRRR
RRRRR
RRRRR
RRRRR

output:

YES
5 5 5 3
5 3 5 2
5 2 5 1
5 1 5 4
5 4 4 4
4 4 4 3
4 3 4 2
4 2 4 1
4 1 4 5
4 5 3 5
3 5 3 3
3 3 3 2
3 2 3 1
3 1 3 4
3 4 2 4
2 4 2 3
2 3 2 2
2 2 2 1
2 1 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: 3700kb

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 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 17 16
17 16 16 16
16 16 16 15
16 15 16 14
16 14 16 13
16 13 16 12
16 12 16 11
16 11 16 10
16 10 16 9
16 9 16 8
16 8 16 7
16 7 16...

result:

ok 

Test #131:

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

input:

100 R
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

output:

YES
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 100 80
100 80 100 79
100 79 100 78
10...

result:

ok 

Test #132:

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

input:

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

output:

YES

result:

ok 

Test #133:

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

input:

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

output:

NO

result:

ok 

Test #134:

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

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
66 73 66 71
66 71 66 60
80 93 80 66
96 95 96 72
96 72 96 54
96 54 96 85
96 85 91 85
91 85 91 67
98 32 98 18
98 18 98 13
98 13 98 3
98 3 98 1
98 1 98 94
98 94 89 94
89 94 88 94
88 94 88 82
90 98 90 90
92 97 92 89
99 99 99 100
99 100 100 100
100 100 100 83
100 83 100 75
100 75 100 63
100 63 100 60...

result:

ok 

Test #135:

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

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
94 99 94 97
97 86 97 81
99 98 99 97
99 97 99 89
99 89 99 87
99 87 99 85
99 85 99 83
99 83 99 80
99 80 99 78
99 78 99 75
99 75 99 73
100 92 100 76
100 76 100 70
100 70 100 58
100 58 100 51
100 51 100 39
100 39 100 37
100 37 100 32
100 32 100 28
100 28 100 26
100 26 100 24
100 24 100 14
100 14 100...

result:

ok 

Test #136:

score: 0
Accepted
time: 10ms
memory: 5108kb

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
96 99 96 98
99 100 99 92
99 92 99 89
99 89 99 82
99 82 99 78
99 78 99 77
100 95 100 94
100 94 100 83
100 83 100 81
100 81 100 76
100 76 100 75
100 75 100 71
100 71 100 66
100 66 100 65
100 65 100 63
100 63 100 62
100 62 100 59
100 59 100 58
100 58 100 54
100 54 100 51
100 51 100 45
100 45 100 43...

result:

ok 

Test #137:

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

input:

3 B
B..
B..
..B

output:

NO

result:

ok 

Test #138:

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

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

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

input:

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

output:

YES
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 100 80
100 80 100 79
100 79 100 78
10...

result:

ok 

Test #141:

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

input:

3 R
R.R
.R.
R.R

output:

NO

result:

ok 

Test #142:

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

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

input:

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

output:

NO

result:

ok 

Test #144:

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

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 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 29 27
29 27 28 27
28 27 28 25
28 25 28 23
28 23 28 21
28 21 28 1...

result:

ok 

Test #145:

score: 0
Accepted
time: 26ms
memory: 9576kb

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 98 100 97
100 97 100 95
100 95 100 94
100 94 100 93
100 93 100 91
100 91 100 90
100 90 100 89
100 89 100 87
100 87 100 86
100 86 100 85
100 85 100 83
100 83 100 82
100 82 100 81
100 81 100 79
100 79 100 78
100 78 100 77
100 77 100 75
100 75 100 74
100 74 100 73
100 73 100 71
100 7...

result:

ok 

Test #146:

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

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

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

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