#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> g[4 * 2005], revG[4 * 2005];
bool a[2005][2005], b[2005][2005], bar[2005];
void add_edge(int u, int v) {
  g[u].push_back(v);
  revG[v].push_back(u);
}
int dd[4 * 2005], visit[4 * 2005], tt;
vector<int> order;
void DFS1(int u) {
  dd[u] = 1;
  for (auto v : g[u]) {
    if (dd[v]) continue;
    DFS1(v);
  }
  order.push_back(u);
}
void DFS2(int u) {
  visit[u] = tt;
  for (auto v : revG[u]) {
    if (visit[v]) continue;
    DFS2(v);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i <= n - 1; i++) {
    string s;
    cin >> s;
    for (int j = 0; j <= n - 1; j++) a[i][j] = s[j] - '0';
  }
  for (int i = 0; i <= n - 1; i++) {
    string s;
    cin >> s;
    for (int j = 0; j <= n - 1; j++) b[i][j] = s[j] - '0';
  }
  string s;
  cin >> s;
  for (int j = 0; j <= n - 1; j++) bar[j] = s[j] - '0';
  for (int i = 0; i <= n - 1; i++)
    for (int j = 0; j <= n - 1; j++)
      for (int vRow = 0; vRow <= 1; vRow++)
        for (int vCol = 0; vCol <= 1; vCol++) {
          int x = a[i][j] ^ (vRow & bar[j]) ^ (vCol & bar[i]);
          int y = b[i][j];
          if (x != y) {
            add_edge(2 * i + vRow, 2 * (j + n) + (vCol ^ 1));
            add_edge(2 * (j + n) + vCol, 2 * i + (vRow ^ 1));
          }
        }
  int sz = 4 * n;
  for (int i = 0; i <= sz - 1; i++)
    if (!dd[i]) DFS1(i);
  reverse(order.begin(), order.end());
  for (auto u : order)
    if (!visit[u]) {
      tt++;
      DFS2(u);
    }
  vector<int> res;
  for (int i = 0; i <= 2 * n - 1; i++) {
    if (visit[2 * i] == visit[2 * i + 1]) {
      cout << -1;
      return 0;
    }
    if (visit[2 * i] < visit[2 * i + 1]) {
      res.push_back(i);
    }
  }
  cout << res.size() << '\n';
  for (auto u : res) {
    if (u < n)
      cout << "row " << u << '\n';
    else
      cout << "col " << u - n << '\n';
  }
}
