#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

vector<bool> goodtime;
vector<int> backg[1000000];
int ans[1000000];
bool r[1000000];
bool us[1000000];

bool inloop[1000000];

int gyk;

void dfs(int v, int mintime, int gykbegin)
{
    if (us[v])
        return;
    us[v] = true;
    if (inloop[v] || !r[v])
    {
        inloop[v] = false;
        for (int i : backg[v])
            dfs(i, max(1, mintime - 1), (gykbegin - 1 + goodtime.size()) % goodtime.size());
    }
    else
    {
        while (gyk < goodtime.size() && goodtime[gyk])
            ++gyk;
        if (goodtime.size() == gyk)
        {
            for (int i : backg[v])
            dfs(i, 0, (gykbegin - 1 + goodtime.size()) % goodtime.size());
            return;
        }
        int tm = (gyk + gykbegin - 1 + goodtime.size()) % goodtime.size();
        goodtime[gyk] = true;
        int hlp = mintime / goodtime.size() * goodtime.size();
        if (mintime > hlp + tm)
            hlp += goodtime.size();
        ans[v] = hlp + tm;
        for (int i : backg[v])
            dfs(i, max(1, hlp + tm - 1), (gykbegin - 1 + goodtime.size()) % goodtime.size());
    }
}

void sol(int h, int w, int gg)
{
    int g[h * w];
    map<char, int> mp;
    mp['N'] = 0;
    mp['W'] = 1;
    mp['S'] = 2;
    mp['E'] = 3;
    mp['n'] = 0;
    mp['w'] = 1;
    mp['s'] = 2;
    mp['e'] = 3;
    for (int i = 0; i < h; ++i)
    {
        string s;
        cin >> s;
        for (int j = 0; j < w; ++j)
        {
            int hlp = j + i * w;
            if ('A' <= s[j] && s[j] <= 'Z')
                r[hlp] = true;
            else
                r[hlp] = false;
            if (mp[s[j]] == 0)
            {
                g[hlp] = hlp - w;
                backg[hlp - w].push_back(hlp);
            }
            if (mp[s[j]] == 1)
            {
                g[hlp] = hlp - 1;
                backg[hlp - 1].push_back(hlp);
            }
            if (mp[s[j]] == 2)
            {
                g[hlp] = hlp + w;
                backg[hlp + w].push_back(hlp);
            }
            if (mp[s[j]] == 3)
            {
                g[hlp] = hlp + 1;
                backg[hlp + 1].push_back(hlp);
            }
        }
    }
    int time[w * h];
    for (auto &i : us)
        i = false;

    bool usn[w * h];
    for (auto &i : usn)
        i = false;

    for (int i = 0; i < w * h; ++i)
    {
        if (!us[i])
        {
            int yk = i;
            int tm = 0;
            goodtime.resize(0);
            while (!usn[yk])
            {
                time[yk] = tm++;
                usn[yk] = true;
                yk = g[yk];
            }
            int len = tm - time[yk];
            int mem = yk;
            do
            {
                yk = g[yk];
                inloop[yk] = true;
                goodtime.push_back(r[yk]);
                if (r[yk])
                    ans[yk] = 1;
            }while (mem != yk);
            gyk = 0;
            dfs(yk, 1, len - 1);
        }
    }
    int cnt = 0;
    for (int i = 0; i < w * h; ++i)
        if (ans[i] > 0)
        {
            ++cnt;
        }
    printf("%d\n", cnt);
    if (gg)
    {
        for (int i = 0; i < w * h; ++i)
        if (ans[i] > 0)
        {
            printf("%d %d %d\n", i / w + 1, i % w + 1, ans[i]);
        }
    }
}

int main()
{
    freopen("robots.in", "r", stdin);
    freopen("robots.out", "w", stdout);
    int n, m, g;
    while (scanf("%d%d%d", &n, &m, &g) == 3)
        sol(n, m, g);
    return 0;
}
