#include <bits/stdc++.h>
using namespace std;
const int N = 2000 + 77;
char S[N][N], T[N][N], C[N], X[N][N];
int n;
vector<pair<int, int> > Op;
inline void Print() {
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) cout << X[i][j] << ((j == n) ? '\n' : ' ');
}
inline void ChangeRow(int x) {
  Op.push_back(make_pair(1, x));
  for (int i = 1; i <= n; ++i)
    if (C[i] == '1') {
      if (X[x][i] == '0')
        X[x][i] = '1';
      else
        X[x][i] = '0';
    }
}
inline void ChangeCol(int x) {
  Op.push_back(make_pair(2, x));
  for (int i = 1; i <= n; ++i)
    if (C[i] == '1') {
      if (X[i][x] == '0')
        X[i][x] = '1';
      else
        X[i][x] = '0';
    }
}
inline void Check() {
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (X[i][j] != T[i][j]) return;
  printf("%d\n", (int)Op.size());
  for (auto x : Op) {
    if (x.first == 1)
      printf("row ");
    else
      printf("col ");
    printf("%d\n", x.second - 1);
  }
  exit(0);
}
int main() {
  int goodrow = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%s", S[i] + 1);
  for (int i = 1; i <= n; ++i) scanf("%s", T[i] + 1);
  scanf("%s", C + 1);
  memcpy(X, S, sizeof S);
  Check();
  for (int i = 1; i <= n; ++i)
    if (C[i] == '1') goodrow = i;
  if (goodrow == 0) return !printf("-1\n");
  memcpy(X, S, sizeof S);
  for (int i = 1; i <= n; ++i)
    if (X[goodrow][i] != T[goodrow][i]) ChangeCol(i);
  for (int i = 1; i <= n; ++i) {
    if (i == goodrow) continue;
    bool eq = 1;
    for (int j = 1; j <= n; ++j)
      if (X[i][j] != T[i][j]) eq = 0;
    if (!eq) ChangeRow(i);
  }
  Check();
  Op.clear();
  memcpy(X, S, sizeof S);
  ChangeRow(goodrow);
  for (int i = 1; i <= n; ++i)
    if (X[goodrow][i] != T[goodrow][i]) ChangeCol(i);
  for (int i = 1; i <= n; ++i) {
    if (i == goodrow) continue;
    bool eq = 1;
    for (int j = 1; j <= n; ++j)
      if (X[i][j] != T[i][j]) eq = 0;
    if (!eq) ChangeRow(i);
  }
  Check();
  printf("-1\n");
  return 0;
}
