#include <bits/stdc++.h>
using namespace std;
char a[1001][1001], b[1001][1001];
int n, m, k, g[1001][1001];
int main() {
  scanf("%d%d%d\n", &n, &m, &k);
  int i, j, cnt, tot;
  for (i = 1; i <= n; i++) {
    gets(a[i] + 1);
    if (i != n) gets(b[i] + 1);
  }
  if (k == 1) {
    cnt = tot = 0;
    for (i = 1; i <= n; i++)
      for (j = 1; j < m; j++) cnt += a[i][j] != 'N', tot++;
    for (i = 1; i < n; i++)
      for (j = 1; j <= m; j++) cnt += b[i][j] != 'N', tot++;
    if (cnt * 4 >= tot * 3) {
      puts("YES");
      for (i = 1; i <= n; i++) {
        for (j = 1; j <= m; j++) printf("1 ");
        printf("\n");
      }
    } else
      puts("NO");
  } else {
    for (i = 1; i <= n; i++) {
      g[i][1] = 1;
      for (j = 2; j <= m; j++)
        if (a[i][j - 1] == 'E')
          g[i][j] = g[i][j - 1];
        else
          g[i][j] = 3 - g[i][j - 1];
      if (i != 1) {
        cnt = 0;
        for (j = 1; j <= m; j++)
          cnt += (g[i][j] == g[i - 1][j] && b[i - 1][j] == 'E') ||
                 (g[i][j] != g[i - 1][j] && b[i - 1][j] == 'N');
        if (2 * cnt < m)
          for (j = 1; j <= m; j++) g[i][j] = 3 - g[i][j];
      }
    }
    cnt = tot = n * (m - 1);
    for (i = 1; i < n; i++)
      for (j = 1; j <= m; j++)
        cnt += (g[i][j] == g[i + 1][j] && b[i][j] == 'E') ||
               (g[i][j] != g[i + 1][j] && b[i][j] == 'N'),
            tot++;
    if (cnt * 4 >= tot * 3) {
      puts("YES");
      for (i = 1; i <= n; i++) {
        for (j = 1; j <= m; j++) printf("%d ", g[i][j]);
        printf("\n");
      }
      return 0;
    }
    for (i = 1; i <= m; i++) {
      g[1][i] = 1;
      for (j = 2; j <= n; j++)
        if (b[j - 1][i] == 'E')
          g[j][i] = g[j - 1][i];
        else
          g[j][i] = 3 - g[j - 1][i];
      if (i != 1) {
        cnt = 0;
        for (j = 1; j <= n; j++)
          cnt += (g[j][i] == g[j][i - 1] && a[j][i - 1] == 'E') ||
                 (g[j][i] != g[j][i - 1] && a[j][i - 1] == 'N');
        if (2 * cnt < n)
          for (j = 1; j <= n; j++) g[j][i] = 3 - g[j][i];
      }
    }
    cnt = tot = (n - 1) * m;
    for (i = 1; i < m; i++)
      for (j = 1; j <= n; j++)
        cnt += (g[j][i] == g[j][i + 1] && a[j][i] == 'E') ||
               (g[j][i] != g[j][i + 1] && a[j][i] == 'N'),
            tot++;
    puts("YES");
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) printf("%d ", g[i][j]);
      printf("\n");
    }
  }
  return 0;
}
