#include <bits/stdc++.h>
using namespace std;
const int N = 2002;
const int V = N * 4;
vector<int> g[V];
vector<int> rg[V];
vector<int> ord;
int used[V];
int comp[V];
int vec[N];
int mat[N][N];
void OR(int a, int b) {
  g[a ^ 1].push_back(b);
  g[b ^ 1].push_back(a);
  rg[a].push_back(b ^ 1);
  rg[b].push_back(a ^ 1);
}
void dfs1(int v) {
  used[v] = true;
  for (int to : g[v]) {
    if (!used[to]) {
      dfs1(to);
    }
  }
  ord.push_back(v);
}
void dfs2(int v, int c) {
  comp[v] = c;
  for (int to : rg[v]) {
    if (!comp[to]) {
      dfs2(to, c);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      mat[i][j] ^= (c == '1');
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      mat[i][j] ^= (c == '1');
    }
  }
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    vec[i] = (c == '1');
  }
  bool ok = true;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (mat[i][j]) {
        if (vec[i] && vec[j]) {
          OR(i * 2 + 1, j * 2 + 2 * n + 1);
          OR(i * 2, j * 2 + 2 * n);
        } else if (vec[j]) {
          OR(i * 2, i * 2);
        } else if (vec[i]) {
          OR(j * 2 + 2 * n, j * 2 + 2 * n);
        } else {
          ok = false;
        }
      } else {
        if (vec[i] && vec[j]) {
          OR(i * 2 + 1, j * 2 + 2 * n);
          OR(i * 2, j * 2 + 1 + 2 * n);
        } else if (vec[j]) {
          OR(i * 2 + 1, i * 2 + 1);
        } else if (vec[i]) {
          OR(j * 2 + 2 * n + 1, j * 2 + 2 * n + 1);
        }
      }
    }
  }
  for (int i = 0; i < 4 * n; i++) {
    if (!used[i]) dfs1(i);
  }
  reverse(ord.begin(), ord.end());
  int cnt = 1;
  for (int v : ord) {
    if (!comp[v]) dfs2(v, cnt++);
  }
  for (int i = 0; i < 4 * n; i++) {
    if (comp[i] == comp[i ^ 1]) {
      ok = false;
      break;
    }
  }
  if (ok) {
    vector<int> ans;
    for (int i = 0; i < 4 * n; i += 2) {
      if (comp[i] > comp[i ^ 1]) {
        ans.push_back(i / 2);
      }
    }
    cout << ans.size() << endl;
    for (int a : ans) {
      if (a < n) {
        cout << "row " << a << endl;
      } else {
        cout << "col " << a - n << endl;
      }
    }
  } else {
    cout << -1 << endl;
  }
  return 0;
}
