#include <bits/stdc++.h>
using namespace std;
const int MAKS = 2010;
const int INF = 1e9 + 1;
const long long LINF = 1e17;
int n, a[MAKS][MAKS], b[MAKS][MAKS], p[MAKS], node[2 * MAKS], cnt;
string A[MAKS], B[MAKS], P;
bool vis[2 * MAKS];
bool salah;
vector<pair<int, int> > adj[2 * MAKS];
void buat(int u, int v, int w) {
  adj[u].push_back(make_pair(v, w));
  adj[v].push_back(make_pair(u, w));
  return;
}
void sebar(int now, int type) {
  if (vis[now]) {
    if (node[now] == type) return;
    printf("-1\n");
    salah = true;
    return;
  }
  vis[now] = true;
  node[now] = type;
  for (pair<int, int> next : adj[now]) {
    sebar(next.first, (type + next.second) % 2);
    if (salah) return;
  }
  return;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < n; i++) cin >> B[i];
  cin >> P;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      a[i][j] = A[i][j] - '0';
      b[i][j] = B[i][j] - '0';
      p[i] = P[i] - '0';
    }
  }
  memset(node, -1, sizeof(node));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (p[i] + p[j] == 2) {
        if (a[i][j] != b[i][j]) {
          buat(i, j + n, 1);
        } else
          buat(i, j + n, 0);
      } else if (p[i] + p[j] == 1) {
        if (p[j] == 1) {
          if (a[i][j] != b[i][j])
            node[i] = 1;
          else
            node[i] = 0;
        } else {
          if (a[i][j] != b[i][j])
            node[j + n] = 1;
          else
            node[j + n] = 0;
        }
      } else {
        if (a[i][j] != b[i][j]) {
          printf("-1\n");
          return 0;
        }
      }
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    if (node[i] != -1) {
      sebar(i, node[i]);
      if (salah) return 0;
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    if (!vis[i]) {
      sebar(i, 1);
      if (salah) return 0;
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    if (node[i] == 1) cnt++;
  }
  printf("%d\n", cnt);
  for (int i = 0; i < 2 * n; i++) {
    if (node[i] == 1) {
      if (i < n)
        printf("row %d\n", i);
      else
        printf("col %d\n", i - n);
    }
  }
}
