#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
int n, m, g;
pair <int, int> to[1000][1000];
pair <int, int> from[1000][1000];
int was[1000][1000];
bool was2[1000][1000];
int cycle[1000][1000];
int num[1000][1000];
bool st[1000][1000];
int comp[1000][1000];
int ans[1000][1000];
int sz[1000000];
pair <int, int> near[1000][1000];
vector <pair <int, int> > v;
set <int> s[1000000];
int t = 0;
void dfs(int i, int j) {
    was[i][j] = 1;
    int k = to[i][j].first;
    int l = to[i][j].second;
    if (was[k][l] == 0) {
        dfs(k, l);
    }
    if (was[k][l] == 1) {
        cycle[k][l] = 0;
        comp[k][l] = t;
        t++;
    }
    comp[i][j] = comp[k][l];
    was[i][j] = 2;
}
void dfs1(int i, int j, int d) {
    was2[i][j] = true;
    cycle[i][j] = 0;
    num[i][j] = d;
    int k = to[i][j].first;
    int l = to[i][j].second;
    if (cycle[k][l] != 0) {
        dfs1(k, l, d + 1);
    }
    else {
        sz[comp[i][j]] = d + 1;
    }
}
int dfs2(int i, int j) {
    if (cycle[i][j] != -1) return cycle[i][j];
    int k = to[i][j].first;
    int l = to[i][j].second;
    return dfs2(k, l) + 1;
}
pair <int, int> dfs3(int i, int j) {
    if (near[i][j] != mp(-1, -1)) return near[i][j];
    if (cycle[i][j] == 0) {
        near[i][j] = mp(i, j);
        return near[i][j];
    }
    int k = to[i][j].first;
    int l = to[i][j].second;
    near[i][j] = dfs3(k, l);
    return near[i][j];
}
bool comp1(pair <int, int> p, pair <int, int> q) {
    if (cycle[p.first][p.second] < cycle[q.first][q.second]) return true;
    return false;
}
int main() {
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    cin >> n >> m >> g;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            was[i][j] = 0;
            ans[i][j] = -1;
            cycle[i][j] = -1;
            near[i][j] = mp(-1, -1);
            st[i][j] = false;
            was2[i][j] = false;
            char c;
            cin >> c;
            if (c == 'n' || c == 'N') {
                to[i][j] = mp(i - 1, j);
                if (c == 'N') st[i][j] = true;
            }
            if (c == 's' || c == 'S') {
                to[i][j] = mp(i + 1, j);
                if (c == 'S') st[i][j] = true;
            }
            if (c == 'w' || c == 'W') {
                to[i][j] = mp(i, j - 1);
                if (c == 'W') st[i][j] = true;
            }
            if (c == 'e' || c == 'E') {
                to[i][j] = mp(i, j + 1);
                if (c == 'E') st[i][j] = true;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (was[i][j] == 0) dfs(i, j);
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (cycle[i][j] == 0 && !was2[i][j]) dfs1(i, j, 0);
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) cycle[i][j] = dfs2(i, j);
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (st[i][j]) v.pb(mp(i, j));
        }
    }
    sort(v.begin(), v.end(), comp1);
    for (int i = 0; i < v.size(); i++) {
        int k = v[i].first;
        int l = v[i].second;
        near[k][l] = dfs3(k, l);
        int a = near[k][l].first;
        int b = near[k][l].second;
        int c = comp[k][l];
        //cout << a << " " << b << " " << num[a][b] << "\n";
        //cout << k << " " << l << " " << a << " " << b << " " << c << "\n";
        //cout << sz[comp[k][l]] << "\n";
        for (int j = cycle[k][l]; j < cycle[k][l] + sz[comp[k][l]]; j++) {
            int x = (sz[c] + num[a][b] - (j % sz[c])) % sz[c];
            //cout << k << " " << l << " " << x << "\n";
            if (s[c].find(x) == s[c].end()) {
                ans[k][l] = j - cycle[k][l];
                s[c].insert(x);
                break;
            }
        }
    }
    int col = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (ans[i][j] != -1) col++;
        }
    }
    cout << col << "\n";
    if (g == 0) return 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (ans[i][j] != -1) cout << i + 1 << " " << j + 1 << " " << ans[i][j] + 1 << "\n";
        }
    }
}
