QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#202797#2477. ExcavationBoulevardDust#AC ✓219ms31824kbC++201.8kb2023-10-06 13:29:322023-10-06 13:29:32

Judging History

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

  • [2023-10-06 13:29:32]
  • 评测
  • 测评结果:AC
  • 用时:219ms
  • 内存:31824kb
  • [2023-10-06 13:29:32]
  • 提交

answer

#include <iostream>
#include <cstdio>
#define mn 15005

using namespace std;


int n, cnt, h[mn], d[mn], vis[mn];
char c, a[105][105];


struct E {
	int to, nxt;
}e[100000005];

int get(int x, int y) {
	return (x - 1) * n + y;
}
int find(int x) {
	return x == d[x] ? x : d[x] = find(d[x]);
}
void add(int u, int v) {
	e[++cnt] = (E){v, h[u]}, h[u] = cnt;
	d[find(u)] = find(v);
}

void link(int x, int y) {
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			if(i == x && j == y) continue;
			if(a[i][j] == '.') continue;
			int f = 0;
			if(c == 'R' && (i == x || j == y)) f = 1;
			if(c == 'Q' && (i == x || j == y || i - j == x - y || i + j == x + y)) f = 1;
			if(c == 'B' && (i - j == x - y || i + j == x + y)) f = 1;
			if(c == 'N' && ((abs(i - x) == 2 && abs(j - y) == 1) || (abs(i - x) == 1 && abs(j - y) == 2))) f = 1;
			if(c == 'K' && (abs(i - x) <= 1 && abs(j - y) <= 1)) f = 1;
			if(f) add(get(x, y), get(i, j));
		}
	}
}
void print(int x, int y) {
	printf("%d %d %d %d\n", (x - 1) / n + 1, (x - 1) % n + 1, (y - 1) / n + 1, (y - 1) % n + 1);
}
void dfs(int u) {
	vis[u] = 1;
	for(int i = h[u]; i; i = e[i].nxt) {
		int v = e[i].to;
		if(vis[v]) continue;
		dfs(v);
		print(v, u);
	}
}

int main() {
	scanf("%d %c\n", &n, &c);
	for(int i = 1; i <= n; ++i) {
		scanf("%s", a[i] + 1);
	}
	for(int i = 1; i <= n * n; ++i) {
		d[i] = i;
	}
	// RQBNK
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			if(a[i][j] != '.') {
				link(i, j);
			}
		}
	}
	int s = 0, r;
	for(int i = 1; i <= n; ++i) {
		for(int j = 1; j <= n; ++j) {
			if(a[i][j] == '.') continue;
			int x = get(i, j);
			if(d[x] == x) ++s, r = x;
		}
	}
	if(s != 1) {
		return puts("NO"), 0;
	}
	puts("YES");
	dfs(r);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

NO

result:

ok 

Test #2:

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

input:

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

output:

NO

result:

ok 

Test #3:

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

input:

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

output:

NO

result:

ok 

Test #4:

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

input:

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

output:

NO

result:

ok 

Test #5:

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

input:

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

output:

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

result:

ok 

Test #6:

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

input:

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

output:

NO

result:

ok 

Test #7:

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

input:

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

output:

NO

result:

ok 

Test #8:

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

input:

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

output:

NO

result:

ok 

Test #9:

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

input:

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

output:

NO

result:

ok 

Test #10:

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

input:

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

output:

NO

result:

ok 

Test #11:

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

input:

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

output:

NO

result:

ok 

Test #12:

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

input:

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

output:

NO

result:

ok 

Test #13:

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

input:

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

output:

NO

result:

ok 

Test #14:

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

input:

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

output:

NO

result:

ok 

Test #15:

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

input:

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

output:

NO

result:

ok 

Test #16:

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

input:

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

output:

NO

result:

ok 

Test #17:

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

input:

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

output:

NO

result:

ok 

Test #18:

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

input:

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

output:

NO

result:

ok 

Test #19:

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

input:

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

output:

NO

result:

ok 

Test #20:

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

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

input:

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

output:

NO

result:

ok 

Test #22:

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

input:

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

output:

NO

result:

ok 

Test #23:

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

input:

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

output:

NO

result:

ok 

Test #24:

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

input:

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

output:

NO

result:

ok 

Test #25:

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

input:

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

output:

NO

result:

ok 

Test #26:

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

input:

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

output:

NO

result:

ok 

Test #27:

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

input:

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

output:

NO

result:

ok 

Test #28:

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

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

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

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

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

input:

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

output:

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

result:

ok 

Test #33:

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

input:

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

output:

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

result:

ok 

Test #34:

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

input:

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

output:

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

result:

ok 

Test #35:

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

input:

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

output:

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

result:

ok 

Test #36:

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

