#include <bits/stdc++.h>
using namespace std;
int n, m, k, sum, cnt, flag, a[1005][1005];
char h[1005][1005], v[1005][1005];
int main() {
  scanf("%d%d%d", &n, &m, &k), sum = n * (m - 1) + (n - 1) * (m);
  for (int i = 0; i < n; i++) {
    scanf("%s", h[i]);
    for (int j = 0; j < m - 1; j++) cnt += h[i][j] == 'E';
    if (i < n - 1) {
      scanf("%s", v[i]);
      for (int j = 0; j < m; j++) cnt += v[i][j] == 'E';
    }
  }
  if (k == 1) {
    if (cnt * 4 < 3 * sum) return puts("NO"), 0;
    puts("YES");
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) printf("1%s", j < m - 1 ? " " : "\n");
    return 0;
  }
  puts("YES");
  if (n > m) {
    flag = 1, swap(n, m);
    for (int i = 0; i < m; i++)
      for (int j = 0; j < m; j++) swap(h[i][j], v[j][i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++)
      if (j) a[i][j] = (h[i][j - 1] == 'N') ^ a[i][j - 1];
    cnt = 0;
    if (i)
      for (int j = 0; j < m; j++)
        cnt += (v[i - 1][j] == 'E') != (a[i - 1][j] == a[i][j]);
    if (cnt * 2 >= m)
      for (int j = 0; j < m; j++) a[i][j] ^= 1;
  }
  if (flag) {
    for (int i = 0; i < m; i++)
      for (int j = 0; j < n; j++)
        printf("%d%s", a[j][i] + 1, j < n - 1 ? " " : "\n");
  } else
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        printf("%d%s", a[i][j] + 1, j < m - 1 ? " " : "\n");
  return 0;
}
