#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cctype>

using namespace std;

const int maxn = 2000000;

int f[maxn];
int w[maxn];
bool is[maxn];
int cn[maxn];
int cv[maxn];
int pw[maxn];

int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
vector<int> cur;
vector<int> p[maxn];
vector<int> p1[maxn];
vector<int> cs[maxn];
int lc;

#define I(p_) ((p_)/m)
#define J(p_) ((p_)%m)
#define P(i_, j_) ((i_)*m+(j_))

int dfs(int v)
{
    cur.push_back(v);
    w[v] = 1;
    int y = -1;
    p[f[v]].push_back(v);
    if (w[f[v]] == 1) {
        return f[v];
    } else if (w[f[v]] == 0) {
        y = dfs(f[v]);
    }
    w[v] = 2;
    return y;
}

int dfs2(int v, int c)
{
    pw[v] = is[v] ? 1 : 0;
    cn[v] = c;
    for (auto y: p[v]) {
        if (cn[y] == -1) {
            pw[v] += dfs2(y, c);
            p1[v].push_back(y);
        }
    }
    return pw[v];
}


vector<pair<int, int>> e;

pair<int, int> dfs3(int v, int cnt, int t)
{
    if (cnt == 0) {
        return {cnt, t};
    }
    if (is[v]) {
        e.push_back({v, t});
        --cnt;
        --t;
    }
    for (auto y: p1[v]) {
        auto g = dfs3(y, cnt, t-1);
        cnt = g.first;
        t = g.second+1;
    }
    return {cnt, t};
}

int main()
{
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    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) {
            switch (tolower(s[j])) {
                case 'n': f[P(i, j)] = P(i+dx[0], j+dy[0]); break;
                case 'e': f[P(i, j)] = P(i+dx[1], j+dy[1]); break;
                case 's': f[P(i, j)] = P(i+dx[2], j+dy[2]); break;
                case 'w': f[P(i, j)] = P(i+dx[3], j+dy[3]); break;
                default: break;
            }
            is[P(i, j)] = isupper(s[j]);
        }
    }
    int u = n*m;
    fill(cn, cn+u, -1);
    for (int i = 0; i < u; ++i) {
        if (w[i] == 0) {
            int y;
            if ((y = dfs(i)) != -1) {
                auto it = find(cur.begin(), cur.end(), y);
                cs[lc++] = vector<int>(it, cur.end());
                for (auto q: cs[lc-1]) {
                    cn[q] = lc-1;
                }
            }
            cur.clear();
        }
    }
    for (int i = 0; i < lc; ++i) {
        for (auto y: cs[i]) {
            dfs2(y, cn[y]);
        }
    }
    for (int i = 0; i < u; ++i) {
        if (is[i]) {
            ++cv[cn[i]];
        }
    }
    int res = 0;
    for (int i = 0; i < lc; ++i) {
        res += min(int(cs[i].size()), cv[i]);
    }
    cout << res << '\n';
    if (g == 0) {
        return 0;
    }
    for (int i = 0; i < lc; ++i) {
        int nd = min(int(cs[i].size()), cv[i]);
        int curt = 1e7;
        for (auto y: cs[i]) {
            int r = min(pw[y], nd);
            dfs3(y, r, curt);
            nd -= r;
            curt += r-1;
        }
    }
    for (auto &h: e) {
        cout << I(h.first)+1 << ' ' << J(h.first)+1 << ' ' << h.second << '\n';
    }
    return 0;
}