input:

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

output:

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

result:

ok 

Test #37:

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

input:

2 K
K.
KK

output:

YES
1 1 2 1
2 1 2 2

result:

ok 

Test #38:

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

input:

1 B
B

output:

YES

result:

ok 

Test #39:

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

input:

2 B
BB
BB

output:

NO

result:

ok 

Test #40:

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

input:

3 B
BBB
BBB
BBB

output:

NO

result:

ok 

Test #41:

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

input:

5 B
BBBBB
BBBBB
BBBBB
BBBBB
BBBBB

output:

NO

result:

ok 

Test #42:

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

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

input:

100 B
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

NO

result:

ok 

Test #44:

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

input:

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

output:

YES

result:

ok 

Test #45:

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

input:

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

output:

NO

result:

ok 

Test #46:

score: 0
Accepted
time: 18ms
memory: 3992kb

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

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

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

input:

3 B
BBB
B.B
BBB

output:

NO

result:

ok 

Test #50:

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

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

input:

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

output:

NO

result:

ok 

Test #52:

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

input:

3 B
B.B
.B.
B.B

output:

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

result:

ok 

Test #53:

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

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

result:

ok 

Test #54:

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

input:

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

output:

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

result:

ok 

Test #55:

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

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

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

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

result:

ok 

Test #58:

score: 0
Accepted
time: 79ms
memory: 10352kb

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

result:

ok 

Test #59:

score: 0
Accepted
time: 83ms
memory: 9928kb

input:

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

output:

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

result:

ok 

Test #60:

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

input:

1 K
K

output:

YES

result:

ok 

Test #61:

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

input:

2 K
KK
KK

output:

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

result:

ok 

Test #62:

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

input:

3 K
KKK
KKK
KKK

output:

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

result:

ok 

Test #63:

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

input:

5 K
KKKKK
KKKKK
KKKKK
KKKKK
KKKKK

output:

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

result:

ok 

Test #64:

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

input:

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

output:

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

result:

ok 

Test #65:

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

input:

100 K
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK...

output:

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

result:

ok 

Test #66:

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

input:

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

output:

YES

result:

ok 

Test #67:

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

input:

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

output:

NO

result:

ok 

Test #68:

score: 0
Accepted
time: 22ms
memory: 3764kb

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

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

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

input:

3 K
KKK
K.K
KKK

output:

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

result:

ok 

Test #72:

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

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

result:

ok 

Test #73:

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

input:

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

output:

YES
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
100 78 100 77
100 77 100 76
10...

result:

ok 

Test #74:

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

input:

3 K
K.K
.K.
K.K

output:

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

result:

ok 

Test #75:

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

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

result:

ok 

Test #76:

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

input:

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

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 #77:

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

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
1 1 2 1
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 29 2
29 2 29 3
29 3 28 3
28 ...

result:

ok 

Test #78:

score: 0
Accepted
time: 73ms
memory: 4376kb

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 1 2 1
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 ...

result:

ok 

Test #79:

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

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
31 1 30 2
29 31 28 30
29 1 28 2
25 31 24 30
25 1 24 2
21 31 20 30
21 1 20 2
17 31 16 30
17 1 16 2
13 31 12 30
13 1 12 2
9 31 8 30
9 1 8 2
5 31 4 30
5 1 4 2
1 3 2 2
1 1 2 2
2 2 3 1
3 1 4 2
4 2 3 3
3 3 2 4
1 5 2 4
2 4 3 5
3 5 2 6
1 7 2 6
2 6 3 7
3 7 2 8
1 9 2 8
2 8 3 9
3 9 2 10
1 11 2 10
2 10 3 11...

result:

ok 

Test #80:

score: 0
Accepted
time: 71ms
memory: 4520kb

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
98 100 97 99
97 1 96 2
94 100 93 99
93 1 92 2
90 100 89 99
89 1 88 2
86 100 85 99
85 1 84 2
82 100 81 99
81 1 80 2
78 100 77 99
77 1 76 2
74 100 73 99
73 1 72 2
70 100 69 99
69 1 68 2
66 100 65 99
65 1 64 2
62 100 61 99
61 1 60 2
58 100 57 99
57 1 56 2
54 100 53 99
53 1 52 2
50 100 49 99
49 1 48...

result:

ok 

Test #81:

score: 0
Accepted
time: 74ms
memory: 4520kb

input:

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

output:

YES
100 1 99 2
97 100 96 99
98 1 97 2
93 100 92 99
94 1 93 2
89 100 88 99
90 1 89 2
85 100 84 99
86 1 85 2
81 100 80 99
82 1 81 2
77 100 76 99
78 1 77 2
73 100 72 99
74 1 73 2
69 100 68 99
70 1 69 2
65 100 64 99
66 1 65 2
61 100 60 99
62 1 61 2
57 100 56 99
58 1 57 2
53 100 52 99
54 1 53 2
49 100 48...

