#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

struct ver
{
    int x;
    int y;
    bool rob;
    ver(int x,int y,bool rob):x(x),y(y),rob(rob){}
    ver():x(0),y(0),rob(false){}
    ver operator =(ver a)
    {
        x = a.x;
        y = a.y;
        rob = a.rob;
        return a;
    }
};
struct ans
{
    int x;
    int y;
    int t;
    ans(int x,int y,int t):x(x),y(y),t(t){}
};
int num[1005][1005] = {0};
//int time[1005][1005] = {0};
vector<ver> par[1005][1005];
ver child[1005][1005];
ver all[1005][1005];
bool used[1005][1005] ={0};
vector<ans> res;
int ost = 0;
int time = 0;
int rasm  =0;
int vux = 0;
void dfs(int x,int y)
{
    if(used[x][y])
        return;
   if(num[x][y]>0 && ost > 0)
   {
       used[x][y] = true;
       if(all[x][y].rob == true)
       {
            --ost;
            res.push_back(ans(x,y,time+ rasm- num[x][y]%rasm));
            all[x][y].rob = false;
            ++time;
       }
       for(int i = 0;i < par[x][y].size();++i)
       {
           int nx = par[x][y][i].x;
           int ny = par[x][y][i].y;
           num[nx][ny] = num[x][y]%rasm-1;
           if(num[nx][ny] <= 0)
                num[nx][ny]+= rasm*3;
           dfs(nx,ny);
       }
       return;
   }
   if(num[x][y] > 0 && ost <= 0)
        return;
   num[x][y] = 1;
   for(;;)
   {
       int nx,ny;
       nx = child[x][y].x;
       ny = child[x][y].y;
       if(num[nx][ny] > 0)
       {
           ost = num[x][y]-num[nx][ny]+1;
           rasm = ost;
           break;
       }
       num[nx][ny] = num[x][y]+1;
       x = nx;
       y = ny;
   }
    dfs(x,y);
    return;
}
int main()
{
    freopen("robots.in","r",stdin);
    freopen("robots.out","w",stdout);
    res.reserve(1000000);
    int n,m,g;
    cin >> n >> m >> g;
    for(int i = 1; i <= n; ++i)
        for(int i1 = 1; i1 <= m; ++i1)
        {
            all[i1][i].x = i1;
            all[i1][i].y = i;
        }
    for(int i = 1; i <= n; ++i)
        for(int i1 = 1; i1 <= m; ++i1)
        {
            char c;
            scanf(" %c",&c);
            if(c - 'A' >= 0 && c - 'A' <= 30)
                all[i1][i].rob = true;
            if(c == 'N' || c == 'n')
            {
                child[i1][i] = all[i1][i-1];
                par[i1][i-1].push_back(all[i1][i]);
            }
            if(c == 'S' || c == 's')
            {
                child[i1][i] = all[i1][i+1];
                par[i1][i+1].push_back(all[i1][i]);
            }
            if(c == 'W' || c == 'w')
            {
                child[i1][i] = all[i1-1][i];
                par[i1-1][i].push_back(all[i1][i]);
            }
            if(c == 'E' || c == 'e')
            {
                child[i1][i] = all[i1+1][i];
                par[i1+1][i].push_back(all[i1][i]);
            }
        }
    for(int i = 1; i <= n; ++i)
        for(int i1 = 1; i1 <= m; ++i1)
        {
            if(num[i1][i] <= 0)
            {
                time = 0;
                rasm = 0;
                ost = 0;
                dfs(i1,i);
            }
        }
    cout << res.size()<<'\n';
    if(g == 1)
    {
        for(int i = 0; i < res.size();++i)
            cout << res[i].x << ' ' << res[i].y << ' ' << res[i].t << '\n';
    }
    /*
    cout << endl;
     for(int i = 1; i <= n; ++i)
        for(int i1 = 1; i1 <= m; ++i1)
            cout << i1 << ' ' << i << ' ' <<num[i1][i] <<endl;
    */
    return 0;
}
/*
3 4 1
SSSS
EESW
ENWW

4 4 1
essS
Eess
Snww
EeWN
*/
