#include <bits/stdc++.h>
using namespace std;
const long long N = 2e3 + 100, OO = 1e10 + 10, M = 998244353, lg = 769;
char a[N * 4][N * 4], b[N * 4][N * 4], c[N * 4];
int id = 1, n, comp[N * 4];
vector<int> topol, G[N * 4], GR[N * 4];
bool mark[N * 4], ans[4 * N];
void oroper(int i, int j) {
  G[i ^ 1].push_back(j);
  G[j ^ 1].push_back(i);
  GR[i].push_back(j ^ 1);
  GR[j].push_back(i ^ 1);
}
void xoroper(int i, int j) {
  oroper(i ^ 1, j ^ 1);
  oroper(i, j);
}
void add(int i, int j) {
  int x = i * 2, y = 2 * (n + j);
  if (c[i] == c[j] && c[j] == a[i][j] && a[i][j] == b[i][j] && c[i] == '0')
    return;
  if (c[i] == c[j] && c[j] == a[i][j] && a[i][j] == b[i][j] && c[i] == '1') {
    oroper(x, y ^ 1);
    oroper(x ^ 1, y);
    return;
  }
  if (c[i] == c[j] && a[i][j] == b[i][j] && c[i] == '1' && a[i][j] == '0') {
    oroper(x, y ^ 1);
    oroper(x ^ 1, y);
    return;
  }
  if (c[i] == c[j] && a[i][j] == b[i][j] && c[i] == '0' && a[i][j] == '1')
    return;
  if (c[i] == '1' && c[j] == '0' && a[i][j] == '0' && b[i][j] == '0') {
    oroper(x ^ 1, y ^ 1);
    oroper(x, y ^ 1);
    return;
  }
  if (c[i] == '0' && c[j] == '1' && a[i][j] == '0' && b[i][j] == '0') {
    oroper(x ^ 1, y ^ 1);
    oroper(x ^ 1, y);
    return;
  }
  if (c[i] == '1' && c[j] == '1' && a[i][j] == '0' && b[i][j] == '1') {
    oroper(x ^ 1, y ^ 1);
    oroper(x, y);
    return;
  }
  if (c[i] == '0' && c[j] == '1' && a[i][j] == '0' && b[i][j] == '1') {
    oroper(x, y);
    return;
  }
  if (c[i] == '1' && c[j] == '0' && a[i][j] == '0' && b[i][j] == '1') {
    oroper(x, y);
    return;
  }
  if (c[i] == '0' && c[j] == '0' && a[i][j] == '0' && b[i][j] == '1') {
    cout << -1 << endl;
    exit(0);
    return;
  }
  if (c[i] == '1' && c[j] == '1' && a[i][j] == '1' && b[i][j] == '0') {
    oroper(x ^ 1, y ^ 1);
    oroper(x, y);
    return;
  }
  if (c[i] == '1' && c[j] == '0' && a[i][j] == '1' && b[i][j] == '1') {
    oroper(x, y ^ 1);
    return;
  }
  if (c[i] == '1' && c[j] == '0' && a[i][j] == '1' && b[i][j] == '0') {
    oroper(x, y);
    oroper(x ^ 1, y);
    return;
  }
  if (c[i] == '0' && c[j] == '1' && a[i][j] == '1' && b[i][j] == '0') {
    oroper(x, y);
    oroper(x, y ^ 1);
    return;
  }
  if (c[i] == '0' && c[j] == '1' && a[i][j] == '1' && b[i][j] == '1') {
    oroper(x ^ 1, y ^ 1);
    oroper(x ^ 1, y);
    return;
  }
  if (c[i] == '0' && c[j] == '0' && a[i][j] == '1' && b[i][j] == '0') {
    cout << -1 << endl;
    exit(0);
    return;
  }
}
void dfs1(int node) {
  mark[node] = 1;
  for (int v : G[node])
    if (!mark[v]) dfs1(v);
  topol.push_back(node);
}
void dfs2(int node, int cid) {
  comp[node] = cid;
  if (!comp[node ^ 1]) ans[(node >> 1) * 2] = node & 1;
  for (int v : GR[node])
    if (!comp[v]) dfs2(v, cid);
}
void SCC() {
  for (int i = 0; i < 4 * n; i++)
    if (!mark[i]) dfs1(i);
  reverse(topol.begin(), topol.end());
  for (int v : topol)
    if (!comp[v]) dfs2(v, id++);
}
bool SAT() {
  SCC();
  for (int i = 0; i < 4 * n; i += 2)
    if (comp[i] == comp[i ^ 1]) return 0;
  return 1;
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> b[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      add(i, j);
    }
  }
  if (!SAT()) {
    cout << -1 << endl;
    return 0;
  }
  int ANS = 0;
  for (int i = 0; i < 4 * n; i += 2) {
    if (ans[i]) {
      ANS++;
    }
  }
  cout << ANS << endl;
  for (int i = 0; i < 4 * n; i += 2) {
    if (ans[i]) {
      if (i < 2 * n)
        cout << "row " << i / 2 << endl;
      else
        cout << "col " << (i / 2) - n << endl;
    }
  }
  return 0;
}
