#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>

using namespace std;

const int MAX_N = 1001;
const int MAX_C = 1000001;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int n, m, go[MAX_N][MAX_N], cx, cy, c, g, har[MAX_C], num[MAX_N][MAX_N], dist[MAX_N][MAX_N], pr[MAX_N][MAX_N];
pair<int, int> how[MAX_N][MAX_N];
string s[MAX_N];
bool used[MAX_N][MAX_N], used_now[MAX_N][MAX_N];
vector<vector<pair<int, int> > > cicle;
vector<pair<int, int> > v;
vector<pair<int, int> > to[MAX_N][MAX_N];

void dfs(int x, int y)
{
    used[x][y] = true;
    used_now[x][y] = true;
    v.push_back(make_pair(x, y));
    int l = x + dx[go[x][y]];
    int r = y + dy[go[x][y]];
    if (used[l][r] && !used_now[l][r])
    {
        dist[x][y] = dist[l][r] + 1;
        num[x][y] = num[l][r];
        how[x][y] = how[l][r];
        return;
    }
    if (!used[l][r])
    {
        dfs(l, r);
        if (cx != -1 && cy != -1)
        {
            cicle[c - 1].push_back(make_pair(x, y));
            dist[x][y] = 0;
            num[x][y] = c - 1;
            how[x][y] = make_pair(x, y);
        }
        if (cx == -1 && cy == -1)
        {
            dist[x][y] = dist[l][r] + 1;
            num[x][y] = num[l][r];
            how[x][y] = how[l][r];
        }
        if (x == cx && y == cy)
        {
            cx = -1;
            cy = -1;
        }
    }
    else if (used_now[l][r])
    {
        c++;
        vector<pair<int, int> > emp;
        cicle.push_back(emp);
        cx = l;
        cy = r;
        cicle[c - 1].push_back(make_pair(x, y));
        dist[x][y] = 0;
        num[x][y] = c - 1;
        how[x][y] = make_pair(x, y);
        return;
    }
}

int main()
{
    #define fname "robots"
    freopen(fname".in", "r", stdin);
    freopen(fname".out", "w", stdout);
    scanf("%d%d%d\n", &n, &m, &g);
    for (int i = 0; i < n; i++)
        getline(cin, s[i]);
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            if (s[i][j] == 's' || s[i][j] == 'S')
                go[i][j] = 0;
            else if (s[i][j] == 'e' || s[i][j] == 'E')
                go[i][j] = 1;
            else if (s[i][j] == 'n' || s[i][j] == 'N')
                go[i][j] = 2;
            else
                go[i][j] = 3;
        }
    memset(num, -1, sizeof(num));
    c = 0;
    cx = -1;
    cy = -1;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if (!used[i][j])
            {
                v.clear();
                dfs(i, j);
                for (pair<int, int> p : v)
                    used_now[p.first][p.second] = false;
            }
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if ('A' <= s[i][j] && s[i][j] <= 'Z')
                if (num[i][j] != -1)
                    har[num[i][j]]++;
    int ans = 0;
    for (int i = 0; i < c; i++)
    {
        int f = cicle[i].size();
        ans += min(f, har[i]);
    }
    cout << ans << endl;
    if (g == 0)
        return 0;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            if ('A' <= s[i][j] && s[i][j] <= 'Z')
                to[how[i][j].first][how[i][j].second].push_back(make_pair(i, j));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            pr[i][j] = to[i][j].size();
    int timer = 0;
    vector<pair<pair<int, int>, int> > u;
    for (int i = 0; i < c; i++)
    {
        int len = cicle[i].size();
        int y = min(len, har[i]);
        int ll[y];
        int ss = 0;
        for (int j = 0; j < y; j++)
        {
            while (pr[cicle[i][ss].first][cicle[i][ss].second] == 0)
                ss++;
            pr[cicle[i][ss].first][cicle[i][ss].second]--;
            ll[j] = ss;
        }
        vector<vector<int> > sovm(len);
        for (int j = 0; j < y; j++)
            sovm[ll[j]].push_back(j);
        for (int j = 0; j < len; j++)
            if (sovm[j].size() != 0)
            {
                vector<pair<int, int> > e = to[cicle[i][j].first][cicle[i][j].second];
                for (int h = 0; h < sovm[j].size(); h++)
                {
                    int f = sovm[j][h];
                    pair<int, int> r = e[h];
                    int w = dist[r.first][r.second];
                    timer += c;
                    timer += w + 1;
                    int cur_pos = (timer + f) % len;
                    timer += (len + j - cur_pos) % len;
                    u.push_back({r, timer - w});
                }
            }
        /*pair<int, int> is[len];
        int ss = 0;
        for (int j = 0; j < min(len, har[i]); j++)
        {
            while (pr[cicle[i][ss].first][cicle[i][ss].second] == 0)
                ss++;
            is[j] = circle[i][ss];
            pr[cicle[i][ss].first][cicle[i][ss].second]--;
            ll[j] = ss;
        }
        for (int j = 0; j < min(len, har[i]); j++)
        {

        }*/
    }
    for (pair<pair<int, int>, int> t : u)
        cout << t.first.first + 1 << " " << t.first.second + 1 << " " << t.second + 1 << endl;
    return 0;
}
