#include <bits/stdc++.h>

using namespace std;

int n, m, g;
string s[1000];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
char d1[4] = {'n', 'w', 's', 'e'};
char d2[4] = {'N', 'W', 'S', 'E'};
int cyc[1000][1000];
int cnt[1000][1000];
int sz[1000][1000];
int dist[1000][1000];
int used[1000][1000];
vector<pair<pair<int, int>, int> > ans;

void cntdist(int x, int y, int r) {
    int a = r / m;
    int b = r % m;
    int xx = x;
    int yy = y;
    for (int i = 0; i < 4; i++) {
        if (d1[i] == s[x][y]) {
            xx += dx[i];
            yy += dy[i];
        }
    }
    for (int i = 0; i < 4; i++) {
        if (d2[i] == s[x][y]) {
            xx += dx[i];
            yy += dy[i];
        }
    }
    if (xx == a && yy == b) {
        dist[x][y] = 1;
        return;
    }
    if (dist[xx][yy] != -1) {
        dist[x][y] = dist[xx][yy] + 1;
        return;
    }
    cntdist(xx, yy, r);
    dist[x][y] = dist[xx][yy] + 1;
    return;
}

void cntsz(int x, int y, int r) {
    int a = r / m;
    int b = r % m;
    sz[a][b]++;
    int xx = x;
    int yy = y;
    for (int i = 0; i < 4; i++) {
        if (d1[i] == s[x][y]) {
            xx += dx[i];
            yy += dy[i];
        }
    }
    for (int i = 0; i < 4; i++) {
        if (d2[i] == s[x][y]) {
            xx += dx[i];
            yy += dy[i];
        }
    }
    if (a == xx && b == yy) {
        return;
    }
    cntsz(xx, yy, r);
}

int dfs(int x, int y) {
    used[x][y] = 1;
    if (cyc[x][y] != -1) {
        return cyc[x][y];
    }
    int xx = x;
    int yy = y;
    for (int i = 0; i < 4; i++) {
        if (d1[i] == s[x][y]) {
            xx += dx[i];
            yy += dy[i];
        }
    }
    for (int i = 0; i < 4; i++) {
        if (d2[i] == s[x][y]) {
            xx += dx[i];
            yy += dy[i];
        }
    }
    if (cyc[xx][yy] == -1 && used[xx][yy] == 1) {
        cntsz(xx, yy, m * xx + yy);
        return cyc[x][y] = m * xx + yy;
    }
    return cyc[x][y] = dfs(xx, yy);
}


int main() {
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    iostream::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> g;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        for (int j = 0; j < m; j++) {
            cyc[i][j] = -1;
            dist[i][j] = -1;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j] >= 'A' && s[i][j] <= 'Z') {
                if (cyc[i][j] == -1) {
                    dfs(i, j);
                }
                int x = cyc[i][j] / m;
                int y = cyc[i][j] % m;
                if (cnt[x][y] == sz[x][y]) {
                    continue;
                } else {
                    if (x == i && y == j) {
                        dist[i][j] = 0;
                    }
                    if (dist[i][j] == -1) {
                        cntdist(i, j, cyc[i][j]);
                    }
                    int t = (cnt[x][y] - dist[i][j] + 1 + sz[x][y]) % sz[x][y];
                    if (t < 0) {
                        t += sz[x][y];
                    }
                    ans.push_back({{i + 1, j + 1}, t + 1});
                    cnt[x][y]++;
                }
            }
        }
    }
    cout << ans.size() << "\n";
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i].first.first << " " << ans[i].first.second << " " << ans[i].second << "\n";
    }
}
