1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;

    vector<vector<char>> target(n, vector<char>(m));
    vector<int> row_color_count(n, 0);
    vector<int> col_color_count(m, 0);

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            cin >> target[i][j];
            if (target[i][j] != '.') {
                ++row_color_count[i];
                ++col_color_count[j];
            }
        }
    }

    // Wykonanie ruchów
    vector<string> moves;
    for (int i = 0; i < n; ++i) {
        if (row_color_count[i] > 0) {
            moves.push_back("R " + to_string(i + 1) + " " + target[i][0]);
        }
    }
    for (int j = 0; j < m; ++j) {
        if (col_color_count[j] > 0) {
            moves.push_back("K " + to_string(j + 1) + " " + target[0][j]);
        }
    }

    cout << moves.size() << endl;
    for (const string& move : moves) {
        cout << move << endl;
    }

    return 0;
}