#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
bitset<maxn> l[maxn], t[maxn], m;
vector<int> nule, jedan;
vector<string> r;
vector<int> pot;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < n; j++) {
      if (s[j] == '1') {
        l[i][j] = 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < n; j++) {
      if (s[j] == '1') {
        t[i][j] = 1;
      }
    }
  }
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      m[i] = 1;
      jedan.push_back(i);
    } else {
      nule.push_back(i);
    }
  }
  int sz = nule.size();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < sz; j++) {
      if (t[i][nule[j]] != l[i][nule[j]]) {
        if (i > jedan[0] || !m[i]) {
          cout << -1 << '\n';
          return 0;
        }
        r.push_back("col");
        pot.push_back(nule[j]);
        for (int k = 0; k < n; k++) {
          l[k][nule[j]] = l[k][nule[j]] ^ m[k];
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < sz; j++) {
      if (t[nule[j]][i] != l[nule[j]][i]) {
        if (i > jedan[0] || !m[i]) {
          cout << -1 << '\n';
          return 0;
        }
        r.push_back("row");
        pot.push_back(nule[j]);
        for (int k = 0; k < n; k++) {
          l[nule[j]][k] = l[nule[j]][k] ^ m[k];
        }
      }
    }
  }
  sz = jedan.size();
  for (int i = 0; i < n; i++) {
    if (l[i][jedan[0]] != t[i][jedan[0]]) {
      r.push_back("row");
      pot.push_back(i);
      for (int j = 0; j < sz; j++) {
        l[i][jedan[j]] = l[i][jedan[j]] ^ 1;
      }
    }
  }
  int x;
  for (int i = 0; i < n; i++) {
    x = -1;
    for (int j = 0; j < sz; j++) {
      if (l[jedan[j]][i] != t[jedan[j]][i]) {
        if (x == -1) {
          x = 1;
        } else if (x == 0) {
          cout << -1 << '\n';
          return 0;
        }
      } else {
        if (x == -1) {
          x = 0;
        } else if (x == 1) {
          cout << -1 << '\n';
          return 0;
        }
      }
    }
    if (x) {
      r.push_back("col");
      pot.push_back(i);
    }
  }
  sz = r.size();
  cout << sz << '\n';
  for (int i = 0; i < sz; i++) {
    cout << r[i] << " " << pot[i] << '\n';
  }
  return 0;
}
