import java.io.*;
import java.util.*;
  
public class main {
    String fileName = "robots";
    ArrayList<String> result;
  
    class pair {
        @Override
        public String toString() {
            return "pair [x=" + x + ", y=" + y + "]";
        }
  
        int x;
        int y;
  
        pair(int a, int b) {
            this.x = a;
            this.y = b;
        }
  
    }
  
    int colour1 = 0;
    
    boolean check(pair q) {
        if (s[q.x][q.y] == 'S' || s[q.x][q.y] == 'E' || s[q.x][q.y] == 'W' || s[q.x][q.y] == 'N')
            return true;
        return false;
    }
   
    void dfs(pair q, pair pred, int d) {
        if (used[q.x][q.y] != -1 && dist[q.x][q.y] == inf) {
            dist[q.x][q.y] = 0;
//            pos[q.x][q.y] = 0;
//
//            u[colour] = new ArrayList<Integer>();
//            if (check(q)) {
//                result.add((q.x + 1) + " " + (q.y + 1) + " 1");
//            }
//            if (check(q)) {
//                u[used[q.x][q.y]].add(0);
//            }
            dfs1(g[q.x][q.y], q, 1);
//            minn[colour] = new ArrayList<Integer>();
//            int ind = 0;
// 
//            for (int i = 0; i < col[colour]; i++) {
//                while (ind < u[colour].size() && u[colour].get(ind) < i) {
//                    ind += 1;
//                }
//                if (ind < u[colour].size() && u[colour].get(ind) == i) {
//                } else
//                    minn[colour].add(i);
//            }
            return;
  
        } else if (used[q.x][q.y] != -1) {
            colour1 = used[q.x][q.y];
            return;
        }
        used[q.x][q.y] = colour;
        dfs(g[q.x][q.y], q, d);
        dist[q.x][q.y] = dist[g[q.x][q.y].x][g[q.x][q.y].y] + 1;
    }

    void dfs1(pair q, pair pred, int d) {
        // System.out.println(q + " " + pred + " " + d);
        if (pred.x == q.x && pred.y == q.y) {
            dist[q.x][q.y] = 0;
            col[colour] = d;
            return;
        }
//        pos[q.x][q.y] = d;
//        if (check(q)) {
//            u[used[q.x][q.y]].add(d - 1);
//            result.add("" + (q.x + 1) + " " + (q.y + 1) + " 1");
//        }
        dfs1(g[q.x][q.y], pred, d + 1);
        dist[q.x][q.y] = 0;
        }
    void dfs4(pair q, pair pred, int d) {
        if (used[q.x][q.y] != -1 && dist[q.x][q.y] == inf) {
            dist[q.x][q.y] = 0;
            pos[q.x][q.y] = 0;

            u[colour] = new ArrayList<Integer>();
            if (check(q)) {
                result.add((q.x + 1) + " " + (q.y + 1) + " 1");
            }
            if (check(q)) {
                u[used[q.x][q.y]].add(0);
            }
            dfs5(g[q.x][q.y], q, 1);
            minn[colour] = new ArrayList<Integer>();
            int ind = 0;
 
            for (int i = 0; i < col[colour]; i++) {
                while (ind < u[colour].size() && u[colour].get(ind) < i) {
                    ind += 1;
                }
                if (ind < u[colour].size() && u[colour].get(ind) == i) {
                } else
                    minn[colour].add(i);
            }
            return;
  
        } else if (used[q.x][q.y] != -1) {
            colour1 = used[q.x][q.y];
            return;
        }
        used[q.x][q.y] = colour;
        dfs4(g[q.x][q.y], q, d);
        dist[q.x][q.y] = dist[g[q.x][q.y].x][g[q.x][q.y].y] + 1;
    }

    void dfs5(pair q, pair pred, int d) {
        // System.out.println(q + " " + pred + " " + d);
        if (pred.x == q.x && pred.y == q.y) {
            dist[q.x][q.y] = 0;
            col[colour] = d;
            return;
        }
        pos[q.x][q.y] = d;
        if (check(q)) {
            u[used[q.x][q.y]].add(d - 1);
            result.add("" + (q.x + 1) + " " + (q.y + 1) + " 1");
        }
        dfs5(g[q.x][q.y], pred, d + 1);
        dist[q.x][q.y] = 0;
        }
    void dfs2(pair q, pair pred, int col) {
        if (used[q.x][q.y] == col) {
            return;
        }
        used[q.x][q.y] = col;
        dfs2(g[q.x][q.y], pred, col);
    }
  
