#include <fstream>
#include <vector>

using namespace std;
///{N,E,S,W}
int di[] = {-1,0,1,0}, dj[] = {0,1,0,-1};
int n, m, iter = 1;
char dir[1010][1010];
bool term[1010][1010];
int used[1010][1010],
   cycid[1010][1010],
  cycpos[1010][1010];
vector <int> cycsz, cycused;
vector <pair<int, int> > res;
int main() {
    ifstream cin("robots.in");
    ofstream cout("robots.out");
    int g, c;
    cin >> n >> m >> g;
    string cur_s;
    for (int i = 0; i < n; i++) {
        cin >> cur_s;
        for (int j = 0; j < m; j++) {
            cycid[i][j] = -1;
            cycpos[i][j] = -1;
            term[i][j] = (cur_s[j] < 'a');
            if (cur_s[j] == 'N' || cur_s[j] == 'n')
                dir[i][j] = 0;
            if (cur_s[j] == 'E' || cur_s[j] == 'e')
                dir[i][j] = 1;
            if (cur_s[j] == 'S' || cur_s[j] == 's')
                dir[i][j] = 2;
            if (cur_s[j] == 'W' || cur_s[j] == 'w')
                dir[i][j] = 3;
        }
    }
    /*cout << endl;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++)
            cout << (int)dir[i][j];
        cout << endl;
    }*/
    int ci, cj, cyci, cycj, cdir, len;
    for (int si = 0; si < n; si++)
    for (int sj = 0; sj < m; sj++) {
        if(term[si][sj]) {
            //cout << "new"<<endl;
            ci = si;
            cj = sj;
            len = 0;
            while(!used[ci][cj]) {
                //cout << "now " << ci << ' ' << cj << endl;
                used[ci][cj] = 1;
                cdir = dir[ci][cj];
                ci += di[cdir];
                cj += dj[cdir];
                len++;
            }
            if (cycid[ci][cj] != -1) {
                //cout << "join " << cycid[ci][cj];
                cycid[si][sj] = cycid[ci][cj];
                cycpos[si][sj] = cycpos[ci][cj] + len;
                if (cycused[cycid[ci][cj]] < cycsz[cycid[ci][cj]]) {
                    cycused[cycid[ci][cj]]++;
                    //cout << " done!";
                    res.push_back(make_pair(si * 1024 + sj, cycpos[si][sj] + cycsz[cycid[ci][cj]] - cycused[cycid[ci][cj]] + 1));
                }
                //cout << endl;
            } else {
                //cout << "newcyc\n";
                cyci = ci;
                cycj = cj;
                cycsz.push_back(0);
                cycused.push_back(1);
                res.push_back(make_pair(si * 1024 + sj, len));
                cycid[si][sj] = cycsz.size() - 1;
                cycpos[si][sj] = len;
                do {
                    cycsz[cycsz.size() - 1]++;
                    cycid[ci][cj] = cycsz.size() - 1;
                    cdir = dir[ci][cj];
                    ci += di[cdir];
                    cj += dj[cdir];
                } while (ci != cyci || cj != cycj);
            }

            ci = si;
            cj = sj;
            len = 0;
            do {
                cycid[ci][cj] = cycid[si][sj];
                cycpos[ci][cj] = cycpos[si][sj] - len;
                cdir = dir[ci][cj];
                ci += di[cdir];
                cj += dj[cdir];
                len++;
            } while (cycpos[ci][cj] == -1);
            iter++;
        }
    }
    int max_time = 0;
    for (int i = 0; i < res.size(); i++)
        max_time = max(max_time, res[i].second);
    cout << res.size() << endl;
    if (g)
    for (int i = 0; i < res.size(); i++) {
        cout << res[i].first/1024 + 1 << ' ' << res[i].first%1024 + 1 << ' ' << max_time - res[i].second + 1 << '\n';
    }
    return 0;
}