result:

ok 

Test #82:

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

input:

1 N
N

output:

YES

result:

ok 

Test #83:

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

input:

2 N
NN
NN

output:

NO

result:

ok 

Test #84:

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

input:

3 N
NNN
NNN
NNN

output:

NO

result:

ok 

Test #85:

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

input:

5 N
NNNNN
NNNNN
NNNNN
NNNNN
NNNNN

output:

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

result:

ok 

Test #86:

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

input:

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

output:

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

result:

ok 

Test #87:

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

input:

100 N
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

output:

YES
98 1 96 2
97 100 95 99
96 1 94 2
92 100 90 99
93 1 91 2
82 100 80 99
79 100 77 99
88 1 86 2
77 100 75 99
76 100 74 99
85 1 83 2
83 1 81 2
71 100 69 99
79 1 77 2
80 1 78 2
62 100 60 99
77 1 75 2
55 100 53 99
52 100 50 99
71 1 69 2
70 1 68 2
44 100 42 99
37 100 35 99
68 1 66 2
67 1 65 2
66 1 64 2
...

result:

ok 

Test #88:

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

input:

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

output:

YES

result:

ok 

Test #89:

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

input:

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

output:

NO

result:

ok 

Test #90:

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

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

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

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

input:

3 N
NNN
N.N
NNN

output:

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

result:

ok 

Test #94:

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

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

input:

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

output:

NO

result:

ok 

Test #96:

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

input:

3 N
N.N
.N.
N.N

output:

NO

result:

ok 

Test #97:

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

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

input:

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

output:

NO

result:

ok 

Test #99:

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

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

result:

ok 

Test #100:

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

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
97 99 96 97
96 99 95 97
93 99 92 97
92 99 91 97
89 99 88 97
88 99 87 97
85 99 84 97
84 99 83 97
81 99 80 97
80 99 79 97
77 99 76 97
76 99 75 97
73 99 72 97
72 99 71 97
69 99 68 97
68 99 67 97
65 99 64 97
64 99 63 97
61 99 60 97
60 99 59 97
57 99 56 97
56 99 55 97
53 99 52 97
49 99 48 97
94 1 93 ...

result:

ok 

Test #101:

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

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

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

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

input:

1 Q
Q

output:

YES

result:

ok 

Test #105:

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

input:

2 Q
QQ
QQ

output:

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

result:

ok 

Test #106:

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

input:

3 Q
QQQ
QQQ
QQQ

output:

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

result:

ok 

Test #107:

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

input:

5 Q
QQQQQ
QQQQQ
QQQQQ
QQQQQ
QQQQQ

output:

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

result:

ok 

Test #108:

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

input:

17 Q
QQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQ
QQQQQQ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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...

result:

ok 

Test #110:

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

input:

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

output:

YES

result:

ok 

Test #111:

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

input:

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

output:

NO

result:

ok 

Test #112:

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

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
5 4 5 17
5 17 5 46
4 23 4 28
3 12 3 18
3 18 3 58
3 58 3 59
2 6 2 10
2 10 2 34
2 34 2 54
2 54 2 69
2 69 2 72
2 72 2 81
2 81 2 84
2 84 2 76
2 76 1 77
1 1 1 77
1 77 1 61
1 61 3 59
3 59 3 61
3 61 3 69
3 69 3 78
3 78 3 82
3 82 3 84
3 84 3 100
3 100 3 26
3 26 2 26
2 26 4 28
4 28 4 34
4 34 4 37
4 37 4 ...

result:

ok 

Test #113:

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

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
3 2 3 10
3 10 3 22
3 22 3 31
2 6 2 7
2 7 2 8
2 8 2 12
2 12 2 20
1 14 1 15
1 15 1 18
1 18 1 23
1 23 1 29
1 29 1 31
1 31 1 39
1 39 1 45
1 45 1 48
1 48 1 55
1 55 1 59
1 59 1 60
1 60 1 67
1 67 1 75
1 75 1 77
1 77 1 78
1 78 1 79
1 79 1 85
1 85 1 90
1 90 1 97
1 97 1 19
1 19 2 20
2 20 2 38
2 38 2 44
2 ...

result:

ok 

Test #114:

score: 0
Accepted
time: 125ms
memory: 8520kb

input:

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

output:

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

result:

ok 

Test #115:

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

input:

3 Q
QQQ
Q.Q
QQQ

output:

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

result:

ok 

Test #116:

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

input:

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

output:

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

result:

ok 

Test #117:

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

input:

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

output:

YES
1 1 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...

result:

ok 

Test #118:

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

input:

