#include <bits/stdc++.h>
using namespace std;
int find_scc(vector<vector<int> > &graph, vector<int> &comp) {
  int n = graph.size();
  vector<vector<int> > rgraph(n);
  for (int u = 0; u < n; u++) {
    for (int v : graph[u]) {
      rgraph[v].push_back(u);
    }
  }
  vector<int> order;
  vector<bool> used(n);
  function<void(int)> dfs = [&](int u) {
    used[u] = true;
    for (int v : graph[u]) {
      if (used[v]) continue;
      dfs(v);
    }
    order.push_back(u);
  };
  for (int u = 0; u < n; u++) {
    if (used[u]) continue;
    dfs(u);
  }
  fill(used.begin(), used.end(), false);
  int res = 0;
  function<void(int)> rdfs = [&](int u) {
    used[u] = true;
    comp[u] = res;
    for (int v : rgraph[u]) {
      if (used[v]) continue;
      rdfs(v);
    }
  };
  for (int i = n - 1; i >= 0; i--) {
    int u = order[i];
    if (used[u]) continue;
    rdfs(u);
    res++;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    for (auto &c : a[i]) {
      c -= '0';
    }
  }
  vector<string> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    for (auto &c : b[i]) {
      c -= '0';
    }
  }
  string s;
  cin >> s;
  for (auto &c : s) {
    c -= '0';
  }
  vector<vector<int> > graph(n << 2);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int si = 0; si < 2; si++) {
        for (int sj = 0; sj < 2; sj++) {
          int x = a[i][j] ^ (si & s[j]) ^ (sj & s[i]);
          if (x != b[i][j]) {
            graph[i * 2 + si].push_back((n + j) * 2 + (sj ^ 1));
            graph[(n + j) * 2 + sj].push_back(i * 2 + (si ^ 1));
          }
        }
      }
    }
  }
  vector<int> comp(n << 2);
  find_scc(graph, comp);
  vector<int> ans;
  for (int i = 0; i < n + n; i++) {
    if (comp[i << 1] == comp[i << 1 | 1]) {
      cout << "-1\n";
      return 0;
    }
    if (comp[i << 1] < comp[i << 1 | 1]) {
      ans.push_back(i);
    }
  }
  cout << (int)ans.size() << '\n';
  for (int &x : ans) {
    if (x < n) {
      cout << "row " << x << '\n';
    } else {
      cout << "col " << x - n << '\n';
    }
  }
  return 0;
}
