#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int used[1050][1050];
vector<pair<int, int> > r;
int d[1050][1050], num[1050][1050], len[1050][1050], numc[1050][1050];
pair<int, int> go[1050][1050];
bool cycle[1050][1050];
pair<int, int> par[1050][1050];
char c[1050][1050];
bool is[1050][1050];
int t = 0, time = 1;
vector<pair<int, int> > v[500500];
int pos[500500];

void dfs(int x, int y, int px, int py){
    //cout << x << " " << y << " " << px << " " << py << endl;
    used[x][y] = 1;
    par[x][y] = make_pair(px, py);
    int nx = x, ny = y;
    if (c[x][y] == 'n'){
        nx--;
    }
    if (c[x][y] == 's'){
        nx++;
    }
    if (c[x][y] == 'e'){
        ny++;
    }
    if (c[x][y] == 'w'){
        ny--;
    }
    int x2 = x, x1, y1 = y;
    if (used[nx][ny] == 1){
        int nm = 0;
        //cout << "abdbsdb" << endl;
        //cout << used[nx][ny] << endl;
        while (x != nx || y != ny){
            //cout << x << " " << y << endl;
            //cout << nx << " " << ny << endl;
            //if (x == -1 || y == -1)
            //    break;
            v[t].push_back(make_pair(x, y));
            num[x][y] = nm;
            nm++;
            cycle[x][y] = true;
            x1 = x;
            x = par[x1][y].first;
            y = par[x1][y].second;
        }
        num[nx][ny] = nm;
        v[t].push_back(make_pair(nx, ny));
        for (int i = 0; i < v[t].size(); i++){
            len[v[t][i].first][v[t][i].second] = nm + 1;
            numc[v[t][i].first][v[t][i].second] = t;
        }
        cycle[nx][ny] = true;
        t++;
    }else
    if (used[nx][ny] == 0)
        dfs(nx, ny, x, y);
    used[x2][y1] = 2;
}

void calc(int x, int y){
    used[x][y] = true;
    if (cycle[x][y]){
        d[x][y] = 0;
        go[x][y] = make_pair(x, y);
        return;
    }
    int nx = x, ny = y;
    if (c[x][y] == 'n'){
        nx--;
    }
    if (c[x][y] == 's'){
        nx++;
    }
    if (c[x][y] == 'e'){
        ny++;
    }
    if (c[x][y] == 'w'){
        ny--;
    }
    if (!used[nx][ny])
        calc(nx, ny);
    d[x][y] = d[nx][ny] + 1;
    go[x][y] = go[nx][ny];

}

int main(){
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    //ios_base::sync_with_studio(0);
    int n, m, g;
    cin >> n >> m >> g;
    gets(c[0]);
    for (int i = 0; i < n; i++){
        //cin >> c[i];
        gets(c[i]);
        for (int j = 0; j < m; j++)
            if (c[i][j] >= 'A' && c[i][j] <= 'Z'){
                r.push_back(make_pair(i, j));
                c[i][j] += (int)'a' - (int)'A';
            }
    }
    //cout << -1 << endl;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (!used[i][j])
                dfs(i, j, -1, -1);
    //cout << -2 << endl;
    for (int i = 0; i < t; i++)
        pos[i] = 0;
    memset(used, 0, sizeof(used));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (!used[i][j])
                calc(i, j);
    //cout << -3 << endl;
    vector<pair<pair<int, int>, int> > ans;
    for (int i = 0; i < r.size(); i++){
        int x = r[i].first, y = r[i].second, pc, nx = go[x][y].first, ny = go[x][y].second, c = numc[nx][ny], x1, y1;
        //cout << x << " " << y << " " << nx << " " << ny << " " << c << endl;
        //cout << c << " " << pos[c] << " " <<" " <<v[c].size() << " "<< x << " " << y << endl;
        if (pos[c] != v[c].size()){
            pc = pos[c];
            x1 = v[c][pc].first;
            y1 = v[c][pc].second;
            //cout << d[x][y] << " " << " " << x1 << " " << y1 << " " << num[nx][ny] << " " << num[x1][y1] << endl;
            int time = len[nx][ny] - (d[x][y] + num[nx][ny] - num[x1][y1] + len[nx][ny]) % len[nx][ny];
            ans.push_back(make_pair(make_pair(x + 1, y + 1), time));
            pos[c]++;
        }
    }
    cout << ans.size() << endl;
    if (g){
        for (int i = 0; i < ans.size(); i++)
            cout << ans[i].first.first << " " << ans[i].first.second << " " << ans[i].second << "\n";
    }
    return 0;
}
