#include <bits/stdc++.h>
#define TASK "robots"

using namespace std;

typedef long long ll;
typedef pair < ll , ll > lpair;
const int DX[] = {1, 0,-1, 0};
const int DY[] = {0, 1, 0,-1};

const int N = 1179;

int n, m, ggg;
bool hr[N*N];
int dir[N][N], ans[N*N], dep[N*N];
int ansc = 0;

int vc, e[N*N];
vector < int > eb[N*N];

bool inloop[N*N], vis[N*N];
int cll, llen;

void dfs(int v, int cdep, int cr)
{
	vis[v] = true;
	dep[v] = cdep;
	if (hr[v] && cll != 0)
	{
		int ct = -(cdep + cll);
		if (ct < cr)
			ct += (cr-ct-1)/llen*llen+llen;
		cr = max(ct + 1, cr);
		ans[v] = ct;
		--cll;
		++ansc;
	}
	for (int nv : eb[v])
	{
		if (inloop[nv])
			continue;
		dfs(nv, cdep + 1, max(cr - 1, 1));
	}
}

int main()
{
#ifndef LOCAL
	freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);
#endif
	ios::sync_with_stdio(false);

	cin >> n >> m >> ggg;
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin >> s;
		for (int j = 0; j < m; ++j)
		{
			if (s[j] >= 'A' && s[j] <= 'Z')
			{
				hr[i*m+j] = true;
				s[j] = s[j] - 'A' + 'a';
			}
			switch (s[j])
			{
			case 's': dir[i][j] = 0; break;
			case 'e': dir[i][j] = 1; break;
			case 'n': dir[i][j] = 2; break;
			case 'w': dir[i][j] = 3; break;
			}
		}
	}

	vc = n*m;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
		{
			int v = i*m + j;
			int nv = (i+DX[dir[i][j]])*m + (j+DY[dir[i][j]]);
			e[v] = nv;
			eb[nv].push_back(v);
		}
	
	memset(ans, -1, sizeof(ans));
	for (int v = 0; v < vc; ++v)
	{
		if (vis[v])
			continue;
		int cv = v;
		while (!vis[cv])
		{
			vis[cv] = true;
			cv = e[cv];
		}
		int ncv = cv;
		llen = 0;
		do
		{
			inloop[ncv] = true;
			ncv = e[ncv];
			++llen;
		} while (cv != ncv);

		cll = llen;
		ncv = cv;
		int nn = llen;
		do
		{
			dfs(ncv, nn, 1);
			--nn;
			ncv = e[ncv];
		} while (cv != ncv);
	}
	cout << ansc << "\n";
	for (int i = 0; i < vc; ++i)
		if (ans[i] != -1)
			cout << i/m+1 << " " << i%m+1 << " " << ans[i] << "\n";


	return 0;
}
