#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int n, x, tot, cnt, ans, a[N][N], b[N], r[N][2], c[N][2], head[N * 4],
    to[N * N * 4], nxt[N * N * 4];
int idx, scd, dfn[N * 4], low[N * 4], stk[N * 4], scc[N * 4];
char s[N];
void adde(int u, int v) {
  to[++cnt] = v;
  nxt[cnt] = head[u];
  head[u] = cnt;
}
void tarjan(int u) {
  dfn[u] = low[u] = ++idx;
  stk[++stk[0]] = u;
  int v;
  for (int i = head[u]; i; i = nxt[i]) {
    v = to[i];
    if (!dfn[v]) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
    } else if (!scc[v]) {
      low[u] = min(low[u], dfn[v]);
    }
  }
  if (low[u] == dfn[u]) {
    scd++;
    do {
      scc[stk[stk[0]]] = scd;
    } while (stk[stk[0]--] != u);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    r[i][0] = ++tot;
    r[i][1] = ++tot;
  }
  for (int i = 1; i <= n; i++) {
    c[i][0] = ++tot;
    c[i][1] = ++tot;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= n; j++) {
      a[i][j] = s[j] - '0';
    }
  }
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= n; j++) {
      a[i][j] ^= s[j] - '0';
    }
  }
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) {
    b[i] = s[i] - '0';
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (b[i] && b[j]) {
        if (a[i][j]) {
          adde(r[i][0], c[j][1]);
          adde(r[i][1], c[j][0]);
          adde(c[j][0], r[i][1]);
          adde(c[j][1], r[i][0]);
        } else {
          adde(r[i][0], c[j][0]);
          adde(c[j][0], r[i][0]);
          adde(r[i][1], c[j][1]);
          adde(c[j][1], r[i][1]);
        }
      } else if (b[i] && !b[j]) {
        if (a[i][j]) {
          adde(c[j][1], c[j][0]);
        } else {
          adde(c[j][0], c[j][1]);
        }
      } else if (!b[i] && b[j]) {
        if (a[i][j]) {
          adde(r[i][1], r[i][0]);
        } else {
          adde(r[i][0], r[i][1]);
        }
      } else if (!b[i] && !b[j]) {
        if (a[i][j] == 1) {
          puts("-1");
          return 0;
        }
      }
    }
  }
  for (int i = 1; i <= tot; i++) {
    if (!dfn[i]) {
      tarjan(i);
    }
  }
  for (int i = 1; i <= n; i++) {
    if (scc[r[i][0]] == scc[r[i][1]]) {
      puts("-1");
      return 0;
    }
    if (scc[c[i][0]] == scc[c[i][1]]) {
      puts("-1");
      return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (scc[r[i][0]] < scc[r[i][1]]) {
      ans++;
    }
    if (scc[c[i][0]] < scc[c[i][1]]) {
      ans++;
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++) {
    if (scc[r[i][0]] < scc[r[i][1]]) {
      printf("row %d\n", i - 1);
    }
    if (scc[c[i][0]] < scc[c[i][1]]) {
      printf("col %d\n", i - 1);
    }
  }
  return 0;
}
