#include <iostream>
#include <cstdio>
#include <set>
#include <vector>
#include <map>

using namespace std;

int tx[] = {-1, 1, 0, 0};
int ty[] = {0, 0, -1, 1};
vector<int> len;
vector<int> cnt;

int used[1000][1000];
int num[1000][1000];
int turn[1000][1000];
bool ex[1000][1000];

struct cyc
{
	int sx, sy;
	set<int> dos;
	int vnem;
	cyc(){}
};

vector<cyc> a;
vector<pair<pair<int, int>, int> > ans;

pair<int, int> dfs(int x, int y)
{
	if (used[x][y] > -1)
		return {used[x][y], num[x][y] + 1};
	if (used[x][y] == -2)
	{
		int num = a.size();
		int cx = x, cy = y;
		int cnt = 0;
		set<int> dd;
		int cnta = 0;
		do
		{
			dd.insert(cnt);
			cnt++;
			int ccx = cx;
			cx = cx + tx[turn[cx][cy]];
			cy = cy + ty[turn[ccx][cy]];
		}
		while (cx != x or cy != y);
		cyc tmp;
		tmp.sx = x;
		tmp.sy = y;
		tmp.vnem = cnta;
		tmp.dos = dd;
		a.push_back(tmp);
		return {num, 1};
	}
	used[x][y] = -2;
	pair<int, int> anss = dfs(x + tx[turn[x][y]], y + ty[turn[x][y]]);
	used[x][y] = anss.first;
	num[x][y] = anss.second;
	if (a[used[x][y]].dos.size() and ex[x][y])
	{
		ans.push_back({{x + 1, y + 1}, num[x][y] + *a[used[x][y]].dos.begin()});
		a[used[x][y]].dos.erase(a[used[x][y]].dos.begin());
	}
	return {anss.first, anss.second + 1};
}

int main()
{
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	int n, m, g;
	cin >> n >> m >> g;
	map<char, int> a;
	a['N'] = 0;
	a['n'] = 0;
	a['S'] = 1;
	a['s'] = 1;
	a['W'] = 2;
	a['w'] = 2;
	a['E'] = 3;
	a['e'] = 3;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			char c;
			cin >> c;
			turn[i][j] = a[c];
			used[i][j] = -1;
			if (c < 'Z')
			{
				ex[i][j] = 1;
			}
		}
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			if (used[i][j] == -1)
				dfs(i, j);
		}
	cout << ans.size() << endl;
	for (int i = 0; i < (int)ans.size() and g == 1; i++)
	{
		cout << ans[i].first.first << " " << ans[i].first.second << " " << ans[i].second + 1 << endl;
	}
}

