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

using namespace std;

#define lint long long int

#define C 1005

int n, m, c;

char f[C][C];

int loop[C][C];
int modLoop[C][C];
int wh[C][C];
bool done[C][C];

int haveLoop;

map<char, pair<int, int>> dir;

int xS, yS;
set<pair<int, int>> curPath, s0;

vector<int> loopSize;
vector<int> cand;
vector<int> loopFill;

struct p1
{
	int x, y;
	int t;
};

vector<p1> ans;

bool cap(int x, int y)
{
	return f[x][y] == 'W' || f[x][y] == 'S' || f[x][y] == 'N' || f[x][y] == 'E';
}

void makeLoop(int x, int y, int ln, int xS, int yS, int curM = 0)
{
	//if (loop[x][y] != -1)
	/// return;
	//if (wh[x][y] != -1)
	//  return;
	loop[x][y] = wh[x][y] = ln;
	modLoop[x][y] = curM;
	loopSize[ln]++;
	if (cap(x, y))
		cand[ln]++;
	int x0, y0;
	x0 = x + dir[f[x][y]].first;
	y0 = y + dir[f[x][y]].second;
	if (x0 == xS && y0 == yS)
		return;
	makeLoop(x0, y0, ln, xS, yS, curM + 1);

	if (cap(x, y))
	{
		p1 p;
		p.x = x;
		p.y = y;
		p.t = loopFill[ln] + modLoop[x][y];
		while (p.t < 0)
			p.t += loopSize[ln];
		ans.push_back(p);
		loopFill[ln]++;
	}

}

void makeWay(int x, int y, int ln)
{
	if (loop[x][y] != -1)
		return;
	if (done[x][y])
		return;
	//if (wh[x][y] != -1)
	//  return;
	wh[x][y] = ln;
	if (cap(x, y)) {
		cand[ln]++;

	}
	int x0, y0;
	x0 = x + dir[f[x][y]].first;
	y0 = y + dir[f[x][y]].second;
	if (loop[x0][y0] == -1) {
		makeWay(x0, y0, ln);
		modLoop[x][y] = modLoop[x0][y0] - 1;
	}
	else
		modLoop[x][y] = modLoop[x0][y0] - 1;

	if (cap(x, y))
	{
		p1 p;
		p.x = x;
		p.y = y;
		p.t = loopFill[ln] + modLoop[x][y];
		while (p.t <= 0)
			p.t += loopSize[ln] + 100000;
		ans.push_back(p);
		loopFill[ln]++;
	}

	done[x][y] = 1;
}

void go(int x1, int y1)
{
	int x, y;
	x = x1, y = y1;

	while (1) {
		if (curPath.find(make_pair(x, y)) != curPath.end())
		{
			loopSize.push_back(0);
			cand.push_back(0);
			loopFill.push_back(0);
			makeLoop(x, y, haveLoop++, x, y);
			makeWay(xS, yS, haveLoop - 1);
			return;
		}

		int x0, y0;
		x0 = x + dir[f[x][y]].first;
		y0 = y + dir[f[x][y]].second;
		if (loop[x0][y0] == -1) {
			if (wh[x0][y0] == -1) {
				curPath.insert(make_pair(x, y));
				//go(x0, y0);
				x = x0;
				y = y0;
			}
			else {
				wh[x][y] = wh[x0][y0];
				makeWay(xS, yS, wh[x0][y0]);
				return;
			}
		}
		else
		{
			wh[x][y] = loop[x0][y0];
			loop[x][y] = -1;
			makeWay(xS, yS, loop[x0][y0]);   
			return;
		}
	}
}

int main()
{
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);

	cin >> n >> m >> c;

	haveLoop = 0;

	dir['w'] = dir['W'] = make_pair(0, -1);
	dir['e'] = dir['E'] = make_pair(0, 1);
	dir['n'] = dir['N'] = make_pair(-1, 0);
	dir['s'] = dir['S'] = make_pair(1, 0);

	vector<char> chars;
	chars.push_back('w');
	chars.push_back('W');
	chars.push_back('n');
	chars.push_back('N');
	chars.push_back('s');
	chars.push_back('S');
	chars.push_back('e');
	chars.push_back('E');

	srand(time(0));

	//for (int k = 0; k < 1000; k++) {

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) {
			cin >> f[i][j];
			//f[i][j] = chars[(rand() % 8)];
			loop[i][j] = -1;
			wh[i][j] = -1;
			done[i][j] = 0;
		}

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
		{
			curPath = s0;
			xS = i;
			yS = j;
			if (loop[i][j] == -1 && wh[i][j] == -1)
				go(i, j);
		}
	/*
	for (int i = 0; i < n; i++) {
	for (int j = 0; j < m; j++)
	{
	cout << f[i][j] << " ";
	}
	cout << endl;
	}

	cout << endl;

	for (int i = 0; i < n; i++) {
	for (int j = 0; j < m; j++)
	{
	cout << loop[i][j] << " ";
	}
	cout << endl;
	}

	cout << endl;

	for (int i = 0; i < n; i++) {
	for (int j = 0; j < m; j++)
	{
	cout << wh[i][j] << " ";
	}
	cout << endl;
	}

	cout << endl;

	for (int i = 0; i < loopSize.size(); i++)
	cout << loopSize[i] << " ";

	cout << endl;

	for (int i = 0; i < loopSize.size(); i++)
	cout << cand[i] << " ";

	cout << endl;


	for (int i = 0; i < n; i++) {
	for (int j = 0; j < m; j++)
	{
	cout << modLoop[i][j] << " ";
	}
	cout << endl;
	}

	cout << endl;
	
*/
	int res = 0;
	for (int i = 0; i < loopSize.size(); i++)
		res += min(cand[i], loopSize[i]);
	cout << res << endl;
	if (c)
	{

		for (int i = 0; i < min((int)ans.size(), res); i++)
			cout << ans[i].x + 1 << " " << ans[i].y + 1 << " " << ans[i].t << endl;
	}

	///}

}