#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <stdio.h>
#include <cmath>
#include <map>
#include <time.h>
#include <cstdio>

using namespace std;

const int N = 1000;
char tab[N][N];
int color[N][N];
int mark[N][N];
int dx[] = { -1, 0, 1, 0 };
int dy[] = { 0, 1, 0, -1 };
vector <pair <int, int> > ans;

void dfs(int x, int y) {
	color[x][y] = 1;
	int xn = x + dx[tab[x][y] - '0'];
	int yn = y + dy[tab[x][y] - '0'];
	if (color[xn][yn] == 0) {
		dfs(xn, yn);
	}
	else if (color[xn][yn] == 1) {
		mark[xn][yn] = 1;
	}
	color[x][y] = 2;
}

void dfs1(int x, int y) {
	ans.push_back(make_pair(x, y));
	color[x][y] = 2;
	int xn = x + dx[tab[x][y] - '0'];
	int yn = y + dy[tab[x][y] - '0'];
	if (color[xn][yn] == 0) {
		dfs1(xn, yn);
	}
}

int main()
{
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	int n, m, g;
	cin >> n >> m >> g;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> tab[i][j];
			if (tab[i][j] == 'N' || tab[i][j] == 'n') {
				tab[i][j] = '0';
			}
			if (tab[i][j] == 'E' || tab[i][j] == 'e') {
				tab[i][j] = '1';
			}
			if (tab[i][j] == 'S' || tab[i][j] == 's') {
				tab[i][j] = '2';
			}
			if (tab[i][j] == 'W' || tab[i][j] == 'w') {
				tab[i][j] = '3';
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (color[i][j] == 0) {
				dfs(i, j);
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			color[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (mark[i][j] == 1) {
				dfs1(i, j);
			}
		}
	}

	cout << (int)ans.size() << endl;
	if (g == 1) {
		for (int i = 0; i < (int)ans.size(); i++) {
			cout << ans[i].first + 1 << " " << ans[i].second + 1 << " " << 1 << endl;
		}
	}
	//for (;;);
}

/*

3 4 1
SsSS
EEsW
EnwW

*/