#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
int n;
VVI M, A;
VI V;
VI R, C;
bool print() {
  cout << R.size() + C.size() << endl;
  for (int x : R) cout << "row " << x << endl;
  for (int x : C) cout << "col " << x << endl;
  return true;
}
void row(int i) {
  for (int j = 0; j < n; ++j) A[i][j] ^= V[j];
  R.push_back(i);
}
void col(int j) {
  for (int i = 0; i < n; ++i) A[i][j] ^= V[i];
  C.push_back(j);
}
int check(const VI& row) {
  if (row == VI(n, 0)) return 0;
  if (row == V) return 1;
  return -1;
}
int check_col(int j) {
  VI C(n);
  for (int i = 0; i < n; ++i) C[i] = A[i][j];
  return check(C);
}
bool prova(int x, int y, bool h, bool v) {
  A = M;
  R = C = VI(0);
  if (h) row(x);
  if (v) col(y);
  if (A[x][y]) return false;
  if (V[y]) {
    for (int i = 0; i < n; ++i)
      if (i != x and A[i][y]) row(i);
    for (int j = 0; j < n; ++j)
      if (j != y) {
        int canvi = check_col(j);
        if (canvi == -1) return false;
        if (canvi) col(j);
      }
    return true;
  }
  for (int j = 0; j < n; ++j)
    if (j != y and A[x][j]) col(j);
  for (int i = 0; i < n; ++i)
    if (i != x) {
      int canvi = check(A[i]);
      if (canvi == -1) return false;
      if (canvi) row(i);
    }
  return true;
}
bool solu() {
  int x = 0;
  int y = 0;
  while (x < n and not M[x][y]) {
    ++y;
    if (y == n) {
      y = 0;
      ++x;
    }
  }
  if (x == n) return print();
  if (not V[x] and not V[y]) return false;
  if (prova(x, y, true, false)) return print();
  if (prova(x, y, false, true)) return print();
  if (prova(x, y, true, true)) return print();
  return false;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  M = VVI(n, VI(n));
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      char c;
      cin >> c;
      M[i][j] = c - '0';
    }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      char c;
      cin >> c;
      M[i][j] ^= c - '0';
    }
  V = VI(n);
  for (int i = 0; i < n; ++i) {
    char c;
    cin >> c;
    V[i] = c - '0';
  }
  if (not solu()) cout << -1 << endl;
}
