#include <iostream>
#include <sstream>
#include <cstdio>
#include <set>
#include <algorithm>
#include <cmath>
#include <vector>


using namespace std;

int n, m, g;
string s[1002];
bool used[1002][1002];
int incycle[1002][1002];
vector<vector<pair<int, int> > > cycle;
vector<pair<int, int> > topsort;
//int dist[1002][1002];


void dfs(int i, int j) {
    //cout << "opa" << ' ' << i << ' ' << j << endl;
    if (i >= 1 && (s[i - 1][j] == 'S' || s[i - 1][j] == 's') && !used[i - 1][j]) {
        incycle[i - 1][j] = incycle[i][j] + 1;
        dfs(i - 1, j);
    }
    if (i < n - 1 && (s[i + 1][j] == 'N' || s[i + 1][j] == 'n') && !used[i + 1][j]) {
        incycle[i + 1][j] = incycle[i][j] + 1;
        dfs(i + 1, j);
    }
    if (j >= 1 && (s[i][j - 1] == 'E' || s[i][j - 1] == 'e') && !used[i][j - 1]) {
        incycle[i][j - 1] = incycle[i][j] + 1;
        dfs(i, j - 1);
    }
    if (j < m - 1 && (s[i][j + 1] == 'W' || s[i][j + 1] == 'w') && !used[i][j + 1]) {
        incycle[i][j + 1] = incycle[i][j] + 1;
        dfs(i, j + 1);
    }
    if (s[i][j] >= 'A' && s[i][j] <= 'Z') {
        topsort.push_back(make_pair(i, j));
    }
}


