//#include <iostream>
#include <fstream>
#include <algorithm>
#include <set>
#include <cstring>
//#include <cstdlib>

#define ll long long
using namespace std;

int n, m, **xWhere, **yWhere, nCycles, **whichCycle, **whichFutureCycle, **distInCycle, **distInFutureCycle, *sizeCycle, *usedResiduesCycle, ans, *ANS1, *ANS2, *ANS3;
pair <int, int> **Where, *Cycle;
int p, q;
set<pair<int, int> > visited;
bool **hasRobot, **usedInCycle;
ifstream cin;
ofstream cout;


int main()
{
	cin.open("robots.in");
	cout.open("robots.out");
	int g;
	cin >> n >> m >> g;
	hasRobot = new bool*[n] - 1;
	usedInCycle = new bool*[n] - 1;
	sizeCycle = new int[n * m + 10];
	ANS1 = new int[n * m + 10];
	ANS2 = new int[n * m + 10];
	ANS3 = new int[n * m + 10];
	Cycle = new pair<int, int>[n * m + 10];
	usedResiduesCycle = new int[n * m + 10];
	distInCycle = new int*[n] - 1;
	distInFutureCycle = new int*[n] - 1;
	xWhere = new int*[n] - 1;
	yWhere = new int*[n] - 1;
	whichCycle = new int*[n] - 1;
	whichFutureCycle = new int*[n] - 1;
	distInCycle = new int*[n] - 1;
	Where = new pair<int, int>*[n] - 1;
	int i, j, k;
	for (i = 1; i <= n; ++i)
	{
		hasRobot[i] = new bool[m] - 1;
		usedInCycle[i] = new bool[m] - 1;
		whichCycle[i] = new int[m] - 1;
		whichFutureCycle[i] = new int[m] - 1;
		xWhere[i] = new int[m] - 1;
		yWhere[i] = new int[m] - 1;
		Where[i] = new pair<int, int>[m] - 1;
		distInCycle[i] = new int[m] - 1;
		distInFutureCycle[i] = new int[m] - 1;
		for (j = 1; j <= m; ++j)
			usedInCycle[i][j] = false;
	}
	char* c;
	c = new char[m + 1];
	cin.getline(c, m + 1);
	--c;
	for (i = 1; i <= n; ++i)
	{
		cin.getline(c + 1, m + 1);
		for (j = 1; j <= m; ++j)
		{
			if (c[j] >= 'a')
			{
				hasRobot[i][j] = false;
				c[j] -= 32;
			}
			else
				hasRobot[i][j] = true;
			if (c[j] == 'N')
			{
				xWhere[i][j] = 0;
				yWhere[i][j] = -1;
			}
			else if (c[j] == 'W')
			{
				xWhere[i][j] = -1;
				yWhere[i][j] = 0;
			}
			else if (c[j] == 'E')
			{
				xWhere[i][j] = 1;
				yWhere[i][j] = 0;
			}
			else if (c[j] = 'S')
			{
				xWhere[i][j] = 0;
				yWhere[i][j] = 1;
			}
			Where[i][j] = pair<int, int>(i + yWhere[i][j], j + xWhere[i][j]);
		}
	}
	nCycles = 0;
	pair<int, int> *ourPath, ourCell;
	pair<int, int>*** ourFuture;
	ourFuture = new pair<int, int>**[30];
	for (k = 0; k < 30; ++k)
	{
		ourFuture[k] = new pair<int, int>*[n] - 1;
		for (i = 1; i <= n; ++i)
			ourFuture[k][i] = new pair<int, int>[m] - 1;
	}
	for (i = 1; i <= n; ++i)
		for (j = 1; j <= m; ++j)
			ourFuture[0][i][j] = Where[i][j];
	for (k = 1; k < 30; ++k)
		for (i = 1; i <= n; ++i)
			for (j = 1; j <= m; ++j)
			{
				p = ourFuture[k - 1][i][j].first;
				q = ourFuture[k - 1][i][j].second;
				//cout << i << ' ' << j << ' ' << p << ' ' << q << ' ' << endl;
				pair <int, int> r = ourFuture[k - 1][p][q];
				ourFuture[k][i][j] = r;
			}
	nCycles = 0;
	int l, z;
	ans = 0;
	for (i = 1; i <= n; ++i)
		for (j = 1; j <= m; ++j)
		{
			*Cycle = ourFuture[29][i][j];
			if (visited.find(*Cycle) == visited.end())
			{
				sizeCycle[nCycles] = 1;
				usedResiduesCycle[nCycles] = 0;
				k = 0;
				while (Where[(Cycle + k)->first][(Cycle + k)->second] != *Cycle)
				{
					++k;
					Cycle[k] = Where[(Cycle + k - 1)->first][(Cycle + k - 1)->second];
				}
				for (l = 0; l <= k; ++l)
				{
					distInFutureCycle[(Cycle + l)->first][(Cycle + l)->second] = k + 1 - l;
					whichFutureCycle[(Cycle + l)->first][(Cycle + l)->second] = nCycles;
					visited.insert(Cycle[l]);
				}
				distInFutureCycle[Cycle->first][Cycle->second] = 0;
				sizeCycle[nCycles] = k + 1;
				++nCycles;
			}
			z = whichFutureCycle[Cycle->first][Cycle->second];
			//cout << z << endl;
			if ((usedResiduesCycle[z] < sizeCycle[z]) && (hasRobot[i][j]))
			{
				usedInCycle[i][j] = true;
				ANS1[ans] = i;
				ANS2[ans] = j;
				ANS3[ans] = (usedResiduesCycle[z] - distInFutureCycle[Cycle->first][Cycle->second] + sizeCycle[z]) % sizeCycle[z] + 1;
				++usedResiduesCycle[z];
				++ans;
			}
		}
	cout << ans << endl;
	if (g)
	{
		for (i = 0; i < ans; ++i)
			cout << ANS1[i] << ' ' << ANS2[i] << ' ' << ANS3[i] << endl;
	}

	//for (i = 0; i < nCycles; ++i)
		//cout << ANS3[i] << ' ' << sizeCycle[i] << ' ' << usedResiduesCycle[i] << endl;
//	system("pause");
	return 0;
}