import java.io.*;
import java.util.*;

public class b1 {
	String fileName = "robots";

	static int dx[] = { 1, 0, -1, 0 };
	static int dy[] = { 0, 1, 0, -1 };
	static int a[][];
	static int color[][];
	static int curx[];
	static int cury[];
	static int topx;
	static int topy;

	static int len[][];
	static int val[][];
	static int number[][];
	static int cnt;
	static int count[];
	static long mod[][];
	static boolean oncicle[][];
	static int tocicle[][];

	static long time[][];

	static void add(int x, int y) {
		curx[topx] = x;
		topx++;
		cury[topy] = y;
		topy++;
	}

	static void dfs(int x, int y, int value) {
		color[x][y] = 0;
		val[x][y] = value;
		add(x, y);

		int nextx = x + dx[a[x][y]];
		int nexty = y + dy[a[x][y]];

		if (color[nextx][nexty] == 0) {
			count[cnt] = val[x][y] - val[nextx][nexty] + 1;

			boolean fl = true;

			while (topx > 0) {
				number[curx[topx - 1]][cury[topy - 1]] = cnt;
				int ln = val[x][y] - val[nextx][nexty] + 1;
				mod[curx[topx - 1]][cury[topy - 1]] = topx % ln;
				len[curx[topx - 1]][cury[topy - 1]] = ln;
				oncicle[curx[topx - 1]][cury[topy - 1]] = fl;

				if (curx[topx - 1] == nextx && cury[topy - 1] == nexty) {
					fl = false;
				}

				topx--;
				topy--;

			}

			cnt++;
		} else if (color[nextx][nexty] == -1) {
			dfs(nextx, nexty, value + 1);
			len[x][y] = len[nextx][nexty];
			number[x][y] = number[nextx][nexty];
		} else {
			len[x][y] = len[nextx][nexty];
			number[x][y] = number[nextx][nexty];
		}

		if (mod[x][y] == -1) {
			mod[x][y] = (mod[nextx][nexty] - 1 + len[x][y]) % len[x][y];
		}

		color[x][y] = 1;
	}

	static void dfs1(int x, int y) {
		color[x][y] = 0;

		int nextx = x + dx[a[x][y]];
		int nexty = y + dy[a[x][y]];

		if (oncicle[nextx][nexty]) {
			tocicle[x][y] = 1;
		} else {
			if (color[nextx][nexty] == -1) {
				dfs1(nextx, nexty);
			}

			tocicle[x][y] = tocicle[nextx][nexty] + 1;
		}

		color[x][y] = 1;
	}

	public void solve() throws IOException {
		int n = nextInt();
		int m = nextInt();
		int g = nextInt();
		cnt = 0;

		a = new int[n][m];
		mod = new long[n][m];
		color = new int[n][m];
		len = new int[n][m];
		curx = new int[n * m];
		cury = new int[n * m];
		topx = 0;
		topy = 0;
		val = new int[n][m];
		number = new int[n][m];
		count = new int[n * m];
		oncicle = new boolean[n][m];
		tocicle = new int[n][m];
		time = new long[n][m];
		
		boolean robot[][] = new boolean[n][m];

		for (int i = 0; i < n; i++) {
			String s = nextToken();
			Arrays.fill(mod[i], -1);
			Arrays.fill(color[i], -1);

			for (int j = 0; j < m; j++) {
				if (s.charAt(j) == 's' || s.charAt(j) == 'S') {
					a[i][j] = 0;
				}
				if (s.charAt(j) == 'e' || s.charAt(j) == 'E') {
					a[i][j] = 1;
				}
				if (s.charAt(j) == 'n' || s.charAt(j) == 'N') {
					a[i][j] = 2;
				}
				if (s.charAt(j) == 'w' || s.charAt(j) == 'W') {
					a[i][j] = 3;
				}

				if (s.charAt(j) >= 'A' && s.charAt(j) <= 'Z') {
					robot[i][j] = true;
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (color[i][j] == -1) {
					dfs(i, j, 0);
					topx = 0;
					topy = 0;
				}
			}
		}

		if (g == 0) {
			long ans = 0;

			for (int x = 0; x < n; x++) {
				for (int y = 0; y < m; y++) {
					if (robot[x][y] && count[number[x][y]] > 0) {
						ans++;
						count[number[x][y]]--;
					}
				}
			}

			out.println(ans);
		} else {
			for (int i = 0; i < n; i++) {
				Arrays.fill(time[i], -1);
			}
			
			int md[] = new int[n * m];

			int max[] = new int[cnt];
			boolean used[][] = new boolean[cnt][];
			
			for (int i = 0; i < cnt; i++) {
				used[i] = new boolean[count[i]];
			}
			
			long ans = 0;
			
			for (int x = 0; x < n; x++) {
				Arrays.fill(color[x], -1);
				for (int y = 0; y < m; y++) {
					if (robot[x][y] && count[number[x][y]] > 0) {
						if (oncicle[x][y]){
							time[x][y] = 0;
							ans++;
							count[number[x][y]]--;
							used[number[x][y]][(int) mod[x][y]] = true;
						}
					}
				}
			}
			
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (!oncicle[i][j] && color[i][j] == -1) {
						dfs1(i, j);
					}
				}
			}
			
			for (int x = 0; x < n; x++) {
				for (int y = 0; y < m; y++) {
					if (robot[x][y] && count[number[x][y]] > 0) {
						if (!oncicle[x][y]){
							while (used[number[x][y]][max[number[x][y]]]){
								max[number[x][y]]++;
							}
							
							time[x][y] = 1l * tocicle[x][y] * len[x][y] + len[x][y] - mod[x][y] + max[number[x][y]];
							used[number[x][y]][max[number[x][y]]] = true;
							ans++;
							count[number[x][y]]--;
						}
					}
				}
			}

			out.println(ans);
			
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < m; j++) {
					if (time[i][j] != -1){
						out.println((i + 1) + " " + (j + 1) + " " + (time[i][j] + 1));
					}
				}
			}
			
		}
	}

	public void run() {
		try {
			br = new BufferedReader(new FileReader(fileName + ".in"));
			out = new PrintWriter(fileName + ".out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	BufferedReader br;
	StringTokenizer in;
	PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	public static void main(String[] args) throws IOException {
		Locale.setDefault(Locale.US);
		new b1().run();
	}

}