#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 2100;
int a[N][N], b[N][N], d[N][N];
int c[N], n, tag = -1, res[N];
void print() {
  cout << -1;
  exit(0);
}
int cnt = 0;
void solve(int id, int T) {
  if (T) {
    for (int i = 1; i <= n; i++) {
      if (i == tag) continue;
      if (d[i][id] != c[i]) res[i]++;
    }
  } else {
    for (int i = 1; i <= n; i++) {
      if (i == tag) continue;
      if (d[i][id] != 0) res[i]++;
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  char ch;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) cin >> ch, a[i][j] = ch - '0';
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) cin >> ch, b[i][j] = ch - '0';
  for (int i = 1; i <= n; i++) cin >> ch, c[i] = ch - '0';
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) d[i][j] = a[i][j] ^ b[i][j];
  for (int i = 1; i <= n; i++)
    if (c[i]) tag = i;
  if (tag == -1) {
    bool f = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (d[i][j]) f = 1;
    if (f) print();
  }
  for (int i = 1; i <= n; i++)
    if (d[tag][i]) cnt++;
  for (int i = 1; i <= n; i++) solve(i, d[tag][i]);
  for (int i = 1; i <= n; i++) {
    if (res[i]) {
      cnt++;
      for (int j = 1; j <= n; j++) d[i][j] ^= c[j];
    }
  }
  for (int j = 1; j <= n; j++) {
    int C = 0;
    bool f = 0;
    for (int i = 1; i <= n; i++) {
      if ((d[i][j] && c[i] == 0) || (!d[i][j] && c[i])) f = 1;
      if (d[i][j]) C++;
    }
    if (C && f) print();
  }
  cout << cnt << '\n';
  for (int i = 1; i <= n; i++)
    if (res[i]) cout << "row " << i - 1 << '\n';
  for (int i = 1; i <= n; i++)
    if (d[tag][i]) cout << "col " << i - 1 << '\n';
  return 0;
}
