#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
using namespace std;
long const w=10000000;
long n, m, i, j, g[20000001], ans = 0, dlina, tin[20000001], v1, rob, ras[2000001], och[20000001], l, r, t;
vector <long> g1[1000001], ans1[3];
char x;
bool used1[20000001], used2[20000001], robot[20000001], p = false, q;
void dfs1(long v) {
	if (used1[g[v]] == true) {
		p = true;
		dlina = tin[v] - tin[g[v]] + 1;
		v1 = g[v];
	}
	if (p == false) {
		used1[v] = true;
		tin[g[v]] = tin[v] + 1;
		dfs1(g[v]);
	}
}
int main() {
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	cin >> n >> m >> q;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			cin >> x;
			if (x == 'W') {
				robot[i*m + j] = true;
				g[i*m + j] = i*m + j - 1;
				g1[i*m + j - 1].push_back(i*m + j);
			}
			if (x == 'w') {
				robot[i*m + j] = false;
				g[i*m + j] = i*m + j - 1;
				g1[i*m + j - 1].push_back(i*m + j);
			}
			if (x == 'S') {
				robot[i*m + j] = true;
				g[i*m + j] = (i + 1)*m + j;
				g1[(i + 1)*m + j].push_back(i*m + j);
			}
			if (x == 's') {
				robot[i*m + j] = false;
				g[i*m + j] = (i + 1)*m + j;
				g1[(i + 1)*m + j].push_back(i*m + j);
			}
			if (x == 'N') {
				robot[i*m + j] = true;
				g[i*m + j] = (i - 1)*m + j;
				g1[(i - 1)*m + j].push_back(i*m + j);
			}
			if (x == 'n') {
				robot[i*m + j] = false;
				g[i*m + j] = (i - 1)*m + j;
				g1[(i - 1)*m + j].push_back(i*m + j);
			}
			if (x == 'E') {
				robot[i*m + j] = true;
				g[i*m + j] = i*m + j + 1;
				g1[i*m + j + 1].push_back(i*m + j);
			}
			if (x == 'e') {
				robot[i*m + j] = false;
				g[i*m + j] = i*m + j + 1;
				g1[i*m + j + 1].push_back(i*m + j);
			}
			used1[i*m + j] = false;
			used2[i*m + j] = false;
		}
	}
	for (i = 0; i < n*m; i++) {
		if (used1[i] == false) {
			tin[i] = 0;
			rob = 0;
			p = false;
			dfs1(i);
			ras[v1] = 0;
			och[0] = v1;
			l = 0;
			r = 1;
			t = w;
			while (l < r) {
				used2[och[l]] = true;
				used1[och[l]] = true;
				if (robot[och[l]] == true) {
					rob++;
					if (rob <= dlina&&q==1) {
						ans1[0].push_back(och[l] / m);
						ans1[1].push_back(och[l]%m);
						ans1[2].push_back(t - ras[och[l]]);
					}
				}
				for (j = 0; j < g1[och[l]].size(); j++) {
					if (used2[g1[och[l]][j]]==false) {
						ras[g1[och[l]][j]] = ras[och[l]] + 1;
						och[r] = g1[och[l]][j];
						r++;
					}
				}
				l++;
			}
			ans += min(rob, dlina);
		}
	}
	cout << ans<<endl;
	if (q == true) {
		for (i = 0; i < ans1[0].size(); i++) {
			cout << ans1[0][i]+1 << " " << ans1[1][i]+1 <<" "<< ans1[2][i] << endl;
		}
	}
	return 0;
}