#define _CRT_SECURE_NO_WARNINGS
#include<cstdio>
#include<algorithm>
#include<set>
#include<cassert>
#include<vector>
using namespace std;
char a[1007][1007];
bool was[1007][1007];
bool wasColor[1007 * 1007];
int color[1007][1007];
int haveRobots[1007 * 1007];
int haveColor[1007 * 1007];
int cycleLen[1007 * 1007];
int distToCycle[1007][1007];
int colCnt = 0;
vector<pair<int, int> >onColor[1007 * 1007];
void goStep(int& x, int &y)
{
	if (a[x][y] == 'S' || a[x][y] == 's')
	{
		x++;
	}
	else if (a[x][y] == 'N' || a[x][y] == 'n')
	{
		x--;
	}
	else if (a[x][y] == 'E' || a[x][y] == 'e')
	{
		y++;
	}
	else
	{
		y--;
	}
}
void go(int x, int y)
{
	if (was[x][y])
	{
		if (color[x][y] == 0)
		{
			colCnt++;
			color[x][y] = colCnt;
			distToCycle[x][y] = 0;
		}
		return;
	}
	was[x][y] = true;
	int nx = x, ny = y;
	goStep(nx, ny);
	go(nx, ny);
	color[x][y] = color[nx][ny];
}
void go2(int x, int y)
{
	if (distToCycle[x][y] != -1) return;
	int nx = x, ny = y;
	goStep(nx, ny);
	go2(nx, ny);
	distToCycle[x][y] = distToCycle[nx][ny] + 1;
}
int main()
{
	//  freopen("input.txt", "r", stdin);
	//  freopen("output.txt", "w", stdout);
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	int n, m, g;
	scanf("%d %d %d", &n, &m, &g);
	for (int i = 1; i <= n; i++)
	{
		scanf("%s", a[i]);
		for (int j = m; j >= 1; j--)
		{
			a[i][j] = a[i][j - 1];
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			distToCycle[i][j] = -1;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (!was[i][j]) go(i, j);
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			go2(i, j);
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			was[i][j] = false;
			haveColor[color[i][j]]++;
			if (a[i][j] >= 'A' && a[i][j] <= 'Z')
			{
				haveRobots[color[i][j]]++;
			}
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (!wasColor[color[i][j]])
			{
				wasColor[color[i][j]] = true;
				int x = i, y = j;
				int sz = haveColor[color[i][j]];
				for (int k = 1; k <= sz; k++)
				{
					goStep(x, y);
				}
				while (!was[x][y])
				{
					cycleLen[color[x][y]]++;
					was[x][y] = true;
					goStep(x, y);
				}
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= colCnt; i++)
	{
		ans += min(haveRobots[i], cycleLen[i]);
	}
	printf("%d\n", ans);
	if (g == 0) return 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (a[i][j] >= 'A' && a[i][j] <= 'Z')
			{
				onColor[color[i][j]].push_back(make_pair(i, j));
			}
		}
	}
	for (int i = 1; i <= colCnt; i++)
	{
		int take = min(haveRobots[i], cycleLen[i]);
		for (int j = 0; j < take; j++)
		{
			int x = onColor[i][j].first, y = onColor[i][j].second;
			int curLen = distToCycle[x][y];
			int modTime = (j - curLen + 1000 * cycleLen[i]) % cycleLen[i];
			assert(2 * cycleLen[i] * (j + 1) + modTime <= 1000 * 1000 * 1000);
			printf("%d %d %d\n", x, y, 2 * cycleLen[i] * (j + 1) + modTime);
		}
	}

}