#include <bits/stdc++.h>
using namespace std;
constexpr int MXN = 2005;
bool a[MXN][MXN], b[MXN][MXN], msk[MXN];
int _p[MXN * 4], *p = _p + MXN + MXN;
int find(int x) { return x == p[x] ? x : p[x] = find(p[x]); }
void merge(int x, int y) { p[find(x)] = find(y); }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n;
  char c;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) cin >> c, a[i][j] = c - '0';
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) cin >> c, b[i][j] = c - '0';
  }
  for (int i = 0; i < n; i++) cin >> c, msk[i] = c - '0';
  for (int i = 1; i <= n + n + 1; i++) p[i] = i, p[-i] = -i;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!msk[i] && !msk[j]) {
        if (a[i][j] != b[i][j]) cout << "-1\n", exit(0);
      } else if (msk[i] && msk[j]) {
        if (a[i][j] == b[i][j]) {
          merge(i + 1, j + n + 1);
          merge(-(i + 1), -(j + n + 1));
        } else {
          merge(i + 1, -(j + n + 1));
          merge(-(i + 1), j + n + 1);
        }
      } else if (msk[j]) {
        if (a[i][j] != b[i][j]) {
          merge(i + 1, n + n + 1);
          merge(-(i + 1), -(n + n + 1));
        } else {
          merge(i + 1, -(n + n + 1));
          merge(-(i + 1), n + n + 1);
        }
      } else {
        if (a[i][j] != b[i][j]) {
          merge(j + n + 1, n + n + 1);
          merge(-(j + n + 1), -(n + n + 1));
        } else {
          merge(j + n + 1, -(n + n + 1));
          merge(-(j + n + 1), n + n + 1);
        }
      }
    }
  }
  for (int i = 1; i <= n + n + 1; i++) {
    if (find(i) == find(-i)) cout << "-1\n", exit(0);
  }
  vector<int> ans;
  ans.reserve(n + n);
  set<int> s;
  for (int i = 1; i <= n + n + 1; i++) {
    if (i == find(i)) s.insert(i);
  }
  for (int i = 1; i <= n + n; i++) {
    if (s.count(find(i))) {
      ans.push_back(i);
    }
  }
  cout << ans.size() << "\n";
  for (auto i : ans) {
    if (i <= n)
      cout << "row " << i - 1 << "\n";
    else
      cout << "col " << i - n - 1 << "\n";
  }
  return 0;
}
