QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#168173#2477. ExcavationLaStataleBlue#AC ✓327ms25320kbC++202.9kb2023-09-07 22:53:082023-09-07 22:53:08

Judging History

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

  • [2023-09-07 22:53:08]
  • 评测
  • 测评结果:AC
  • 用时:327ms
  • 内存:25320kb
  • [2023-09-07 22:53:08]
  • 提交

answer

#pragma ide diagnostic ignored "misc-no-recursion"

#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
typedef double db;

#define TESTCASE 0

static constexpr int MOD = 998'244'353;
static constexpr int INF = 1e9;


static void solve([[maybe_unused]] int tc) {
    int N;
    char E;
    cin >> N >> E;

    vector<string> grid(N);
    for (int i = 0; i < N; i++) {
        cin >> grid[i];
    }

    vector<int> pieces;
    vector<vector<int>> graph(N * N);
    for (int i0 = 0; i0 < N; i0++) {
        for (int j0 = 0; j0 < N; j0++) {
            if (grid[i0][j0] == '.') continue;
            pieces.push_back(i0 * N + j0);

            for (int i1 = 0; i1 < N; i1++) {
                for (int j1 = 0; j1 < N; j1++) {
                    if (grid[i1][j1] == '.') continue;
                    if (i0 == i1 && j0 == j1)  continue;

                    int di = abs(i0 - i1), dj = abs(j0 - j1);

                    if ((di == 0 || dj == 0) && (E == 'R' || E == 'Q')) {
                        graph[i1 * N + j1].push_back(i0 * N + j0);
                    }
                    if (((i0 - j0 == i1 - j1) || (i0 + j0 == i1 + j1)) && (E == 'B' || E == 'Q')) {
                        graph[i1 * N + j1].push_back(i0 * N + j0);
                    }
                    if (di <= 1 && dj <= 1 && E == 'K') {
                        graph[i1 * N + j1].push_back(i0 * N + j0);
                    }
                    if (((di == 2 && dj == 1) || (di == 1 && dj == 2)) && E == 'N') {
                        graph[i1 * N + j1].push_back(i0 * N + j0);
                    }
                }
            }
        }
    }

    shuffle(pieces.begin(), pieces.end(), mt19937(696969)); // just in case...

    vector<char> vis(N * N);
    vector<pair<int, int>> moves;
    for (int p : pieces) {
        fill(vis.begin(), vis.end(), 0);
        moves.clear();

        queue<int> Q;
        Q.push(p);
        vis[p] = 1;

        while (!Q.empty()) {
            int u = Q.front();
            Q.pop();

            for (int v : graph[u]) {
                if (vis[v]) continue;
                vis[v] = 1;
                Q.push(v);
                moves.emplace_back(u, v);
            }
        }

        if (count(vis.begin(), vis.end(), 1) == pieces.size()) {
            cout << "YES\n";

            reverse(moves.begin(), moves.end());
            for (auto [v, u] : moves) {
                cout << (u / N + 1) << ' ' << (u % N + 1) << ' ' << (v / N + 1) << ' ' << (v % N + 1) << '\n';
            }

            return;
        }

        break;
    }

    cout << "NO\n";
}