int main() {
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    cin >> n >> m >> g;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    int cnt = 0;
    vector<pair<int, int> > cc;
    for (int i1 = 0; i1 < n; i1++) {
        for (int j1 = 0; j1 < m; j1++) {
            //cout << i1 << ' ' << j1 << endl;
            //cout << s[i1][j1] << endl;
            if (!incycle[i1][j1]) {
                if (s[i1][j1] == 'S' || s[i1][j1] == 's') {
                    if (s[i1 + 1][j1] == 'N' || s[i1 + 1][j1] == 'n') {
                        cnt++;
                        incycle[i1][j1] = cnt;
                        used[i1][j1] = 1;
                        used[i1 + 1][j1] = 1;
                        incycle[i1 + 1][j1] = cnt;
                        cycle.push_back(cc);
                        cycle[cnt - 1].push_back(make_pair(i1, j1));
                        cycle[cnt - 1].push_back(make_pair(i1 + 1, j1));
                        continue;
                    }
                }
                if (s[i1][j1] == 'N' || s[i1][j1] == 'n') {
                    if (s[i1 - 1][j1] == 'S' || s[i1 - 1][j1] == 's') {
                        cnt++;
                        incycle[i1][j1] = cnt;
                        used[i1][j1] = 1;
                        used[i1 - 1][j1] = 1;
                        incycle[i1 - 1][j1] = cnt;
                        cycle.push_back(cc);
                        cycle[cnt - 1].push_back(make_pair(i1, j1));
                        cycle[cnt - 1].push_back(make_pair(i1 - 1, j1));
                        continue;
                    }
                }
                if (s[i1][j1] == 'E' || s[i1][j1] == 'e') {
                    if (s[i1][j1 + 1] == 'W' || s[i1][j1 + 1] == 'w') {
                        cnt++;
                        incycle[i1][j1] = cnt;
                        used[i1][j1] = 1;
                        used[i1][j1 + 1] = 1;
                        incycle[i1][j1 + 1] = cnt;
                        cycle.push_back(cc);
                        cycle[cnt - 1].push_back(make_pair(i1, j1));
                        cycle[cnt - 1].push_back(make_pair(i1, j1 + 1));
                        continue;
                    }
                }
                if (s[i1][j1] == 'W' || s[i1][j1] == 'w') {
                    if (s[i1][j1 - 1] == 'E' || s[i1][j1 - 1] == 'e') {
                        cnt++;
                        incycle[i1][j1] = cnt;
                        used[i1][j1] = 1;
                        used[i1][j1 - 1] = 1;
                        incycle[i1][j1 - 1] = cnt;
                        cycle.push_back(cc);
                        cycle[cnt - 1].push_back(make_pair(i1, j1));
                        cycle[cnt - 1].push_back(make_pair(i1, j1 - 1));
                        continue;
                    }
                }
            }
            if (!used[i1][j1] && !incycle[i1][j1]) {
                int i = i1;
                int j = j1;
                int cntc = 0;
                vector<pair<int, int> > v;
                while (!used[i][j] && !incycle[i][j]) {
                    used[i][j] = 1;
                    v.push_back(make_pair(i, j));
                    cntc++;
                    if (s[i][j] == 'S' || s[i][j] == 's') {
                        i++;
                        continue;
                    }
                    if (s[i][j] == 'N' || s[i][j] == 'n') {
                        i--;
                        continue;
                    }
                    if (s[i][j] == 'E' || s[i][j] == 'e') {
                        j++;
                        continue;
                    }
                    if (s[i][j] == 'W' || s[i][j] == 'w') {
                        j--;
                        continue;
                    }
                }
                if (incycle[i][j]) {
                    continue;
                }
                for (int h = 0; h < (int)v.size(); h++) {
                    if (v[h] == make_pair(i, j)) {
                        if (h == (int)v.size() - 1) {
                            continue;
                        } else {
                            cnt++;
                            cycle.push_back(cc);
                            for (int g = h; g < (int)v.size(); g++) {
                                cycle[cnt - 1].push_back(v[g]);
                                incycle[v[g].first][v[g].second] = 1;
                            }
                            break;
                        }
                    }
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            used[i][j] = 0;
        }
    }
   // cout << cnt << endl;
    int ans = 0;
    for (int k = 0; k < cnt; k++) {
        int p = (int)cycle[k].size();
        for (int i = 0; i < (int)cycle[k].size(); i++) {
            int i1 = cycle[k][i].first;
            int j1 = cycle[k][i].second;
            used[i1][j1] = 1;
        }
    }
    vector<pair<pair<int, int>, int> > v;
    for (int k = 0; k < cnt; k++) {
        int p = (int)cycle[k].size();
      //  cout << k << endl;
        vector<int> ok;
        for (int i = 0; i < (int)cycle[k].size(); i++) {
            int i1 = cycle[k][i].first;
            int j1 = cycle[k][i].second;
            //cout << i1 << ' ' << j1 << endl;
            if (s[i1][j1] >= 'A' && s[i1][j1] <= 'Z') {
                ans++;
                p--;
                if (g) {
                    v.push_back(make_pair(make_pair(i1, j1), 0));
                }
            } else {
                ok.push_back(i);
            }
        }
        //cout << ans << endl;
        for (int i = 0; i < (int)cycle[k].size(); i++) {
            int i1 = cycle[k][i].first;
            int j1 = cycle[k][i].second;
            topsort.clear();
            incycle[i1][j1] = 0;
            //cout << k << ' ' << i <<  endl;
            dfs(i1, j1);
            if (!topsort.empty()) {
               // cout << (int)topsort.size() << ' ' << k << endl;
                reverse(topsort.begin(), topsort.end());
                int l = 0;
                for (int j = 0; j < (int)topsort.size() && p != 0; j++) {
                    i1 = topsort[j].first;
                    j1 = topsort[j].second;
                    if (!used[i1][j1] && s[i1][j1] >= 'A' && s[i1][j1] <= 'Z') {
                        p--;
                        ans++;
                        if (g) {
                            int sf = incycle[i1][j1];
                            //cout << sf << endl;
                            int gt = (ok[l] + sf) % (int)cycle[k].size();
                            int dist = 0;
                            if (gt < i) {
                                dist = i - gt;
                            } else {
                                dist = (int)cycle[k].size() - gt + i - 1;
                            }
                            //cout << gt << endl;
                            v.push_back(make_pair(make_pair(i1, j1), dist));
                            l++;
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
    if (g) {
        for (int i = 0; i < ans; i++) {
            printf("%d %d %d\n", v[i].first.first + 1, v[i].first.second + 1, v[i].second + 1);
        }
    }
    return 0;
}

/*

4 4 1
essS
Eess
Snww
EeWN
*/
