#include <bits/stdc++.h>
using namespace std;
const int N = 2005, M = 8005;
int n, ovo, tot, ans;
bool ok;
char s[N];
int a[N], b[N], c[N], col[M];
bool f[N][N], g[M][M];
int low[M], dfn[M], bel[M], st[M];
bool inst[M];
void adds(int x, int y) { g[x][y] = g[y][x] = 1; }
void adds_same(int x, int y) {
  adds(x << 1, y << 1), adds(x << 1 | 1, y << 1 | 1);
}
void adds_diff(int x, int y) {
  adds(x << 1, y << 1 | 1), adds(x << 1 | 1, y << 1);
}
void dfs(int x, int p) {
  low[x] = dfn[x] = ++ovo, inst[x] = 1, st[++st[0]] = x;
  for (int y = 2; y <= n * 4 + 1; ++y) {
    if (g[x][y]) {
      if (!dfn[y]) {
        dfs(y, x);
        low[x] = min(low[x], low[y]);
      } else {
        low[x] = min(low[x], dfn[y]);
      }
    }
  }
  if (low[x] == dfn[x]) {
    for (++tot, p = st[st[0]]; p != x; p = st[--st[0]]) {
      bel[p] = tot, inst[p] = 0;
    }
    bel[x] = tot, inst[p] = 0, --st[0];
  }
}
void color(int x, int k) {
  col[x >> 1] = (x & 1) ^ k;
  for (int y = 2; y <= n * 4 + 1; ++y) {
    if (g[x][y] && col[y >> 1] < 0) {
      color(y, k);
    }
  }
}
int main() {
  scanf("%d", &n), ok = 1;
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s + 1);
    for (int j = 1; j <= n; ++j) {
      f[i][j] = s[j] - '0';
    }
  }
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s + 1);
    for (int j = 1; j <= n; ++j) {
      f[i][j] ^= s[j] - '0';
    }
  }
  scanf("%s", s + 1);
  for (int i = 1; i <= n; ++i) {
    c[i] = s[i] - '0', col[i] = col[i + n] = -1;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (c[i] == 1 && c[j] == 1) {
        f[i][j] == 1 ? adds_diff(i, j + n) : adds_same(i, j + n);
      } else if (c[j] == 1) {
        ok &= (col[i] < 0 || col[i] == f[i][j]), col[i] = f[i][j];
      } else if (c[i] == 1) {
        ok &= (col[j + n] < 0 || col[j + n] == f[i][j]), col[j + n] = f[i][j];
      } else {
        ok &= (f[i][j] == 0);
      }
    }
  }
  if (!ok) {
    return puts("-1"), 0;
  }
  for (int i = 2; i <= n * 4 + 1; ++i) {
    if (!dfn[i]) {
      dfs(i, 0);
    }
  }
  for (int i = 1; i <= n * 2; ++i) {
    if (bel[i << 1] == bel[i << 1 | 1]) {
      return puts("-1"), 0;
    }
  }
  for (int i = 1; i <= n * 2; ++i) {
    if (~col[i]) {
      if (col[i]) {
        color(i << 1 | 1, 0);
        color(i << 1, 1);
      } else {
        color(i << 1, 0);
        color(i << 1 | 1, 1);
      }
    }
  }
  for (int i = 1; i <= n * 2; ++i) {
    if (col[i] < 0) {
      color(i << 1, 1);
      color(i << 1 | 1, 0);
    }
  }
  for (int i = 1; i <= n * 2; ++i) {
    ans += col[i];
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; ++i) {
    if (col[i] == 1) {
      printf("row %d\n", i - 1);
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (col[i + n] == 1) {
      printf("col %d\n", i - 1);
    }
  }
  return 0;
}
