#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int a[N][N], c[N], f[N], cnt, b[N][N], p[N][N], row[N], col[N], n;
char s[N];
void check() {
  int num = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      int k = a[i][j] ^ b[i][j];
      if (c[i]) k ^= col[j];
      if (c[j]) k ^= row[i];
      if (k) return;
    }
  for (int i = 1; i <= n; i++) num += row[i] + col[i];
  printf("%d\n", num);
  for (int i = 1; i <= n; i++)
    if (row[i]) printf("row %d\n", i - 1);
  for (int i = 1; i <= n; i++)
    if (col[i]) printf("col %d\n", i - 1);
  exit(0);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= n; j++) a[i][j] = s[j] - '0';
  }
  for (int i = 1; i <= n; i++) {
    scanf("%s", s + 1);
    for (int j = 1; j <= n; j++) b[i][j] = s[j] - '0';
  }
  scanf("%s", s + 1);
  for (int i = 1; i <= n; i++) c[i] = s[i] - '0';
  for (int i = 1; i <= n; i++)
    if (c[i]) f[++cnt] = i;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (c[j] == 1) p[i][j] |= 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (c[j] == 1) p[j][i] |= 2;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (p[i][j] == 1) row[i] = a[i][j] ^ b[i][j];
      if (p[i][j] == 2) col[j] = a[i][j] ^ b[i][j];
      if (!p[i][j] && a[i][j] != b[i][j]) {
        puts("-1");
        return 0;
      }
    }
  col[f[1]] = 0;
  row[f[1]] = a[f[1]][f[1]] ^ b[f[1]][f[1]];
  for (int i = 2; i <= cnt; i++)
    col[f[i]] = a[f[1]][f[i]] ^ b[f[1]][f[i]] ^ row[f[1]];
  for (int i = 2; i <= cnt; i++)
    row[f[i]] = a[f[i]][f[1]] ^ b[f[i]][f[1]] ^ col[f[1]];
  check();
  col[f[1]] = 1;
  row[f[1]] = a[f[1]][f[1]] ^ b[f[1]][f[1]] ^ 1;
  for (int i = 2; i <= cnt; i++)
    col[f[i]] = a[f[1]][f[i]] ^ b[f[1]][f[i]] ^ row[f[1]];
  for (int i = 2; i <= cnt; i++)
    row[f[i]] = a[f[i]][f[1]] ^ b[f[i]][f[1]] ^ col[f[1]];
  check();
  puts("-1");
  return 0;
}
