#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1005;

char w[MAXN][MAXN];
int color[MAXN][MAXN], cycle_color[MAXN][MAXN], len[MAXN][MAXN];
int isCycle[MAXN][MAXN], color1[MAXN][MAXN], dist[MAXN][MAXN];
int who[MAXN][MAXN];

vector<int> ans, sz;

pair<int, int> _move(char c) {
    if (c == 'n' || c == 'N')
        return {-1, 0};
    else if (c == 's' || c == 'S')
        return {1, 0};
    else if (c == 'e' || c == 'E')
        return {0, 1};
    return {0, -1};
}
int cycle;

void dfs1(int x, int y, int numb = 0) {
    if (color1[x][y])
        return;
    color1[x][y] = 1;
    isCycle[x][y] = ++numb;
    pair<int, int> dt = _move(w[x][y]);
    int dx = dt.first + x, dy = dt.second + y;
    dfs1(dx, dy, numb);
}

int cycleDist(int x, int y) {
    if (isCycle[x][y]) {
        who[x][y] = isCycle[x][y];
        return 0;
    }
    if (color[x][y])
        return dist[x][y];
    color[x][y] = 1;
    pair<int, int> dt = _move(w[x][y]);
    int dx = x + dt.first, dy = y + dt.second;
    dist[x][y] = 1 + cycleDist(dx, dy);
    who[x][y] = who[dx][dy];
    return dist[x][y];
}

int dfs(int x, int y, int Len = 1) {
    if (color[x][y]) {
        if (cycle_color[x][y])
            return len[x][y];
        cycle_color[x][y] = ++cycle;
        len[x][y] *= -1;
        len[x][y] += Len;
        ans.push_back(len[x][y]);
        dfs1(x, y);
        return len[x][y];
    }
    color[x][y] = 1;
    len[x][y] = Len++;
    pair<int, int> dt = _move(w[x][y]);
    int dx = x + dt.first, dy = y + dt.second;
    dfs(dx, dy, Len);
    cycle_color[x][y] = cycle_color[dx][dy];
    len[x][y] = len[dx][dy];
    return len[x][y];
}

int main () {
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    ans.reserve(1e6);
    int n, m, g;
    cin >> n >> m >> g;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        for (int j = 0; j < m; ++j)
            w[i][j] = s[j];
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (!color[i][j])
                dfs(i, j);
        }
    }
    sz.resize(ans.size());
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            if (w[i][j] >= 'A' && w[i][j] <= 'Z')
                sz[cycle_color[i][j] - 1]++;
    int res = 0;
    for (int i = 0; i < ans.size(); ++i)
        res += min(ans[i], sz[i]);
    cout << res << endl;
    if (g == 0)
        return 0;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            color[i][j] = 0;

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j)
            if (!color[i][j])
                cycleDist(i, j);

    vector<pair<pair<int, int>, int> > ans_t;
    vector<int> cur_sz(sz.size()), last_t(sz.size(), 0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (w[i][j] >= 'A' && w[i][j] <= 'Z' && cur_sz[cycle_color[i][j] - 1] < len[i][j]) {
                int dt1 = 0;
                if (who[i][j] - 1 < cur_sz[cycle_color[i][j] - 1]) {
                    dt1 = cur_sz[cycle_color[i][j] - 1] - who[i][j] + 1;
                }
                else if (who[i][j] - 1 > cur_sz[cycle_color[i][j] - 1]) {
                    dt1 = len[i][j] + (cur_sz[cycle_color[i][j] - 1] - who[i][j] + 1);
                }
                int T = dt1 + dist[i][j], dt2 = 0;
                dt2 = (((-T) % len[i][j]) + len[i][j]) % len[i][j];
                ans_t.push_back({{i, j}, dt2 + len[i][j] * cur_sz[cycle_color[i][j] - 1]});
                cur_sz[cycle_color[i][j] - 1]++;
            }
        }
    }
    for (int i = 0; i < ans_t.size(); ++i) {
        cout << ans_t[i].first.first + 1 << ' ' << ans_t[i].first.second + 1 << ' ' << ans_t[i].second + 1 << endl;
    }

    return 0;
}
