#include <bits/stdc++.h>
using namespace std;
int N;
char Bij, Xi;
char A[2000][2000];
bool B[2000][2000];
bool X[2000];
int P[8002];
bool vis[4000];
vector<int> v[8002];
vector<pair<bool, int> > ans;
int fp(int x) { return P[x] = (P[x] == x ? x : fp(P[x])); }
void lol(int x, int y) {
  cout << "fp(" << x + 1 << "): " << fp(x) + 1 << "; fp(" << y + 1
       << "): " << fp(y) + 1 << '\n';
}
void join(int x, int y) { P[fp(y)] = fp(x); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> N;
  for (int i = 0; i < 4 * N + 2; i++) {
    P[i] = i;
  }
  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++) {
    for (int j = 0; j < N; j++) {
      cin >> Bij;
      B[i][j] = (A[i][j] != Bij);
    }
  }
  for (int i = 0; i < N; i++) {
    cin >> Xi;
    X[i] = (Xi == '1');
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (B[i][j]) {
        if (!X[i] && !X[j]) {
          join(4 * N, 4 * N + 1);
        } else if (X[i] && X[j]) {
          join(2 * N + i, N + j);
          join(i, 3 * N + j);
        } else {
          if (X[j]) {
            join(i, 4 * N + 1);
            join(2 * N + i, 4 * N);
          } else {
            join(4 * N + 1, N + j);
            join(4 * N, 3 * N + j);
          }
        }
      } else {
        if (X[i] && X[j]) {
          join(i, N + j);
          join(2 * N + i, 3 * N + j);
        } else {
          if (X[j]) {
            join(i, 4 * N);
            join(2 * N + i, 4 * N + 1);
          }
          if (X[i]) {
            join(4 * N, N + j);
            join(4 * N + 1, 3 * N + j);
          }
        }
      }
    }
  }
  for (int i = 0; i < 2 * N; i++) {
    if (fp(i) == fp(2 * N + i) || fp(4 * N) == fp(4 * N + 1)) {
      cout << "-1\n";
      return 0;
    }
  }
  for (int i = 0; i < 4 * N + 2; i++) {
    v[fp(i)].push_back(i);
  }
  for (int i = 0; i < 2 * N; i++) {
    if (!vis[i]) {
      if (fp(i) == fp(4 * N + 1)) {
        ans.push_back(make_pair((i < N), i % N));
        vis[i] = 1;
      } else if (fp(i) != fp(4 * N)) {
        for (int k : v[fp(i)]) {
          if (2 * N <= k && k < 4 * N) {
            vis[k % (2 * N)] = 1;
          } else {
            vis[k] = 1;
            ans.push_back(make_pair((k < N), k % N));
          }
        }
      }
    }
  }
  cout << ans.size() << '\n';
  for (auto p : ans) {
    cout << (p.first ? "row" : "col") << ' ' << p.second << '\n';
  }
  return 0;
}
