

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class B {
	public static StringTokenizer st;
	public static BufferedReader in;
	public static PrintWriter out;
	public static String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}
	public static int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}
	public static class Data {
		public boolean cycleNow;
		public int fn, tta;
		public Data(boolean cycleNow, int fn, int tta) {
			this.cycleNow = cycleNow;
			this.fn = fn;
			this.tta = tta;
		}
		
	}
	public static class Robot implements Comparable<Robot> {
		public final int t, i;

		public Robot(int t, int i) {
			this.t = t;
			this.i = i;
		}

		@Override
		public int compareTo(Robot o) {
			return	Integer.compare(t, o.t) != 0 ?
					Integer.compare(t, o.t) :
					Integer.compare(i, o.i);
		}
		
	}
	public static final int[] DIR_X = {0, 1, 0, -1};
	public static final int[] DIR_Y = {1, 0, -1, 0};
	public static Data dfs(	int x, int y,
							int[][] g, int[][] v, 
							int[][] cn, int[][] fc,
							int[][] tta,
							ArrayList<Integer> cpx,
							ArrayList<Integer> cpy,
							ArrayList<Integer> cl) {
		int n = v.length, m = v[0].length;
		if (x >= n || y >= m || x < 0 || y < 0) {
			return new Data(false, -1, -1);
		}
		if (v[x][y] == 2) {
			return new Data(false, fc[x][y], tta[x][y]);
		}
		if (v[x][y] == 1) {
			v[x][y] = 2;
			int fn = cl.size();
			cl.add(1);
			cpx.add(x);
			cpy.add(y);
			cn[x][y] = fn;
			fc[x][y] = fn;
			tta[x][y] = 0;
			return new Data(true, fn, 0);
		}
		v[x][y] = 1;
		Data d = dfs(x + DIR_X[g[x][y]], y + DIR_Y[g[x][y]], g, v, cn, fc, tta, cpx, cpy, cl);
		if (d.cycleNow) {
			if (v[x][y] == 2) {
				cn[x][y] = d.fn;
				fc[x][y] = d.fn;
				tta[x][y] = 0;
				return new Data(false, d.fn, 0);
			}
			cl.set(d.fn, cl.get(d.fn) + 1);
			cn[x][y] = d.fn;
			fc[x][y] = d.fn;
			tta[x][y] = d.tta + 1;
			v[x][y] = 2;
			return new Data(true, d.fn, d.tta + 1);
		}
		cn[x][y] = -1;
		fc[x][y] = d.fn;
		tta[x][y] = d.tta + 1;
		v[x][y] = 2;
		return new Data(false, d.fn, d.tta + 1);
	}
	public static void main(String[] args) throws IOException {
		boolean test = false;
		String fileName = "robots";
		if (test) {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
		} else {
			in = new BufferedReader(new FileReader(fileName + ".in"));
			out = new PrintWriter(fileName + ".out");
		}
		int n = nextInt();
		int m = nextInt();
		boolean r = nextInt() == 1;
		int[][] g = new int[n][m];
		int[][] v = new int[n][m];
		int[][] fc = new int[n][m];
		int[][] cn = new int[n][m];
		int[][] tta = new int[n][m];
		ArrayList<Integer> rx = new ArrayList<>();
		ArrayList<Integer> ry = new ArrayList<>();
		ArrayList<Integer> rt = new ArrayList<>();
		ArrayList<Integer> cpx = new ArrayList<>();
		ArrayList<Integer> cpy = new ArrayList<>();
		ArrayList<Integer> cl = new ArrayList<>();
		int rs = 0;
		ArrayList<TreeSet<Robot>> rc = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			char[] s = nextToken().toCharArray();
			for (int j = 0; j < s.length; j++) {
				if (Character.getType(s[j]) == Character.UPPERCASE_LETTER) {
					rx.add(i);
					ry.add(j);
					rt.add(-1);
					rs++;
					s[j] = Character.toLowerCase(s[j]);
				}
				switch (s[j]) {
				case 'n':
					g[i][j] = 3;
					break;
				case 's':
					g[i][j] = 1;
					break;
				case 'e':
					g[i][j] = 0;
					break;
				case 'w':
					g[i][j] = 2;
					break;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				dfs(i, j, g, v, cn, fc, tta, cpx, cpy, cl);
			}
		}
		for (@SuppressWarnings("unused") int i : cl) {
			rc.add(new TreeSet<>());
		}
		for (int i = 0; i < rs; i++) {
			int x = rx.get(i);
			int y = ry.get(i);
			rc.get(fc[x][y]).add(new Robot(tta[x][y], i));
		}
		for (int i = 0; i < cl.size(); i++) {
			int k = 0;
			for (Robot j : rc.get(i)) {
				if (k >= cl.get(i)) {
					break;
				}
				rt.set(j.i, (k + cl.get(i) - j.t % cl.get(i)) % cl.get(i));
				k++;
			}
		}
		int ans = 0;
		for (int i : rt) {
			if (i != -1) {
				ans++;
			}
		}
		out.println(ans);
		if (r) {
			for (int i = 0; i < rs; i++) {
				if (rt.get(i) != -1) {
					out.println((rx.get(i) + 1) + " " + (ry.get(i) + 1) + " " + (rt.get(i) + 1));
				}
			}
		}
		in.close();
		out.close();
	}

}
/*
3 4 0
SSSS
EESW
ENWW

3 4 1
SSSS
EeSW
ENwW

4 4 1
essS
Eess
Snww
EeWN

*/