#include <bits/stdc++.h>
char a[2005][2005];
char b[2005][2005];
char c[2005];
char use[2][2005];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) scanf("%s", &a[i]);
  for (int i = 0; i < n; ++i) scanf("%s", &b[i]);
  scanf("%s", c);
  for (int i = 0; i < n; ++i) {
    c[i] -= '0';
    for (int j = 0; j < n; ++j) {
      a[i][j] -= '0';
      b[i][j] -= '0';
    }
  }
  int sb = 0;
  for (int i = 0; i < n; ++i)
    if (c[i]) {
      sb = i;
      break;
    }
  for (int i = 0; i < n; ++i)
    if (a[i][sb] != b[i][sb]) {
      use[0][i] = 1;
      for (int j = 0; j < n; ++j) a[i][j] ^= c[j];
    }
  for (int i = 0; i < n; ++i)
    if (a[sb][i] != b[sb][i]) {
      use[1][i] = 1;
      for (int j = 0; j < n; ++j) a[j][i] ^= c[j];
    }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (a[i][j] != b[i][j]) {
        printf("-1");
        return 0;
      }
  int ans = 0;
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < n; ++j)
      if (use[i][j]) ++ans;
  printf("%d\n", ans);
  for (int i = 0; i < n; ++i)
    if (use[0][i]) printf("row %d\n", i);
  for (int i = 0; i < n; ++i)
    if (use[1][i]) printf("col %d\n", i);
  return 0;
}
