#include <bits/stdc++.h>
using namespace std;
bool a[2000][2000];
bool b[2000][2000];
bool binv[2000][2000];
bool bar[2000];
int main() {
  int n;
  char ch;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf(" %c", &ch);
      a[i][j] = (ch == '1');
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf(" %c", &ch);
      b[i][j] = (ch == '1');
    }
  }
  for (int i = 0; i < n; i++) {
    scanf(" %c", &ch);
    bar[i] = (ch == '1');
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (bar[j]) {
        binv[i][j] = !b[i][j];
      } else {
        binv[i][j] = b[i][j];
      }
    }
  }
  int k = 0;
  for (int i = 0; i < n; i++) {
    if (bar[i]) {
      k = i;
      break;
    }
  }
  vector<pair<int, int> > ans;
  for (int j = 0; j < n; j++) {
    if (a[k][j] != b[k][j]) {
      ans.emplace_back(1, j);
      for (int i = 0; i < n; i++) {
        if (bar[i]) a[i][j] = !a[i][j];
      }
    }
  }
  bool checa = true;
  for (int i = 0; i < n; i++) {
    bool linha = true;
    ;
    for (int j = 0; j < n; j++) {
      if (a[i][j] != b[i][j]) {
        linha = false;
        break;
      }
    }
    if (linha) continue;
    linha = true;
    for (int j = 0; j < n; j++) {
      if (a[i][j] != binv[i][j]) {
        linha = false;
        break;
      }
    }
    if (linha)
      ans.emplace_back(0, i);
    else {
      checa = false;
      break;
    }
  }
  if (checa) {
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      if (ans[i].first == 0) {
        printf("row %d\n", ans[i].second);
      } else {
        printf("col %d\n", ans[i].second);
      }
    }
    return 0;
  }
  ans.clear();
  for (int j = 0; j < n; j++) {
    if (a[k][j] != binv[k][j]) {
      ans.emplace_back(1, j);
      for (int i = 0; i < n; i++) {
        if (bar[i]) a[i][j] = !a[i][j];
      }
    }
  }
  checa = true;
  for (int i = 0; i < n; i++) {
    bool linha = true;
    ;
    for (int j = 0; j < n; j++) {
      if (a[i][j] != b[i][j]) {
        linha = false;
        break;
      }
    }
    if (linha) continue;
    linha = true;
    for (int j = 0; j < n; j++) {
      if (a[i][j] != binv[i][j]) {
        linha = false;
        break;
      }
    }
    if (linha)
      ans.emplace_back(0, i);
    else {
      checa = false;
      break;
    }
  }
  if (checa) {
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
      if (ans[i].first == 0) {
        printf("row %d\n", ans[i].second);
      } else {
        printf("col %d\n", ans[i].second);
      }
    }
  } else {
    cout << -1 << endl;
  }
}
