#include <bits/stdc++.h>
using namespace std;
char str1[1010][1010], str2[1010][1010];
int ans[1100][1100];
int main() {
  int n, m, K;
  while (cin >> n >> m >> K) {
    memset(ans, 0, sizeof(ans));
    bool flag = 0;
    int num = 0;
    int sum = n * (m - 1) + m * (n - 1);
    for (int i = 0; i < (n); ++i) {
      scanf("%s", str2[i]);
      for (int j = 0; j < (m - 1); ++j)
        if (str2[i][j] == 'E') num++;
      if (i < n - 1) {
        scanf("%s", str1[i]);
        for (int j = 0; j < (m); ++j)
          if (str1[i][j] == 'E') num++;
      }
    }
    if (K == 1) {
      if (num * 4 < sum * 3) {
        puts("NO");
      } else {
        puts("YES");
        for (int i = 0; i < (n); ++i) {
          for (int j = 0; j < (m); ++j) {
            if (j) putchar(' ');
            putchar('1');
          }
          puts("");
        }
      }
      continue;
    }
    if (n > m) {
      flag = 1;
      for (int i = 0; i < (n); ++i)
        for (int j = 0; j < (n); ++j) swap(str2[i][j], str1[j][i]);
      swap(n, m);
    }
    for (int i = 0; i < (n); ++i) {
      for (int j = (1); j <= (m - 1); ++j) {
        if (str2[i][j - 1] == 'E')
          ans[i][j] = ans[i][j - 1];
        else
          ans[i][j] = ans[i][j - 1] ^ 1;
      }
      if (i) {
        int temp = 0;
        for (int j = 0; j < (m); ++j)
          if ((ans[i][j] == ans[i - 1][j]) ^ (str1[i - 1][j] == 'E')) temp++;
        if (temp * 2 >= m)
          for (int j = 0; j < (m); ++j) ans[i][j] ^= 1;
      }
    }
    puts("YES");
    if (flag) {
      for (int i = 0; i < (m); ++i)
        for (int j = i + 1; j < m; ++j) swap(ans[i][j], ans[j][i]);
      swap(n, m);
    }
    for (int i = 0; i < (n); ++i) {
      for (int j = 0; j < (m); ++j) {
        if (j) putchar(' ');
        printf("%d", ans[i][j] + 1);
      }
      puts("");
    }
  }
  return 0;
}
