#include <bits/stdc++.h>
using namespace std;
struct TwoSat {
  int N;
  vector<vector<int> > gr;
  vector<int> values;
  TwoSat(int n = 0) : N(n), gr(2 * n) {}
  int add_var() {
    gr.emplace_back();
    gr.emplace_back();
    return N++;
  }
  void either(int f, int j) {
    f = max(2 * f, -1 - 2 * f);
    j = max(2 * j, -1 - 2 * j);
    gr[f].push_back(j ^ 1);
    gr[j].push_back(f ^ 1);
  }
  void set_value(int x) { either(x, x); }
  void at_most_one(const vector<int>& li) {
    if ((int)(li).size() <= 1) return;
    int cur = ~li[0];
    for (int i = 2; i < ((int)(li).size()); ++i) {
      int next = add_var();
      either(cur, ~li[i]);
      either(cur, next);
      either(~li[i], next);
      cur = ~next;
    }
    either(cur, ~li[1]);
  }
  vector<int> val, comp, z;
  int time = 0;
  int dfs(int i) {
    int low = val[i] = ++time, x;
    z.push_back(i);
    for (auto& e : gr[i])
      if (!comp[e]) low = min(low, val[e] ?: dfs(e));
    if (low == val[i]) do {
        x = z.back();
        z.pop_back();
        comp[x] = low;
        if (values[x >> 1] == -1) values[x >> 1] = x & 1;
      } while (x != i);
    return val[i] = low;
  }
  bool solve() {
    values.assign(N, -1);
    val.assign(2 * N, 0);
    comp = val;
    for (int i = 0; i < (2 * N); ++i)
      if (!comp[i]) dfs(i);
    for (int i = 0; i < (N); ++i)
      if (comp[2 * i] == comp[2 * i + 1]) return 0;
    return 1;
  }
  void solverxor(int x, int y) {
    either(x, y);
    at_most_one({x, y});
  }
};
int n;
int startArray[2013][2013];
int endArray[2013][2013];
int wand[2013];
int main() {
  if (fopen("FILENAME.in", "r")) {
    freopen("FILENAME.in", "r", stdin);
    freopen("FILENAME.out", "w", stdout);
  }
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < n; j++) {
      startArray[i][j] = s[j] - '0';
    }
  }
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < n; j++) {
      endArray[i][j] = s[j] - '0';
    }
  }
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) {
    wand[i] = s[i] - '0';
  }
  TwoSat solver(2 * n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int delta = 0;
      if (startArray[i][j] != endArray[i][j]) {
        delta = 1;
      }
      if (wand[i] == 1 && wand[j] == 1) {
        if (delta == 1) {
          solver.solverxor(i, n + j);
        } else {
          solver.solverxor(~i, n + j);
        }
      } else if (wand[i] == 1) {
        if (delta == 1) {
          solver.set_value(n + j);
        } else {
          solver.set_value(~(n + j));
        }
      } else if (wand[j] == 1) {
        int index = i;
        if (delta == 1)
          solver.set_value(index);
        else
          solver.set_value(~index);
      } else if (delta == 1) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  if (!solver.solve()) {
    cout << "-1" << endl;
    return 0;
  }
  int cnt = 0;
  for (int i = 0; i < 2 * n; i++) {
    if (solver.values[i]) {
      cnt++;
    }
  }
  cout << cnt << '\n';
  for (int i = 0; i < n; i++) {
    if (solver.values[i]) {
      cout << "row " << i << '\n';
    }
  }
  for (int i = 0; i < n; i++) {
    if (solver.values[n + i]) {
      cout << "col " << i << '\n';
    }
  }
}
