#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
const long long N = (long long)1e3 + 113;
struct pt {
	int x, y, t;
	pt(int x = 0, int y = 0, int t = 0) : x(x), y(y), t(t) {}
};
bool operator == (pt a, pt b) {
	return a.x == b.x && a.y == b.y;
}
int n, m, g, out, currAns;
char tab[N][N];
pt gr[N][N];
int col[N][N];
pt par[N][N];
int num[N][N];

vector <pt> cycle;
vector <pt> ans;
void dfs(pt v) {
	col[v.x][v.y] = 1;

	pt to = gr[v.x][v.y];
	
	if (col[to.x][to.y] == 1) {
		par[to.x][to.y] = to;
		cycle.push_back(to);
	}
	if (col[to.x][to.y] == 0)
		dfs(to);

	col[v.x][v.y] = 2;
	if (!(par[v.x][v.y] == v)) {
		par[v.x][v.y] = par[to.x][to.y];
	}
	if (tab[v.x][v.y] >= 'A' && tab[v.x][v.y] <= 'Z')
		num[par[v.x][v.y].x][par[v.x][v.y].y] ++;
}
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("outputGood.txt", "w", stdout);
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	
	cin >> n >> m >> g;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> tab[i][j];
			if (tab[i][j] == 'W' || tab[i][j] == 'w') {
				gr[i][j] = pt(i, j - 1);
			}
			if (tab[i][j] == 'N' || tab[i][j] == 'n') {
				gr[i][j] = pt(i - 1, j);
			}
			if (tab[i][j] == 'E' || tab[i][j] == 'e') {
				gr[i][j] = pt(i, j + 1);
			}
			if (tab[i][j] == 'S' || tab[i][j] == 's') {
				gr[i][j] = pt(i + 1, j);
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (col[i][j] == 0)
				dfs(pt(i, j));
		}
	}
	
	for (int i = 0; i < (int)cycle.size(); i++) {
		pt curr = cycle[i];
		curr.t = 1;
		//ans.clear();
		currAns = 1;
		//ans.push_back(curr);
		curr = pt(gr[curr.x][curr.y].x, gr[curr.x][curr.y].y, curr.t);
		while (!(curr == cycle[i])) {
			//ans.push_back(curr);
			currAns++;
			curr = pt(gr[curr.x][curr.y].x, gr[curr.x][curr.y].y, curr.t);
		}
		out += min(num[curr.x][curr.y], currAns);

	}

	cout << out << endl;
	if (!g)
		return 0;

	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].x << ' ' << ans[i].y << ' ' << ans[i].t << endl;
	}
} 