#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef pair<int, int> p;
const int lim = 1001;
const int offset[4][2] = { { 0, 1 },{ 1, 0 },{ 0, -1 },{ -1, 0 } };

int min(int a, int b) {
	return (a < b ? a : b);
}

int dir[lim][lim];
bool robot[lim][lim];
bool been[lim][lim];
int loopind[lim][lim];
int looplen[lim * lim / 2];
int loopsize[lim * lim / 2];
int loopcap[lim * lim / 2];
int loopcur[lim * lim / 2];
int dist[lim][lim];
int loops = 0;
int curloop;
int stopi, stopj;
bool stop;

void dfs(int i, int j) {
	been[i][j] = true;
	int i2 = i + offset[dir[i][j]][0];
	int j2 = j + offset[dir[i][j]][1];
	if (been[i2][j2]) {
		if (loopind[i2][j2]) {
			curloop = loopind[i2][j2] - 1;
			loopind[i][j] = loopind[i2][j2];
			dist[i][j] = dist[i2][j2] + 1;
			if (robot[i][j])
				++loopsize[curloop];
			stop = true;
		}
		else {
			curloop = loops;
			++loops;
			loopind[i][j] = curloop + 1;
			dist[i][j] = 0;
			stopi = i2;
			stopj = j2;
			++looplen[curloop];
			if (robot[i][j])
				++loopsize[curloop];
			stop = false;
		}
	}
	else {
		dfs(i2, j2);
		loopind[i][j] = curloop + 1;
		dist[i][j] = dist[i2][j2] + 1;
		if (robot[i][j])
			++loopsize[curloop];
		if (!stop) {
			++looplen[curloop];
			stop = i == stopi && j == stopj;
		}
	}
}

int main() {
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	int n, m, g, i, j;
	char c;
	scanf("%d %d %d", &n, &m, &g);
	for (i = 0; i < n; ++i) {
		scanf("\n");
		for (j = 0; j < m; ++j) {
			scanf("%c", &c);
			switch (c) {
			case 'E': dir[i][j] = 0; robot[i][j] = true; break;
			case 'S': dir[i][j] = 1; robot[i][j] = true; break;
			case 'W': dir[i][j] = 2; robot[i][j] = true; break;
			case 'N': dir[i][j] = 3; robot[i][j] = true; break;
			case 'e': dir[i][j] = 0; robot[i][j] = false; break;
			case 's': dir[i][j] = 1; robot[i][j] = false; break;
			case 'w': dir[i][j] = 2; robot[i][j] = false; break;
			case 'n': dir[i][j] = 3; robot[i][j] = false; break;
			}
		}
	}
	for (i = 0; i < n; ++i)
		for (j = 0; j < m; ++j)
			if (!been[i][j])
				dfs(i, j);
	int res = 0;
	for (i = 0; i < loops; ++i) {
		res += min(loopsize[i], looplen[i]);
	}
	printf("%d\n", res);
	if (!g)
		return 0;
	for (i = 0; i < loops; ++i)
		loopcap[i] = looplen[i];
	for (i = 0; i < n; ++i)
		for (j = 0; j < m; ++j) {
			int ind = loopind[i][j] - 1;
			if (robot[i][j] && loopcap[ind]) {
				--loopcap[ind];
				printf("%d %d ", i + 1, j + 1);
				printf("%d\n", (((loopcur[ind]++) - dist[i][j]) % looplen[ind] + looplen[ind]) % looplen[ind] + 1);
			}
		}
	return 0;
}