#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

struct pt
{
	int dist;
	int len;
	int num;
	int T;
	int dx, dy;
	int tick;
	int time;
};
int n, m, g, num;
pt field[1000][1000];
int cyc[2000000];
int lns[2000000];

void input()
{
	string s;
	cin >> n >> m >> g;
	for (int i = 0; i < n; ++i)
	{
		do {
			cin >> s;
		} while (s.size() < m);
		for (int j = 0; j < m; ++j)
		{
			field[i][j].dist = -1;
			if (s[j] == 'N')
			{
				field[i][j].dx = 0;
				field[i][j].dy = -1;
				field[i][j].T = 1;
			}
			else if (s[j] == 'E')
			{
				field[i][j].dx = 1;
				field[i][j].dy = 0;
				field[i][j].T = 1;
			}
			else if (s[j] == 'S')
			{
				field[i][j].dx = 0;
				field[i][j].dy = 1;
				field[i][j].T = 1;
			}
			else if (s[j] == 'W')
			{
				field[i][j].dx = -1;
				field[i][j].dy = 0;
				field[i][j].T = 1;
			}
			else if (s[j] == 'n')
			{
				field[i][j].dx = 0;
				field[i][j].dy = -1;
				field[i][j].T = 0;
			}
			else if (s[j] == 'e')
			{
				field[i][j].dx = 1;
				field[i][j].dy = 0;
				field[i][j].T = 0;
			}
			else if (s[j] == 's')
			{
				field[i][j].dx = 0;
				field[i][j].dy = 1;
				field[i][j].T = 0;
			}
			else if (s[j] == 'w')
			{
				field[i][j].dx = -1;
				field[i][j].dy = 0;
				field[i][j].T = 0;
			}
		}
	}
}

void rec(int x, int y, int tick = 1)
{
	field[x][y].dist = -2;
	field[x][y].tick = tick;
	int nx = x + field[x][y].dy;
	int ny = y + field[x][y].dx;
	if (field[nx][ny].dist == -2)
	{
		num += 1;
		field[x][y].num = num;
		field[x][y].dist = 0;
		field[x][y].len = tick - field[nx][ny].tick + 1;
		return;
	}
	if (field[nx][ny].dist == -1)
		rec(nx, ny, tick + 1);
	field[x][y].dist = field[nx][ny].dist + 1;
	field[x][y].len = field[nx][ny].len;
	field[x][y].num = field[nx][ny].num;
}

int main()
{
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	input();
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			if (field[i][j].dist == -1)
				rec(i, j);
	int ans = 0;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
		{
			int nmc = field[i][j].num;
			lns[nmc] = field[i][j].len;
			if (field[i][j].T == 1 && cyc[nmc] < lns[nmc])
			{
				field[i][j].time = 100000000 - field[i][j].dist + cyc[nmc];
				cyc[nmc]++;
				ans++;
			}
			else
				field[i][j].time = -1;
		}
	printf("%d\n", ans);
	if (g == 1)
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			if (field[i][j].time != -1)
				printf("%d %d %d\n", i + 1, j + 1, field[i][j].time + 1);
	n = n;
	return 0;
}