int main() {
    ios::sync_with_stdio(false);

    if (const char *f = getenv("REDIRECT_STDOUT"); f) {
        freopen(f, "w", stdout);
    }

    int T = 1;
#if TESTCASE
    cin >> T;
#endif

    for (int t = 1; t <= T; t++) {
        solve(t);
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

NO

result:

ok 

Test #2:

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

input:

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

output:

NO

result:

ok 

Test #3:

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

input:

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

output:

NO

result:

ok 

Test #4:

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

input:

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

output:

NO

result:

ok 

Test #5:

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

input:

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

output:

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

result:

ok 

Test #6:

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

input:

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

output:

NO

result:

ok 

Test #7:

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

input:

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

output:

NO

result:

ok 

Test #8:

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

input:

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

output:

NO

result:

ok 

Test #9:

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

input:

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

output:

NO

result:

ok 

Test #10:

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

input:

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

output:

NO

result:

ok 

Test #11:

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

input:

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

output:

NO

result:

ok 

Test #12:

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

input:

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

output:

NO

result:

ok 

Test #13:

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

input:

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

output:

NO

result:

ok 

Test #14:

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

input:

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

output:

NO

result:

ok 

Test #15:

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

input:

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

output:

NO

result:

ok 

Test #16:

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

input:

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

output:

NO

result:

ok 

Test #17:

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

input:

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

output:

NO

result:

ok 

Test #18:

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

input:

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

output:

NO

result:

ok 

Test #19:

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

input:

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

output:

NO

result:

ok 

Test #20:

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

input:

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

output:

NO

result:

ok 

Test #21:

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

input:

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

output:

NO

result:

ok 

Test #22:

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

input:

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

output:

NO

result:

ok 

Test #23:

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

input:

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

output:

NO

result:

ok 

Test #24:

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

input:

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

output:

NO

result:

ok 

Test #25:

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

input:

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

output:

NO

result:

ok 

Test #26:

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

input:

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

output:

NO

result:

ok 

Test #27:

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

input:

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

output:

NO

result:

ok 

Test #28:

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

input:

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

output:

NO

result:

ok 

Test #29:

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

input:

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

output:

NO

result:

ok 

Test #30:

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

input:

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

output:

NO

result:

ok 

Test #31:

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

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

input:

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

output:

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

result:

ok 

Test #33:

score: 0
Accepted
time: 1ms
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
8 8 6 6
7 7 6 6
3 3 6 6
2 2 6 6
1 1 6 6
7 9 5 7
6 8 5 7
2 4 5 7
1 3 5 7
6 10 4 8
5 9 4 8
1 5 4 8
4 10 3 9
5 5 1 9
4 6 1 9
3 7 1 9
2 8 1 9
6 6 2 10
5 7 2 10
4 8 2 10
3 9 2 10
1 9 2 10

result:

ok 

Test #34:

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

input:

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

output:

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

result:

ok 

Test #35:

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

input:

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

output:

YES
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
7 8 6 6

result:

ok 

Test #36:

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

input:

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

output:

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

result:

ok 

Test #37:

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

input:

2 K
K.
KK

output:

YES
2 1 2 2
1 1 2 2

result:

ok 

Test #38:

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

input:

1 B
B

output:

YES

result:

ok 

Test #39:

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

input:

2 B
BB
BB

output:

NO

result:

ok 

Test #40:

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

input:

3 B
BBB
BBB
BBB

output:

NO

result:

ok 

Test #41:

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

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

input:

100 B
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB...

output:

NO

result:

ok 

Test #44:

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

input:

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

output:

YES

result:

ok 

Test #45:

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

input:

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

output:

NO

result:

ok 

Test #46:

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

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

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

input:

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

output:

NO

result:

ok 

Test #49:

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

input:

3 B
BBB
B.B
BBB

output:

NO

result:

ok 

Test #50:

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

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

input:

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

output:

NO

result:

ok 

Test #52:

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

input:

3 B
B.B
.B.
B.B

output:

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

result:

ok 

Test #53:

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

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

result:

ok 

Test #54:

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

input:

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

output:

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

result:

ok 

Test #55:

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

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

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

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

result:

ok 

Test #58:

score: 0
Accepted
time: 105ms
memory: 8132kb

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 76 79 97
100 78 79 57
99 77 79 57
100 74 78 96
99 75 78 96
98 76 78 96
100 80 78 58
99 79 78 58
98 78 78 58
97 77 78 58
100 72 77 95
99 73 77 95
98 74 77 95
97 75 77 95
96 76 77 95
100 82 77 59
99 81 77 59
98 80 77 59
97 79 77 59
96 78 77 59
95 77 77 59
100 70 76 94
99 71 76 94
98 72 76 94
9...

result:

ok 

Test #59:

score: 0
Accepted
time: 106ms
memory: 7952kb

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 77 79 98
100 79 79 58
99 78 79 58
100 75 78 97
99 76 78 97
98 77 78 97
100 81 78 59
99 80 78 59
98 79 78 59
97 78 78 59
100 73 77 96
99 74 77 96
98 75 77 96
97 76 77 96
96 77 77 96
100 83 77 60
99 82 77 60
98 81 77 60
97 80 77 60
96 79 77 60
95 78 77 60
18 1 77 60
100 71 76 95
99 72 76 95
98...

result:

ok 

Test #60:

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

input:

1 K
K

output:

YES

result:

ok 

Test #61:

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

input:

2 K
KK
KK

output:

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

result:

ok 

Test #62:

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

input:

3 K
KKK
KKK
KKK

output:

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

result:

ok 

Test #63:

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

input:

5 K
KKKKK
KKKKK
KKKKK
KKKKK
KKKKK

output:

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

result:

ok 

Test #64:

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

input:

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

output:

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

result:

ok 

Test #65:

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

input:

100 K
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK...

output:

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

result:

ok 

Test #66:

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

input:

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

output:

YES

result:

ok 

Test #67:

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

input:

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

output:

NO

result:

ok 

Test #68:

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

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

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

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

input:

3 K
KKK
K.K
KKK

output:

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

result:

ok 

Test #72:

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

input:

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

output:

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

result:

ok 

Test #73:

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

input:

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

output:

YES
100 45 100 44
100 46 100 47
100 44 100 43
100 47 100 48
100 43 100 42
100 48 100 49
100 42 100 41
100 49 100 50
100 41 100 40
100 50 100 51
100 40 100 39
100 51 100 52
100 39 100 38
100 52 100 53
100 38 100 37
100 53 100 54
100 37 100 36
100 54 100 55
100 36 100 35
100 55 100 56
100 35 100 34
10...

result:

ok 

Test #74:

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

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

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

result:

ok 

Test #76:

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

input:

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

output:

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

result:

ok 

Test #77:

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

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

result:

ok 

Test #78:

score: 0
Accepted
time: 114ms
memory: 3888kb

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

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

result:

ok 

Test #80:

score: 0
Accepted
time: 105ms
memory: 3944kb

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
99 1 98 2
97 1 96 2
95 1 94 2
93 1 92 2
91 1 90 2
89 1 88 2
87 1 86 2
85 1 84 2
83 1 82 2
81 1 80 2
79 1 78 2
77 1 76 2
75 1 74 2
73 1 72 2
71 1 70 2
69 1 68 2
67 1 66 2
65 1 64 2
63 1 62 2
61 1 60 2
59 1 58 2
57 1 56 2
55 1 54 2
53 1 52 2
51 1 50 2
49 1 48 2
47 1 46 2
45 1 44 2
43 1 42 2
41 1 4...

result:

ok 

Test #81:

score: 0
Accepted
time: 97ms
memory: 3920kb

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
98 1 97 2
96 1 95 2
94 1 93 2
92 1 91 2
90 1 89 2
88 1 87 2
86 1 85 2
84 1 83 2
82 1 81 2
80 1 79 2
78 1 77 2
76 1 75 2
74 1 73 2
72 1 71 2
70 1 69 2
68 1 67 2
66 1 65 2
64 1 63 2
62 1 61 2
60 1 59 2
58 1 57 2
56 1 55 2
54 1 53 2
52 1 51 2
50 1 49 2
48 1 47 2
46 1 45 2
44 1 43 2
42 1 ...

result:

ok 

Test #82:

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

input:

1 N
N

output:

YES

result:

ok 

Test #83:

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

input:

2 N
NN
NN

output:

NO

result:

ok 

Test #84:

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

input:

3 N
NNN
NNN
NNN

output:

NO

result:

ok 

Test #85:

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

input:

5 N
NNNNN
NNNNN
NNNNN
NNNNN
NNNNN

output:

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

result:

ok 

Test #86:

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

input:

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

output:

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

result:

ok 

Test #87:

score: 0
Accepted
time: 304ms
memory: 4532kb

input:

100 N
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

output:

YES
100 100 98 99
100 99 98 98
99 100 97 99
100 97 98 96
99 98 97 97
98 99 96 98
97 100 95 99
100 98 98 97
99 99 97 98
98 100 96 99
100 96 98 95
99 97 97 96
98 98 96 97
97 99 95 98
96 100 94 99
100 94 98 93
99 95 97 94
98 96 96 95
97 97 95 96
96 98 94 97
95 99 93 98
94 100 92 99
100 95 98 94
99 96 9...

result:

ok 

Test #88:

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

input:

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

output:

YES

result:

ok 

Test #89:

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

input:

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

output:

NO

result:

ok 

Test #90:

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

input:

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

output:

NO

result:

ok 

Test #91:

score: 0
Accepted
time: 32ms
memory: 3716kb

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

input:

3 N
NNN
N.N
NNN

output:

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

result:

ok 

Test #94:

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

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

input:

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

output:

NO

result:

ok 

Test #96:

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

input:

3 N
N.N
.N.
N.N

output:

NO

result:

ok 

Test #97:

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

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

input:

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

output:

NO

result:

ok 

Test #99:

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

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
8 27 7 25
8 23 7 21
8 19 7 17
8 15 7 13
8 11 7 9
8 7 7 5
8 3 7 1
9 29 10 27
9 25 10 23
9 21 10 19
9 17 10 15
9 13 10 11
9 9 10 7
9 5 10 3
9 1 10 3
7 29 6 27
7 25 6 23
7 21 6 19
7 17 6 15
7 13 6 11
7 9 6 7
7 5 6 3
7 1 6 3
10 27 11 25
10 23 11 21
10 19 11 17
10 15 11 13
10 11 11 9
10 7 11 5
10 3 1...

result:

ok 

Test #100:

score: 0
Accepted
time: 99ms
memory: 3892kb

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
42 99 41 97
42 95 41 93
42 91 41 89
42 87 41 85
42 83 41 81
42 79 41 77
42 75 41 73
42 71 41 69
42 67 41 65
42 63 41 61
42 59 41 57
42 55 41 53
42 51 41 49
42 47 41 45
42 43 41 41
42 39 41 37
42 35 41 33
42 31 41 29
42 27 41 25
42 23 41 21
42 19 41 17
42 15 41 13
42 11 41 9
42 7 41 5
42 3 41 1
4...

result:

ok 

Test #101:

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

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

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

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

input:

1 Q
Q

output:

YES

result:

ok 

Test #105:

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

input:

2 Q
QQ
QQ

output:

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

result:

ok 

Test #106:

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

input:

3 Q
QQQ
QQQ
QQQ

output:

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

result:

ok 

Test #107:

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

input:

5 Q
QQQQQ
QQQQQ
QQQQQ
QQQQQ
QQQQQ

output:

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

result:

ok 

Test #108:

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

input:

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

output:

YES
17 15 13 15
16 15 13 15
17 13 13 13
16 13 13 13
17 16 12 16
15 16 12 16
17 12 12 12
15 12 12 12
16 17 11 17
15 17 11 17
13 16 11 14
13 12 11 14
12 15 11 14
12 13 11 14
16 11 11 11
15 11 11 11
13 17 10 14
13 11 10 14
11 15 10 14
11 13 10 14
17 10 10 10
16 10 10 10
15 10 10 10
13 10 9 14
12 17 9 1...

result:

ok 

Test #109:

score: 0
Accepted
time: 296ms
memory: 25320kb

input:

100 Q
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ
QQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQQ...

output:

YES
31 100 30 99
32 100 30 98
31 99 30 98
34 100 30 96
33 99 30 96
32 98 30 96
31 97 30 96
36 100 30 94
35 99 30 94
34 98 30 94
33 97 30 94
32 96 30 94
31 95 30 94
38 100 30 92
37 99 30 92
36 98 30 92
35 97 30 92
34 96 30 92
33 95 30 92
32 94 30 92
31 93 30 92
40 100 30 90
39 99 30 90
38 98 30 90
37...

result:

ok 

Test #110:

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

input:

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

output:

YES

result:

ok 

Test #111:

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

input:

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

output:

NO

result:

ok 

Test #112:

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

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
98 41 98 64
98 21 98 64
100 45 86 59
61 79 81 59
95 33 64 2
90 80 28 80
3 84 3 59
100 41 88 53
96 45 88 53
67 74 88 53
99 41 59 1
59 79 59 1
98 56 10 56
38 56 10 56
100 49 97 52
71 16 71 52
67 56 71 52
94 27 69 52
95 87 60 52
50 100 55 100
38 100 55 100
3 100 55 100
96 11 48 11
87 56 45 14
89 78...

result:

ok 

Test #113:

score: 0
Accepted
time: 38ms
memory: 4588kb

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
85 4 85 95
88 69 59 69
67 69 59 69
42 69 59 69
96 28 57 67
88 30 20 30
10 53 10 6
4 25 4 13
58 49 97 10
100 17 93 10
55 38 83 10
67 98 79 86
85 25 70 10
100 51 59 10
82 35 57 10
55 8 57 10
85 58 37 10
100 43 36 43
10 34 34 10
17 46 17 10
92 64 92 91
92 46 92 91
92 8 92 91
50 95 73 72
72 46 72 2
...

result:

ok 

Test #114:

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

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
100 51 100 9
57 74 19 36
80 78 19 17
11 45 11 17
83 63 83 21
48 87 16 87
99 45 99 2
95 63 95 2
95 28 95 2
69 28 95 2
94 45 94 2
95 4 93 2
89 87 89 2
89 28 89 2
5 37 40 2
66 51 17 2
57 4 12 49
51 87 12 48
77 78 12 13
27 28 12 13
11 35 59 35
100 38 56 38
63 45 56 38
90 41 53 41
52 41 53 41
20 41 5...

result:

ok 

Test #115:

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

input:

3 Q
QQQ
Q.Q
QQQ

output:

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

result:

ok 

Test #116:

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

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

result:

ok 

Test #117:

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

input:

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

output:

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

result:

ok 

Test #118:

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

input:

3 Q
Q.Q
.Q.
Q.Q

output:

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

result:

ok 

Test #119:

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

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

result:

ok 

Test #120:

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

input:

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

output:

YES
89 11 10 90
88 12 10 90
87 13 10 90
86 14 10 90
85 15 10 90
84 16 10 90
83 17 10 90
82 18 10 90
81 19 10 90
80 20 10 90
79 21 10 90
78 22 10 90
77 23 10 90
76 24 10 90
75 25 10 90
74 26 10 90
73 27 10 90
72 28 10 90
71 29 10 90
70 30 10 90
69 31 10 90
68 32 10 90
67 33 10 90
66 34 10 90
65 35 10...

result:

ok 

Test #121:

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

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 26 22 19
29 22 22 15
29 18 22 11
29 23 20 23
28 23 20 23
27 23 20 23
26 23 20 23
25 23 20 23
23 23 20 23
29 19 20 19
28 19 20 19
27 19 20 19
26 19 20 19
25 19 20 19
23 19 20 19
21 23 19 21
21 19 19 21
29 25 18 25
28 25 18 25
27 25 18 25
25 25 18 25
24 25 18 25
23 25 18 25
29 10 18 21
29 17 18...

result:

ok 

Test #122:

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

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
72 99 59 99
70 99 59 99
68 99 59 99
66 99 59 99
64 99 59 99
62 99 59 99
60 99 59 99
70 97 59 97
68 97 59 97
66 97 59 97
64 97 59 97
62 97 59 97
61 99 59 97
60 97 59 97
68 95 59 95
66 95 59 95
64 95 59 95
62 95 59 95
60 95 59 95
66 93 59 93
65 99 59 93
64 93 59 93
63 97 59 93
62 93 59 93
61 95 59...

result:

ok 

Test #123:

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

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 15 21 15
29 15 21 15
27 15 21 15
25 15 21 15
31 13 21 13
29 13 21 13
27 13 21 13
25 13 21 13
30 16 20 16
28 16 20 16
26 16 20 16
30 12 20 12
28 12 20 12
26 12 20 12
31 17 19 17
29 17 19 17
27 17 19 17
23 17 19 17
31 11 19 11
29 11 19 11
27 11 19 11
23 11 19 11
30 18 18 18
28 18 18 18
24 18 18...

result:

ok 

Test #124:

score: 0
Accepted
time: 109ms
memory: 10208kb

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

result:

ok 

Test #125:

score: 0
Accepted
time: 114ms
memory: 10192kb

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

result:

ok 

Test #126:

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

input:

1 R
R

output:

YES

result:

ok 

Test #127:

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

input:

2 R
RR
RR

output:

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

result:

ok 

Test #128:

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

input:

3 R
RRR
RRR
RRR

output:

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

result:

ok 

Test #129:

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

input:

5 R
RRRRR
RRRRR
RRRRR
RRRRR
RRRRR

output:

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

result:

ok 

Test #130:

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

input:

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

output:

YES
17 17 14 17
16 17 14 17
15 17 14 17
17 16 14 16
16 16 14 16
15 16 14 16
17 15 14 15
16 15 14 15
15 15 14 15
17 13 14 13
16 13 14 13
15 13 14 13
17 12 14 12
16 12 14 12
15 12 14 12
17 11 14 11
16 11 14 11
15 11 14 11
17 10 14 10
16 10 14 10
15 10 14 10
17 9 14 9
16 9 14 9
15 9 14 9
17 8 14 8
16 8...

result:

ok 

Test #131:

score: 0
Accepted
time: 309ms
memory: 14384kb

input:

100 R
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

output:

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

result:

ok 

Test #132:

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

input:

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

output:

YES

result:

ok 

Test #133:

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

input:

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

output:

NO

result:

ok 

Test #134:

score: 0
Accepted
time: 12ms
memory: 3728kb

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
13 42 13 61
1 42 1 11
68 97 92 97
22 97 92 97
80 66 82 66
33 66 82 66
90 78 64 78
74 78 64 78
45 78 64 78
33 78 64 78
88 70 62 70
86 70 62 70
80 70 62 70
46 70 62 70
76 26 37 26
40 26 37 26
59 22 29 22
59 85 12 85
35 85 12 85
90 77 12 77
70 77 12 77
68 77 12 77
76 39 8 39
25 39 8 39
13 39 8 39
9...

result:

ok 

Test #135:

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

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
7 81 26 81
7 35 26 35
7 5 26 5
7 79 18 79
7 13 18 13
7 97 4 97
7 95 4 95
7 73 4 73
7 42 4 42
20 97 20 92
20 96 20 92
20 76 20 92
20 74 20 92
20 61 20 92
20 50 20 92
20 42 20 92
20 31 20 92
20 21 20 92
20 19 20 92
20 2 20 92
51 94 51 91
51 87 51 91
51 77 51 91
51 76 51 91
51 69 51 91
51 38 51 91
...

result:

ok 

Test #136:

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

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
93 88 33 88
92 88 33 88
89 88 33 88
86 88 33 88
78 88 33 88
75 88 33 88
71 88 33 88
64 88 33 88
61 88 33 88
59 88 33 88
38 88 33 88
37 88 33 88
32 88 33 88
30 88 33 88
25 88 33 88
18 88 33 88
15 88 33 88
10 88 33 88
7 88 33 88
93 1 31 1
92 1 31 1
88 1 31 1
85 1 31 1
78 1 31 1
67 1 31 1
64 1 31 1...

result:

ok 

Test #137:

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

input:

3 B
B..
B..
..B

output:

NO

result:

ok 

Test #138:

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

input:

3 R
RRR
R.R
RRR

output:

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

result:

ok 

Test #139:

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

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

result:

ok 

Test #140:

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

input:

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

output:

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

result:

ok 

Test #141:

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

input:

3 R
R.R
.R.
R.R

output:

NO

result:

ok 

Test #142:

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

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

input:

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

output:

NO

result:

ok 

Test #144:

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

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 26 29 21
29 22 29 21
29 18 29 21
29 14 29 21
29 10 29 21
29 6 29 21
29 2 29 21
29 29 22 29
28 29 22 29
27 29 22 29
26 29 22 29
25 29 22 29
24 29 22 29
23 29 22 29
29 27 22 27
28 27 22 27
27 27 22 27
26 27 22 27
25 27 22 27
24 27 22 27
23 27 22 27
29 25 22 25
28 25 22 25
27 25 22 25
26 25 22 2...

result:

ok 

Test #145:

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

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
100 98 100 27
100 94 100 27
100 90 100 27
100 86 100 27
100 82 100 27
100 78 100 27
100 74 100 27
100 70 100 27
100 66 100 27
100 62 100 27
100 58 100 27
100 54 100 27
100 50 100 27
100 46 100 27
100 42 100 27
100 38 100 27
100 34 100 27
100 30 100 27
100 26 100 27
100 22 100 27
100 18 100 27
10...

result:

ok 

Test #146:

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

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

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

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