#include <bits/stdc++.h>
using namespace std;
const int N = 2e4 + 9;
int n, m, ndfn, cmp, ll[N], dfn[N], inStack[N], comp[N], val[N], compVal[N];
vector<int> adj[N], comps[N];
stack<int> stk;
void init() {
  ndfn = cmp = 0;
  memset(dfn, -1, sizeof dfn);
  ;
  memset(compVal, -1, sizeof compVal);
  ;
}
void tarj(int u) {
  ll[u] = dfn[u] = ndfn++;
  stk.push(u);
  inStack[u] = 1;
  for (auto v : adj[u]) {
    if (dfn[v] == -1) {
      tarj(v);
      ll[u] = min(ll[u], ll[v]);
    } else if (inStack[v]) {
      ll[u] = min(ll[u], dfn[v]);
    }
  }
  if (dfn[u] == ll[u]) {
    int x = -1;
    while (x != u) {
      x = stk.top();
      stk.pop();
      inStack[x] = 0;
      comp[x] = cmp;
      comps[cmp].push_back(x);
    }
    ++cmp;
  }
}
void SCC() {
  init();
  for (int i = 0; i < n; ++i)
    if (dfn[i] == -1) tarj(i);
}
void addOR(int a, int b) {
  adj[((a) ^ 1)].push_back(b);
  adj[((b) ^ 1)].push_back(a);
}
void addXOR(int a, int b) {
  addOR(a, b);
  addOR(((a) ^ 1), ((b) ^ 1));
}
void addXNOR(int a, int b) {
  addOR(a, ((b) ^ 1));
  addOR(((a) ^ 1), b);
}
bool solvable() {
  for (int i = 0; i < n; i += 2)
    if (comp[i] == comp[((i) ^ 1)]) return 0;
  return 1;
}
void assignValues() {
  for (int i = 0; i < cmp; ++i) {
    if (~compVal[i]) continue;
    compVal[i] = 1;
    int u = comps[i].back();
    int notComp = comp[((u) ^ 1)];
    compVal[notComp] = 0;
  }
  for (int i = 0; i < n; ++i) val[i] = compVal[comp[i]];
}
void force(int i, int v) {
  if (v)
    adj[((i) ^ 1)].push_back(i);
  else
    adj[i].push_back(((i) ^ 1));
}
char s[2002][2002], t[2002][2002], b[2002];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%s", s[i]);
  for (int i = 0; i < n; ++i) scanf("%s", t[i]);
  scanf("%s", b);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int r = i * 2;
      int c = j * 2 + n * 2;
      if (s[i][j] == t[i][j]) {
        if (b[i] == '1' && b[j] == '1')
          addXNOR(r, c);
        else if (b[i] == '1')
          addOR(((c) ^ 1), ((c) ^ 1));
        else if (b[j] == '1')
          addOR(((r) ^ 1), ((r) ^ 1));
      } else {
        if (b[i] == '1' && b[j] == '1')
          addXOR(r, c);
        else if (b[i] == '1')
          addOR(c, c);
        else if (b[j] == '1')
          addOR(r, r);
        else
          return !printf("%d\n", -1);
      }
    }
  }
  n *= 4;
  SCC();
  if (!solvable()) return !printf("%d\n", -1);
  assignValues();
  int ans = 0;
  vector<int> R, C;
  for (int r = 0; r < n / 2; r += 2) {
    if (val[r] == 1) {
      ++ans;
      R.push_back(r / 2);
    }
  }
  for (int c = n / 2; c < n; c += 2) {
    if (val[c] == 1) {
      ++ans;
      C.push_back((c - n / 2) / 2);
    }
  }
  printf("%d\n", ans);
  for (int r : R) printf("row %d\n", r);
  for (int c : C) printf("col %d\n", c);
  return 0;
}
