#include <bits/stdc++.h>
using namespace std;

int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};

int h, w, g;
vector<string> a;
vector<vector<int>> col, dtogood;
vector<vector<bool>> used;
int cc = 1;

int dec(char c) {
	if (c == 'W' || c == 'w') return 0;
	if (c == 'E' || c == 'e') return 1;
	if (c == 'N' || c == 'n') return 2;
	return 3;
}

int dfs(int x, int y) {
	used[x][y] = true;
	int d = dec(a[x][y]);
	int xx = x + dx[d];
	int yy = y + dy[d];
	if (col[xx][yy] != 0) {
		col[x][y] = col[xx][yy];
		return col[x][y];
	}
	if (used[xx][yy]) {
		dtogood[xx][yy] = 0;
		col[x][y] = cc++;
		return col[x][y];
	}
	col[x][y] = dfs(xx, yy);
	return col[x][y];
}

int dfs1(int x, int y) {
	if (dtogood[x][y] != -1) {
		return dtogood[x][y];
	}
	int d = dec(a[x][y]);
	int xx = x + dx[d];
	int yy = y + dy[d];
	dtogood[x][y] = dfs1(xx, yy) + 1;
	return dtogood[x][y];
}

int main() {
	freopen("robots.in", "r", stdin);
	#ifndef DEBUG
	freopen("robots.out", "w", stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> h >> w >> g;
	a.resize(h);
	for (int i = 0; i < h; i++) {
		cin >> a[i];
	}
	col.resize(h);
	used.resize(h);
	dtogood.resize(h);
	for (int i = 0; i < h; i++) {
		col[i].resize(w);
		used[i].resize(w);
		dtogood[i].resize(w);
		fill(dtogood[i].begin(), dtogood[i].end(), -1);
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (col[i][j] == 0) {
				dfs(i, j);
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			dfs1(i, j);
		}
	}
	/*
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << col[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << dtogood[i][j] << " ";
		}
		cout << endl;
	}
	*/
	vector<vector<pair<int, int>>> robs(cc);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if ('A' <= a[i][j] && a[i][j] <= 'Z') {
				robs[col[i][j]].push_back({dtogood[i][j], i * w + j});
			}
		}
	}
	
	vector<int> cap(cc);
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (dtogood[i][j] == 0) {
				int x = i;
				int y = j;
				int d = dec(a[i][j]);
				x += dx[d];
				y += dy[d];
				int cnt = 1;
				while (x != i || y != j) {
					int d = dec(a[x][y]);
					x += dx[d];
					y += dy[d];
					cnt++;
				}
				
				cap[col[i][j]] = cnt;
			}
		}
	}
	
	for (int i = 1; i < cc; i++) {
		sort(robs[i].begin(), robs[i].end());
	}
	
	vector<vector<int>> t(h, vector<int> (w, -1));
	
	for (int i = 1; i < cc; i++) {
		set<int> freemods;
		for (int j = 0; j < cap[i]; j++) {
			freemods.insert(j);
		}
		for (int j = 0; j < robs[i].size() && j < cap[i]; j++) {
			auto it = freemods.lower_bound(robs[i][j].first % cap[i]);
			if (it == freemods.end()) {
				it = freemods.begin();
			}
			int newt = *it;
			freemods.erase(it);
			int addt = newt - robs[i][j].first % cap[i];
			if (addt < 0) {
				addt += cap[i];
			}
			int x = robs[i][j].second / w;
			int y = robs[i][j].second % w;
			t[x][y] = addt;
		}
	}
	/*
	cout << endl;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << t[i][j] << " ";
		}
		cout << endl;
	}
	*/
	
	int k = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (t[i][j] != -1) {
				k++;
			}
		}
	}
	cout << k << endl;
	
	if (g == 1) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (t[i][j] != -1) {
					cout << i + 1 << ' ' << j + 1 << ' ' << t[i][j] + 1 << '\n';
				}
			}
		}
	}
	
	return 0;
}