3 Q
Q.Q
.Q.
Q.Q

output:

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

result:

ok 

Test #119:

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

input:

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

output:

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

result:

ok 

Test #120:

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

input:

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

output:

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

result:

ok 

Test #121:

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

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
1 1 1 3
1 3 1 5
1 5 1 7
1 7 1 8
1 8 1 9
1 9 1 11
1 11 1 12
1 12 1 13
1 13 1 15
1 15 1 16
1 16 1 17
1 17 1 19
1 19 1 20
1 20 1 21
1 21 1 23
1 23 1 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...

result:

ok 

Test #126:

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

input:

1 R
R

output:

YES

result:

ok 

Test #127:

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

input:

2 R
RR
RR

output:

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

result:

ok 

Test #128:

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

input:

3 R
RRR
RRR
RRR

output:

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

result:

ok 

Test #129:

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

input:

5 R
RRRRR
RRRRR
RRRRR
RRRRR
RRRRR

output:

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

result:

ok 

Test #130:

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

input:

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

output:

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

result:

ok 

Test #131:

score: 0
Accepted
time: 171ms
memory: 20544kb

input:

100 R
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

output:

YES
1 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...

result:

ok 

Test #132:

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

input:

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

output:

YES

result:

ok 

Test #133:

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

input:

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

output:

NO

result:

ok 

Test #134:

score: 0
Accepted
time: 20ms
memory: 4188kb

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
4 5 4 23
4 23 4 27
4 27 4 40
8 2 8 6
8 6 8 7
8 7 8 8
5 22 5 8
5 8 8 8
8 8 7 8
7 1 7 8
7 8 7 11
1 11 1 29
1 29 1 34
1 34 1 42
1 42 1 24
1 24 3 24
3 24 3 46
3 46 3 11
3 11 7 11
7 11 7 17
9 12 6 12
6 12 6 13
6 13 6 16
6 16 6 19
6 19 6 17
6 17 7 17
7 17 7 41
7 41 7 56
7 56 7 69
7 69 7 74
7 74 7 61
7...

result:

ok 

Test #135:

score: 0
Accepted
time: 57ms
memory: 4672kb

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
12 2 12 15
12 15 12 30
12 30 12 35
6 21 6 28
6 28 6 34
5 7 1 7
1 7 1 9
1 9 1 20
1 20 1 23
1 23 1 29
1 29 1 40
1 40 1 41
1 41 1 43
1 43 1 44
1 44 1 46
1 46 1 47
1 47 1 49
1 49 1 51
1 51 1 55
1 55 1 57
1 57 1 58
1 58 1 60
1 60 1 65
1 65 1 66
1 66 1 83
1 83 1 89
1 89 1 91
1 91 1 93
1 93 1 1
1 1 4 1...

result:

ok 

Test #136:

score: 0
Accepted
time: 112ms
memory: 6412kb

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
10 9 10 12
2 6 2 10
2 10 2 12
2 12 2 14
1 8 1 23
1 23 1 28
1 28 1 29
1 29 1 30
1 30 1 31
1 31 1 33
1 33 1 35
1 35 1 36
1 36 1 38
1 38 1 39
1 39 1 46
1 46 1 51
1 51 1 53
1 53 1 56
1 56 1 61
1 61 1 62
1 62 1 64
1 64 1 66
1 66 1 69
1 69 1 70
1 70 1 77
1 77 1 78
1 78 1 82
1 82 1 87
1 87 1 14
1 14 2 ...

result:

ok 

Test #137:

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

input:

3 B
B..
B..
..B

output:

NO

result:

ok 

Test #138:

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

input:

3 R
RRR
R.R
RRR

output:

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

result:

ok 

Test #139:

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

input:

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

output:

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

result:

ok 

Test #140:

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

input:

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

output:

YES
1 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...

result:

ok 

Test #141:

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

input:

3 R
R.R
.R.
R.R

output:

NO

result:

ok 

Test #142:

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

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

input:

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

output:

NO

result:

ok 

Test #144:

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

input:

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

output:

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

result:

ok 

Test #145:

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

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 3 1 4
1 4 1 5
1 5 1 7
1 7 1 8
1 8 1 9
1 9 1 11
1 11 1 12
1 12 1 13
1 13 1 15
1 15 1 16
1 16 1 17
1 17 1 19
1 19 1 20
1 20 1 21
1 21 1 23
1 23 1 24
1 24 1 25
1 25 1 27
1 27 1 28
1 28 1 29
1 29 1 31
1 31 1 32
1 32 1 33
1 33 1 35
1 35 1 36
1 36 1 37
1 37 1 39
1 39 1 40
1 40 1 41
1 41 1 43
1 43 1 ...

result:

ok 

Test #146:

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

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

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

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