#include <bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e9 + 7;
const int N = 1e6 + 7;
const int M = 1e3 + 7;

int used[M][M], c[M][M], t[M][M], cnt[N], len[N], tim, cl, d[M][M], to[M][M];
bool f = false;
vector <pii> v[N];
pii check_point;
string s[M];

pii get(char x){
    if (x == 'E' || x == 'e')
        return mp(0, 1);
    if (x == 'W' || x == 'w')
        return mp(0, -1);
    if (x == 'N' || x == 'n')
        return mp(-1, 0);
    if (x == 'S' || x == 's')
        return mp(1, 0);
}

void dfs(int x, int y, int col){
    t[x][y] = tim++;
    used[x][y] = 1;
    c[x][y] = col;
    int u = get(s[x][y]).fi + x, e = get(s[x][y]).se + y;
    if (used[u][e] == 0)
        dfs(u, e, col);
    if (used[u][e] == 1)
        f = true, check_point = mp(u, e), len[col] = tim - t[u][e], cl = 0;
    if (f)
        d[x][y] = 0, to[x][y] = cl++;
    else
        d[x][y] = d[u][e] + 1, to[x][y] = to[u][e];
    if (f && check_point == mp(x, y))
        f = false;
    c[x][y] = c[u][e];
    used[x][y] = 2;
}

int main()
{
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    int n, m, g, col = 0;
    cin >> n >> m >> g;
    for (int i = 0; i < n; i++)
        cin >> s[i];
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++){
            if (used[i][j] != 0 || s[i][j] >= 'a' && s[i][j] <= 'z')
                continue;
            dfs(i, j, ++col);
        }

    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if (s[i][j] >= 'a' && s[i][j] <= 'z')
                continue;
            if (cnt[c[i][j]] == len[c[i][j]])
                continue;
            cnt[c[i][j]]++;
            v[c[i][j]].pb(mp(i, j));

        }
    }

    int ans = 0;
    for (int i = 0; i <= col; i++)
        ans += cnt[i];
    cout << ans << endl;
    if (g == 0)
        return 0;
    for (int i = 0; i <= col; i++){
        if (cnt[i] == 0)
            continue;
        for (int j = 0; j < v[i].size(); j++){
            int x = v[i][j].fi, y = v[i][j].se;
            cout << x + 1 << " " << y + 1 << " " << (j - d[x][y] - to[x][y] + len[i] * 3) % len[i] << endl;
        }
    }
    return 0;
}
