#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <bitset>

using namespace std;

const int N = 1005;

char f[N][N];

bool used[N][N];
int cused[N][N];
int pre[N][N];
int res[N][N];
int robs[N][N];
int csize[N][N];
pair<int, int> beg[N][N];
vector<pair<int, int>> rbs[N][N];

pair<int, int> go(int x, int y, char c) {
    if (c == 'e' || c == 'E') ++y;
    if (c == 'w' || c == 'W') --y;
    if (c == 's' || c == 'S') ++x;
    if (c == 'n' || c == 'N') --x;
    return make_pair(x, y);
}

bool isrobot(char c) {
    return c >= 'A' && c <= 'Z';
}

int main() {
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);

    int n, m, g;
    scanf("%d%d%d", &n, &m, &g);
    for (int i = 0; i < n; ++i) {
        scanf("%s", f[i]);
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            //if (used[i][j]) continue;
            if (!isrobot(f[i][j])) continue;
            vector<pair<int, int>> was;
            int cx = i, cy = j;
            int curans = 0;
            int ctime = 1;
            bool fl = false;
            pair<int, int> from;
            int curpre = 0;
            while (true) {
                if (used[cx][cy]) {
                    if (res[cx][cy] == 0) {
                        curans = ctime - cused[cx][cy];
                        fl = true;
                    } else {
                        curans = res[cx][cy];
                        from = beg[cx][cy];
                        curpre = pre[cx][cy];
                    }
                    break;
                }
                cused[cx][cy] = ctime;
                was.push_back(make_pair(cx, cy));
                used[cx][cy] = true;
                pair<int, int> to = go(cx, cy, f[cx][cy]);
                cx = to.first, cy = to.second;
                ++ctime;
            }
            if (curans > 0) {
                if (fl) {
                    from = make_pair(-1, -1);
                    int bpos = 0;
                    for (int i = cused[cx][cy] - 1; i < (int)was.size(); ++i) {
                        int xx = was[i].first, yy = was[i].second;
                        if (from.first == -1 || (xx < from.first || (xx == from.first && yy < from.second))) {
                            from = make_pair(xx, yy);
                            bpos = i;
                        }
                    }
                    csize[from.first][from.second] = curans;
                    for (int i = bpos - 1; i >= 0; --i) {
                        int xx = was[i].first, yy = was[i].second;
                        pre[xx][yy] = bpos;
                    }
                    for (int i = bpos + 1; i < (int)was.size(); ++i) {
                        int xx = was[i].first, yy = was[i].second;
                        pre[xx][yy] = csize[from.first][from.second] - (i - bpos);
                    }
                } else {
                    for (int i = 0; i < (int)was.size(); ++i) {
                        int xx = was[i].first, yy = was[i].second;
                        pre[xx][yy] = was.size() - i + curpre;
                    }
                }
                for (pair<int, int> cp : was) {
                    res[cp.first][cp.second] = curans;
                    beg[cp.first][cp.second] = from;
                }
                ++robs[from.first][from.second];
                rbs[from.first][from.second].push_back(make_pair(i, j));
            }
            //cout << i << ' ' << j << ' ' << curans << '\n';
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (beg[i][j] == make_pair(i, j)) {
                ans += min(csize[i][j], robs[i][j]);
                //cout << i << ' ' << j << ' ' << csize[i][j] << ' ' << robs[i][j] << '\n';
            }
        }
    }
    cout << ans << '\n';
    if (g == 1) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < m; ++j) {
                if (beg[i][j] == make_pair(i, j) && csize[i][j] > 0) {
                    for (int x = 0; x < (int)rbs[i][j].size() && x < csize[i][j]; ++x) {
                        int xx = rbs[i][j][x].first, yy = rbs[i][j][x].second;
                        int pp = pre[xx][yy];// % csize[i][j];
                        int nad = x - pp;
                        while (nad < 0) nad += csize[i][j];
                        cout << xx + 1 << ' ' << yy + 1 << ' ' << nad + 1 << '\n';
                    }
                }
            }
        }
    }
    return 0;
}