#pragma comment(linker, "/STACK:1000000000")
#include <algorithm>
#include <string>
#include <fstream>
#include <iostream>
#include <vector>

using namespace std;

vector<vector<int>> matr;

vector<vector<int>> dist;

vector<vector<int>> len;

vector<vector<pair<int, int>>> cyc_beg;

vector<vector<bool>> used;

pair<int, int> v = { -1, -1 };

vector<int> DX = { 0, 1, 0, -1 };
vector<int> DY = { 1, 0, -1, 0 };

int tak_sebe_dfs(int x, int y)
{
	if (used[x][y])
	{
		v = cyc_beg[x][y];
		return 0;
	}
	used[x][y] = true;

	int x1 = x + DX[matr[x][y]], y1 = y + DY[matr[x][y]];
	dist[x][y] = tak_sebe_dfs(x1, y1) + 1;
	cyc_beg[x][y] = v;
	if (x == v.first && y == v.second)
		len[x][y] = dist[x][y], dist[x][y] = 0;
	return dist[x][y];;
}

int main()
{
	ifstream cin("robots.in");
	ofstream cout("robots.out");
	int n, m, g; cin >> n >> m >> g;
	len = dist = matr = vector<vector<int>>(n, vector<int>(m));
	used = vector<vector<bool>>(n, vector<bool>(m));
	cyc_beg = vector<vector<pair<int, int>>>(n, vector<pair<int, int>>(m));
	vector<pair<int, int>> rob;
	for (int i = 0; i < n; ++i)
	{
		string s; cin >> s;
		for (int j = 0; j < m; ++j)
		{
			if ('A' <= s[j] && s[j] <= 'Z')
				rob.push_back({ i, j }), s[j] += 'a' - 'A';
			if (s[j] == 'n')
				matr[i][j] = 3;
			if (s[j] == 's')
				matr[i][j] = 1;
			if (s[j] == 'e')
				matr[i][j] = 0;
			if (s[j] == 'w')
				matr[i][j] = 2;
			cyc_beg[i][j] = { i, j };
		}
	}
	for (auto& x : rob)
		if (!used[x.first][x.second])
			tak_sebe_dfs(x.first, x.second);
	vector<vector<vector<pair<int, int>>>> to(n, vector<vector<pair<int, int>>>(m));
	for (auto& x : rob)
		to[cyc_beg[x.first][x.second].first][cyc_beg[x.first][x.second].second].push_back({ x.first, x.second });
	int k = 0;
	vector<vector<int>> ans;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
		{
			if (to[i][j].size() == 0)
				continue;
			k += min((int)to[i][j].size(), len[i][j]);
			for (int l = 0; l < min((int)to[i][j].size(), len[i][j]); ++l)
				ans.push_back({ to[i][j][l].first, to[i][j][l].second, 100000000 + l - dist[to[i][j][l].first][to[i][j][l].second] });
		}
	cout << k << endl;
	if (g)
		for (auto& x : ans)
			cout << x[0] + 1 << ' ' << x[1] + 1 << ' ' << x[2] << endl;

}