#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  int f = 0;
  x = 0;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar()) f |= (ch == '-');
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  if (f) x = -x;
}
const int N = 4005;
int a[N][N], b[N], vis[N], col[N], n;
vector<pair<int, int> > e[N];
vector<int> ansR, ansC;
char s[N];
void upd(int a, int b) {
  if (col[a] == 1 - b) {
    puts("-1");
    exit(0);
  }
  col[a] = b;
}
void dfs(int u) {
  vis[u] = 1;
  for (auto v : e[u])
    if (vis[v.first] && col[v.first] != -1 &&
        (col[u] ^ col[v.first]) != v.second) {
      puts("-1");
      exit(0);
    } else if (!vis[v.first]) {
      col[v.first] = v.second ^ col[u];
      dfs(v.first);
    }
}
int main() {
  read(n);
  for (int i = (1); i <= (n); i++) {
    scanf("%s", s + 1);
    for (int j = (1); j <= (n); j++)
      if (s[j] == '1') a[i][j] ^= 1;
  }
  for (int i = (1); i <= (n); i++) {
    scanf("%s", s + 1);
    for (int j = (1); j <= (n); j++)
      if (s[j] == '1') a[i][j] ^= 1;
  }
  scanf("%s", s + 1);
  for (int i = (1); i <= (n); i++) b[i] = (s[i] == '1');
  memset(col, -1, sizeof col);
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (n); j++)
      if (!b[i] && !b[j]) {
        if (a[i][j]) {
          puts("-1");
          return 0;
        }
      } else if (b[i] && b[j]) {
        e[i].push_back(make_pair(n + j, a[i][j]));
        e[n + j].push_back(make_pair(i, a[i][j]));
      } else if (b[j]) {
        upd(i, a[i][j]);
      } else if (b[i]) {
        upd(n + j, a[i][j]);
      }
  for (int i = (1); i <= (n * 2); i++)
    if (!vis[i] && col[i] != -1) dfs(i);
  for (int i = (1); i <= (n * 2); i++)
    if (!vis[i]) {
      col[i] = 0;
      dfs(i);
    }
  for (int i = (1); i <= (n); i++)
    if (col[i]) ansR.push_back(i);
  for (int i = (n + 1); i <= (n * 2); i++)
    if (col[i]) ansC.push_back(i - n);
  printf("%d\n", (int)ansR.size() + (int)ansC.size());
  for (auto x : ansR) printf("row %d\n", x - 1);
  for (auto x : ansC) printf("col %d\n", x - 1);
  return 0;
}
