#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define chr unsigned char
#define maxn 1007

int a[maxn][maxn];
int c[maxn][maxn];
bool cycle[maxn][maxn];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};

int xc, yc;

bool dfs(int x, int y){
    c[x][y] = 1;

    int x0 = x + dx[a[x][y]], y0 = y + dy[a[x][y]];

    if (c[x0][y0] == 1){
        xc = x0;
        yc = y0;
        cycle[x][y] = true;
        c[x][y] = 2;
        return true;
    }

    if (dfs(x0, y0)){
        cycle[x][y] = true;
        c[x][y] = 2;
        if (x == xc && y == yc)
            return false;
        else
            return true;
    }

    c[x][y] = 2;
    return false;
}


int main()
{
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);

    int n, m, g;
    cin >> n >> m >> g;

    chr x;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j){
            cin >> x;
            cycle[i][j] = false;
            c[i][j] = 0;
            if (x == 'N') a[i][j] = 0;
            if (x == 'E') a[i][j] = 1;
            if (x == 'S') a[i][j] = 2;
            if (x == 'W') a[i][j] = 3;
        }

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (c[i][j] == 0){
                xc = -1;
                yc = -1;
                dfs(i, j);
            }


    int cnt = 0;
    for (int i = 1; i <= n; ++i){
        for (int j = 1; j <= m; ++j)
       //     cout << cycle[i][j] << ' ';
            cnt += cycle[i][j];
      //  cout << endl;
    }

    cout << cnt << endl;

    if (g == 1){
        for (int i = 1; i <= n; ++i)
            for (int j = 1; j <= m; ++j)
                if (cycle[i][j])
                    cout << i << ' ' << j << ' ' << 1 << endl;
    }

    fclose(stdout);
    return 0;
}
