#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
  return os << "(" << x.first << "," << x.second << ")";
}
struct TwoSat {
  vector<vector<int>> E, ER;
  vector<int> comp, topo;
  vector<bool> used;
  stack<int> S;
  int n;
  TwoSat(int _n) : n(_n) {
    used.resize(2 * n);
    comp.resize(2 * n, -1);
    topo.resize(2 * n);
    E.resize(2 * n);
    ER.resize(2 * n);
  }
  void addOr(int a, int b) {
    E[a ^ 1].push_back(b);
    E[b ^ 1].push_back(a);
  }
  void implies(int a, int b) { addOr(a ^ 1, b); }
  void atMostOneOf(vector<int> a) {}
  void dfs(int x) {
    if (used[x]) return;
    used[x] = true;
    for (int y : E[x]) dfs(y);
    S.push(x);
  }
  void dfs2(int x, int c) {
    if (comp[x] != -1) return;
    comp[x] = c;
    for (int y : ER[x]) dfs2(y, c);
  }
  vector<bool> solve() {
    for (int x = 0; x < 2 * n; ++x) dfs(x);
    for (int x = 0; x < 2 * n; ++x)
      for (int y : E[x]) ER[y].push_back(x);
    int tn = 0;
    while (!S.empty()) {
      int x = S.top();
      S.pop();
      dfs2(x, x);
      topo[x] = tn++;
    }
    vector<bool> res(n);
    for (int i = 0; i < n; ++i) {
      if (comp[2 * i] == comp[2 * i + 1]) return {};
      res[i] = topo[comp[2 * i]] < topo[comp[2 * i + 1]];
    }
    return res;
  }
};
const int MAXN = 2005;
char A[MAXN][MAXN];
char B[MAXN][MAXN];
char bulb[MAXN];
void no() {
  printf("-1\n");
  exit(0);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%s", A[i]);
  for (int i = 0; i < n; ++i) scanf("%s", B[i]);
  scanf("%s", bulb);
  TwoSat sat(2 * n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      bool d = (A[i][j] != B[i][j]);
      bool rbit = bulb[j] == '1';
      bool cbit = bulb[i] == '1';
      if (!rbit && !cbit) {
        if (d) no();
      } else if (!rbit) {
        if (!d)
          sat.addOr(2 * (n + j), 2 * (n + j));
        else
          sat.addOr(2 * (n + j) + 1, 2 * (n + j) + 1);
      } else if (!cbit) {
        if (!d)
          sat.addOr(2 * i, 2 * i);
        else
          sat.addOr(2 * i + 1, 2 * i + 1);
      } else {
        if (!d) {
          sat.implies(2 * i, 2 * (n + j));
          sat.implies(2 * i + 1, 2 * (n + j) + 1);
        } else {
          sat.implies(2 * i, 2 * (n + j) + 1);
          sat.implies(2 * i + 1, 2 * (n + j));
        }
      }
    }
  auto ans = sat.solve();
  if (ans.empty()) no();
  printf("%d\n", accumulate(ans.begin(), ans.end(), 0));
  for (int i = 0; i < 2 * n; ++i) {
    if (!ans[i]) continue;
    if (i >= n)
      printf("col %d\n", i - n);
    else
      printf("row %d\n", i);
  }
}