    pair dfs3(pair q, pair pred, int col1) {
        if (pos[q.x][q.y] != -3) {
            return new pair(pos[q.x][q.y], 0);
        }
        int j = used[q.x][q.y];
        pair y = dfs3(g[q.x][q.y], pred, col1);
        int i = y.x;
  
        if (check(q)) {
            if (ind[j] < minn[j].size()) {
                int t = dist[q.x][q.y];
                int size = col[j];
                int k = minn[j].get(ind[j]);
                i = (i + t) % size;
                t += 1;
//              System.out.println(q + " " + j + " " + i + "  " + dist[q.x][q.y] + " " + minn[j].get(ind[j]));
                  
                int t1 = 0;
                if (k >= i) {
                    t1 += (k - i);
                } else {
                    t1 += (i + size - k);
                }
                while (t1 < y.y) {
                    t1 += size;
                }
                result.add("" + (q.x + 1) + " " + (q.y + 1) + " " + (t1 + t));
                ind[j] += 1;
                return new pair(i, t1);
            }
        }
        return y;
    }
  
    pair[][] g;
    int[][] dist;
    int[][] used;
    int[][] pos;
    int[] ind;
    int[] col;
    int[] rob;
    int colour;
    char[][] s;
    int inf = 10000000;
    ArrayList<Integer> u[];
    ArrayList<Integer> minn[];
  
    public void solve() throws IOException {
        int n = nextInt();
        int m = nextInt();
        int T = nextInt();
        g = new pair[n][m];
        used = new int[n][m];
        dist = new int[n][m];
        rob = new int[n * m + 2];
        col = new int[n * m + 2];
        ind = new int[n * m + 2];
        result = new ArrayList<String>();
        for (int i = 0; i < ind.length; i++) {
            ind[i] = 0;
        }
        pos = new int[n][m];
        u = new ArrayList[n * m + 2];
        minn = new ArrayList[n * m + 2];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                dist[i][j] = inf;
                used[i][j] = -1;
                pos[i][j] = -3;
            }
        }
        s = new char[n][m];
        for (int i = 0; i < n; i++) {
            s[i] = nextToken().toCharArray();
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (s[i][j] == 'W' || s[i][j] == 'w')
                    g[i][j] = new pair(i, j - 1);
                if (s[i][j] == 'N' || s[i][j] == 'n')
                    g[i][j] = new pair(i - 1, j);
                if (s[i][j] == 'E' || s[i][j] == 'e')
                    g[i][j] = new pair(i, j + 1);
                if (s[i][j] == 'S' || s[i][j] == 's')
                    g[i][j] = new pair(i + 1, j);
            }
        }
        colour = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (used[i][j] == -1) {
                    colour += 1;
                    colour1 = -2;
                    dfs(new pair(i, j), new pair(-1, -1), 0);
                    if (colour1 != -2) {
                        dfs2(new pair(i, j), new pair(-1, -1), colour1);
                    }
                    dfs4(new pair(i, j), new pair(-1, -1), 0);
                    
                    dfs3(new pair(i, j), new pair(-1, -1), colour);
  
                }
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (s[i][j] == 'N' || s[i][j] == 'W' || s[i][j] == 'E' || s[i][j] == 'S')
                    rob[used[i][j]] += 1;
            }
        }
        int res = 0;
        for (int i = 1; i < col.length; i++) {
            res += Math.min(col[i], rob[i]);
            // out.println(col[i] + " " + rob[i]);
        }
//		for (int i = 0; i < n; i++) {
//			for (int j = 0; j < m; j++) {
//				out.print(dist[i][j] + " ");
//			}
//			out.println();
//		}
        // for (int i = 0; i < 6; i++){
        // for (int j = 0; j < minn[i].size(); j++){
        // out.print(minn[i].get(j) + " ");
        // }
        // out.println();
        // }
        out.println(res);
        if (T == 1)
            for (int i = 0; i < res; i++) {
                out.println(result.get(i));
            }
    }
  
    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 main().run();
    }
  
}