#include <bits/stdc++.h>
using namespace std;
int a[2001][2001], b[2001][2001], c[2001];
vector<int> g[8004];
void sete(int u, int v) { g[u].push_back(v); }
int dfn[8004], low[8004], bel[8004], dfc, scc;
bool inst[8004];
int scs[8004], *sct = scs;
void scc_clr(int n) { fill(dfn + 1, dfn + n + 1, 0); }
int dfs_scc(int u) {
  *sct++ = u;
  inst[u] = 1;
  dfn[u] = low[u] = ++dfc;
  for (int v : g[u]) {
    if (!dfn[v])
      low[u] = min(low[u], dfs_scc(v));
    else if (inst[v])
      low[u] = min(low[u], dfn[v]);
  }
  if (dfn[u] == low[u])
    for (++scc; *sct != u; --sct) bel[sct[-1]] = scc, inst[sct[-1]] = 0;
  return low[u];
}
int main(void) {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) scanf("%1d", &a[i][j]);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) scanf("%1d", &b[i][j]);
  for (int i = 1; i <= n; ++i) scanf("%1d", &c[i]);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) a[i][j] ^= b[i][j];
  bool flg = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      int p = i, q = n + j;
      if (a[i][j]) {
        if (!c[i] && !c[j])
          flg = 0;
        else if (c[i] && c[j]) {
          sete(2 * p, 2 * q + 1);
          sete(2 * p + 1, 2 * q);
          sete(2 * q, 2 * p + 1);
          sete(2 * q + 1, 2 * p);
        } else {
          if (c[j])
            sete(2 * p, 2 * p + 1);
          else
            sete(2 * q, 2 * q + 1);
        }
      } else {
        if (!c[i] && !c[j])
          ;
        else if (c[i] && c[j]) {
          sete(2 * p, 2 * q);
          sete(2 * q, 2 * p);
          sete(2 * p + 1, 2 * q + 1);
          sete(2 * q + 1, 2 * p + 1);
        } else {
          if (c[j])
            sete(2 * p + 1, 2 * p);
          else
            sete(2 * q + 1, 2 * q);
        }
      }
      if (!flg) break;
    }
    if (!flg) break;
  }
  if (flg) {
    for (int i = 2; i <= 4 * n + 1; ++i) {
      if (!dfn[i]) dfs_scc(i);
    }
    for (int i = 1; i <= 2 * n; ++i) {
      if (bel[2 * i] == bel[2 * i + 1]) {
        flg = 0;
        break;
      }
    }
  }
  if (!flg)
    printf("-1\n");
  else {
    vector<string> ans;
    for (int i = 2; i <= 4 * n; i += 2) {
      if (i <= 2 * n) {
        if (bel[i] > bel[i ^ 1]) ans.push_back("row " + to_string(i / 2 - 1));
      } else {
        if (bel[i] > bel[i ^ 1])
          ans.push_back("col " + to_string(i / 2 - n - 1));
      }
    }
    cout << ans.size() << endl;
    for (string s : ans) cout << s << endl;
  }
  return 0;
}
