#include <bits/stdc++.h>
using namespace std;
const int MAXN = 8e3 + 6;
vector<int> g[MAXN];
vector<int> g1[MAXN];
bool vis[MAXN];
int comp[MAXN];
bool a[2048][2048];
bool b[2048][2048];
bool bar[2048];
vector<int> order;
int n;
int all_n;
bool ok[MAXN];
void add_edge(int v1, int v2) {
  g[v1].push_back(v2 ^ 1);
  g1[v2 ^ 1].push_back(v1);
  g[v2].push_back(v1 ^ 1);
  g1[v1 ^ 1].push_back(v2);
}
void dfs1(int u) {
  vis[u] = 1;
  for (auto v : g[u]) {
    if (vis[v] == 0) dfs1(v);
  }
  order.push_back(u);
}
void dfs2(int u, int c) {
  comp[u] = c;
  for (auto v : g1[u]) {
    if (comp[v] == 0) dfs2(v, c);
  }
}
bool solveSAT() {
  for (int i = 0; i < 4 * n; i++) {
    if (vis[i] == 0) dfs1(i);
  }
  reverse(order.begin(), order.end());
  int cnt = 0;
  for (int i = 0; i < order.size(); i++) {
    if (comp[order[i]] == 0) {
      dfs2(order[i], ++cnt);
    }
  }
  for (int i = 0; i < all_n / 2; i++) {
    if (comp[i * 2] == comp[i * 2 + 1]) {
      cout << "-1\n";
      return 0;
    }
    if (comp[i * 2] > comp[i * 2 + 1]) {
      ok[i] = 1;
    }
  }
  return 1;
}
int main() {
  cin >> n;
  all_n = 4 * n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      a[i][j] = c - '0';
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      char c;
      cin >> c;
      b[i][j] = c - '0';
    }
  }
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    bar[i] = c - '0';
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i][j] == b[i][j]) {
        if (bar[i] == 1 && bar[j] == 1) {
          add_edge(i * 2, (j + n) * 2 + 1);
          add_edge(i * 2 + 1, (j + n) * 2);
        }
        if (bar[i] == 0 && bar[j] == 1) {
          add_edge(i * 2, (j + n) * 2);
          add_edge(i * 2, (j + n) * 2 + 1);
        }
        if (bar[i] == 1 && bar[j] == 0) {
          add_edge(i * 2 + 1, (j + n) * 2);
          add_edge(i * 2, (j + n) * 2);
        }
      }
      if (a[i][j] != b[i][j]) {
        if (bar[i] == 1 && bar[j] == 1) {
          add_edge(i * 2 + 1, (j + n) * 2 + 1);
          add_edge(i * 2, (j + n) * 2);
        }
        if (bar[i] == 0 && bar[j] == 1) {
          add_edge(i * 2 + 1, (j + n) * 2 + 1);
          add_edge(i * 2 + 1, (j + n) * 2);
        }
        if (bar[i] == 1 && bar[j] == 0) {
          add_edge(i * 2 + 1, (j + n) * 2 + 1);
          add_edge(i * 2, (j + n) * 2 + 1);
        }
        if (bar[i] == 0 && bar[j] == 0) {
          cout << "-1\n";
          return 0;
        }
      }
    }
  }
  if (!solveSAT()) {
    return 0;
  }
  vector<pair<string, int> > v;
  for (int i = 0; i < n; i++) {
    if (ok[i]) v.push_back({"row", i});
  }
  for (int i = 0; i < n; i++) {
    if (ok[i + n]) v.push_back({"col", i});
  }
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    cout << v[i].first << " " << v[i].second << endl;
  }
  return 0;
}
