#define consfl 0
#define fname "robots"

#include <iostream>
#include <cstdio>
#include <cstdlib>

#include <algorithm>
#include <cmath>

#include <vector>
#include <set>

#define forn(i, n) for (ll i = 0; i < n; i ++)
#define fornn(i, n, m) for (ll i = n; i < m; i ++)
#define mk make_pair
#define outb pop_back
#define inb push_back
#define X first
#define Y second

typedef long long ll;

using namespace std;

const int dd = 1e5;

char f[2000][2000];
pair<ll, pair<ll, pair<ll, ll> > > c[2000][2000];
ll cnum[2000][2000];
bool used[2000][2000];


vector<vector<bool> > usedc;

vector<ll> cic, csz;
vector<pair<ll, ll> > way;

void initc(ll x, ll y, pair<ll, ll> ss, ll num, bool fl) {
	if (ss == mk(x, y) && !fl)
		return;
	cnum[x][y] = num;
	ll xn = x;
	ll yn = y;
	if (f[x][y] == 'S' || f[x][y] == 's')
		xn++;
	if (f[x][y] == 'W' || f[x][y] == 'w')
		yn--;
	if (f[x][y] == 'N' || f[x][y] == 'n')
		xn--;
	if (f[x][y] == 'E' || f[x][y] == 'e')
		yn++;
	initc(xn, yn, ss, num + 1, 0);
}

void go(ll x, ll y) {
	used[x][y] = 1;
	way.inb(mk(x, y));
	ll xn = x;
	ll yn = y;
	if (f[x][y] == 'S' || f[x][y] == 's')
		xn++;
	if (f[x][y] == 'W' || f[x][y] == 'w')
		yn--;
	if (f[x][y] == 'N' || f[x][y] == 'n')
		xn--;
	if (f[x][y] == 'E' || f[x][y] == 'e')
		yn++;
	if (!used[xn][yn]) {
		go(xn, yn);
		c[x][y].X = c[xn][yn].X;
	}
	else
		if (!c[xn][yn].X) {
			pair<ll, ll> ss = mk(xn, yn);
			ll sz = 1;
			while (way.back() != mk(xn, yn))
				ss = min(ss, way.back()), way.outb(), sz++;
			initc(ss.X, ss.Y, ss, 1, 1);
			cic.inb(sz);
			csz.inb(sz);
			usedc.inb(vector<bool>(sz, 0));
			c[x][y].X = cic.size();
		}
		else {
			c[x][y].X = c[xn][yn].X;
		}
}

void go1(ll x, ll y) {
	if (cnum[x][y]) {
		c[x][y].Y.X = 0;
		c[x][y].Y.Y = mk(x, y);
		return;
	}
	used[x][y] = 1;
	ll xn = x;
	ll yn = y;
	if (f[x][y] == 'S' || f[x][y] == 's')
		xn++;
	if (f[x][y] == 'W' || f[x][y] == 'w')
		yn--;
	if (f[x][y] == 'N' || f[x][y] == 'n')
		xn--;
	if (f[x][y] == 'E' || f[x][y] == 'e')
		yn++;
	if (!used[xn][yn])
		go1(xn, yn);
	c[x][y].Y.X = c[xn][yn].Y.X + 1;
	c[x][y].Y.Y = c[xn][yn].Y.Y;
}



int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	if (!consfl) {
		freopen(fname".in", "r", stdin);
		freopen(fname".out", "w", stdout);
	}
#endif
	ll n, m, g;
	cin >> n >> m >> g;

	forn(i, n)
		forn(j, m)
		cin >> f[i][j];

	forn(i, n)
		forn(j, m)
		if ('A' <= f[i][j] && f[i][j] <= 'Z')
			go(i, j);

	forn(i, n)
		forn(j, m)
		used[i][j] = 0;
	forn(i, n)
		forn(j, m)
		if ('A' <= f[i][j] && f[i][j] <= 'Z')
			go1(i, j);

	vector<pair<pair<ll, ll>, ll> > ans;

	vector<ll> zxc(cic.size(), 1);
	forn(i, n)
		forn(j, m)
		if ('A' <= f[i][j] && f[i][j] <= 'Z')
			if (cic[c[i][j].X - 1]) {
				ll timer = zxc[c[i][j].X - 1];
				cic[c[i][j].X - 1] --;
				ll len = csz[c[i][j].X - 1];
				ll t = c[i][j].Y.X;

				ll start = cnum[c[i][j].Y.Y.X][c[i][j].Y.Y.Y] - 1;
				start -= timer;
				start = (start % len + len) % len;

				start -= t;
				start = (start % len + len) % len;
				ll ind = -1;
				forn(qq, len) {
					if (!usedc[c[i][j].X - 1][((start - qq) % len + len) % len]) {
						usedc[c[i][j].X - 1][((start - qq) % len + len) % len] = 1;
						ind = ((start - qq) % len + len) % len;
						break;
					}
				}

				ll tt = start - ind;
				tt = (tt % len + len) % len;
				if (timer + tt <= 1000000000)
				ans.inb(mk(mk(i, j), timer + tt));
				timer += tt + t;
				zxc[c[i][j].X - 1] = timer;
			}
	cout << ans.size() << endl;
	if (g) {
		forn(i, ans.size()) {
			if (ans[i].Y > 1000000000) {
				while (1) {}
			}
			cout << ans[i].X.X + 1 << ' ' << ans[i].X.Y + 1 << ' ' << ans[i].Y << endl;
		}
	}
	return 0;
}