#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <stdio.h>
using namespace std;

int f_y, f_x, cnt, flag; //0 - нет, 1 - будет, 2 - было 
int k;

void dfs(vector< vector< pair<int, int> > > &mat, vector< vector<int> > &cycle, vector< vector<int> > &tim, int &c, int y, int x) {
	cycle[y][x] = c;
	pair<int, int> p = mat[y][x];
	if (cycle[p.first][p.second] == -1) {
		dfs(mat, cycle, tim, c, p.first, p.second);
	} else if (cycle[p.first][p.second] != c) {
		c = cycle[p.first][p.second];
		flag = 2;
		k = tim[p.first][p.second] + 1;
	} else {
		f_y = p.first;
		f_x = p.second;
		tim[y][x] = 1;
		k = 2;
		flag = 1;
		cnt++;
		return;
	}
	if ((f_y == y) && (f_x == x) && (flag == 1)) {
		tim[y][x] = 0;
		k = 1;
		flag = 2;
		cnt++;
		return;
	}
	if (flag == 1) {
		cnt++;
		tim[y][x] = k;
		k++;
	}
	if (flag == 2) {
		tim[y][x] = k;
		k++;
	}
	cycle[y][x] = c;
	return;
}

int main() {
	freopen("robots.in", "r", stdin);
	freopen("robots.out", "w", stdout);
	int n, m, g;
	scanf("%d%d%d", &n, &m, &g);
	vector< vector< pair<int, int> > > mat(n, vector< pair<int, int> >(m));
	vector< vector<bool> > rob(n, vector<bool>(m, false));
	vector< vector<int> > cycle(n, vector<int>(m, -1));
	vector< vector<int> > tim(n, vector<int>(m, -1));
	char u;
	scanf("%c", &u);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			char w;
			scanf("%c", &w);
			if (w < 'a') {
				w = (char) ((int) w + 32);
				rob[i][j] = true;
			}
			if (w == 'n') {
				mat[i][j] = { i - 1, j };
			} else if (w == 'e') {
				mat[i][j] = { i, j + 1 };
			} else if (w == 's') {
				mat[i][j] = { i + 1, j };
			} else {
				mat[i][j] = { i, j - 1 };
			}
		}
		scanf("%c", &u);
	}


	int c = 0;
	vector<int> ver, ver_del;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (cycle[i][j] == -1) {
				int c1 = c;
				cnt = 0;
				f_y = -1;
				f_x = -1;
				flag = 0;
				k = 0;
				dfs(mat, cycle, tim, c1, i, j);
				if (c1 == c) {
					ver.push_back(cnt);
					c++;
				}
			}
		}
	}
	ver_del = ver;
	vector< set<int> > close(ver.size(), set<int> ());
	int sum = 0;
	vector< pair< pair<int, int> , int> > ans;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (rob[i][j]) {
				int r = cycle[i][j];
				if (ver_del[r] > 0) {
					//rob[i][j] = false;
					ver_del[r]--;;
					sum++;
					int e = 1;
					int g = tim[i][j];
					while (close[r].find((e + g - 1) % ver[r]) != close[r].end()) {
						e++;
					}
					close[r].insert((e + g) % ver[r]);
					ans.push_back({{i, j}, e});
				}
			}
		}
	}
	cout << sum << endl;

	if (g == 1) {
		for (int i = 0; i < (int)ans.size(); i++) {
			cout << ans[i].first.first + 1<< " " << ans[i].first.second + 1 << " " << ans[i].second << endl;
		}
	}
	return 0;
}