#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vi = vector<int>;
using Pii = pair<int, int>;
template <class t, class u, class... w>
auto operator<<(t& o, u a) -> decltype(a.print(), o) {
  o << "{";
  a.print();
  o << "}";
  return o;
};
template <class t, class u, class... w>
auto operator<<(t& o, u a) -> decltype(a.second, o) {
  o << "(" << a.first << ", " << a.second << ")";
  return o;
};
template <class t, class u, class... w>
auto operator<<(t& o, u a) -> decltype((a).begin(), (a).end(), o) {
  o << "[";
  auto d = "";
  for (auto i : a) (o << d << i, d = ", ");
  o << "]";
  return o;
};
void DD(...) {}
template <class t, class u, class... w>
void DD(t s, u a, w... k) {
  int b = 44;
  while (*s && *s != b) {
    b += (*s == 40 ? 50 : *s == 41 ? -50 : 0);
    cerr << *s++;
  }
  cerr << ": " << a << *s++;
  DD(s, k...);
}
template <class t, class u, class... w>
vector<t> span(const t* a, u n) {
  return {a, a + n};
}
bool board[2005][2005];
bool stripe[2005];
int rows[2005], cols[2005];
bool seen1[2005], seen2[2005];
int n;
void nope() {
  cout << -1 << endl;
  exit(0);
}
void dfsCol(int i, int w, bool ret = 1);
void dfsRow(int i, int w, bool ret = 1) {
  if (rows[i] == 2) {
    rows[i] = w;
  } else {
    if (rows[i] != w) nope();
    if (ret) return;
  }
  if (seen1[i]) return;
  seen1[i] = 1;
  for (int j = (0); j < (n); j++) {
    int wanted = board[i][j];
    if (stripe[j]) wanted ^= w;
    if (stripe[i]) {
      dfsCol(j, wanted);
    } else if (wanted) {
      nope();
    }
  }
}
void dfsCol(int i, int w, bool ret) {
  if (cols[i] == 2) {
    cols[i] = w;
  } else {
    if (cols[i] != w) nope();
    if (ret) return;
  }
  if (seen2[i]) return;
  seen2[i] = 1;
  for (int j = (0); j < (n); j++) {
    int wanted = board[j][i];
    if (stripe[j]) wanted ^= w;
    if (stripe[i]) {
      dfsRow(j, wanted);
    } else if (wanted) {
      nope();
    }
  }
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(18);
  cin >> n;
  for (int i = (0); i < (n); i++) {
    string s;
    cin >> s;
    for (int j = (0); j < (n); j++) board[i][j] = (s[j] == '1');
  }
  for (int i = (0); i < (n); i++) {
    string s;
    cin >> s;
    for (int j = (0); j < (n); j++) board[i][j] ^= (s[j] == '1');
  }
  string s;
  cin >> s;
  for (int i = (0); i < (n); i++) stripe[i] = (s[i] == '1');
  for (int i = (0); i < (n); i++) {
    rows[i] = cols[i] = 2;
  }
  vector<Pii> from;
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (n); j++) {
      if ((stripe[i] ^ stripe[j]) == 0) continue;
      if (stripe[j]) {
        rows[i] = board[i][j];
        from.push_back({i, 0});
      } else if (stripe[i]) {
        cols[j] = board[i][j];
        from.push_back({j, 1});
      }
    }
  for (auto& f : (from)) {
    if (f.second)
      dfsCol(f.first, cols[f.first], 0);
    else
      dfsRow(f.first, rows[f.first], 0);
  }
  for (int i = (0); i < (n); i++) {
    if (rows[i] == 2) {
      dfsRow(i, 0);
    }
    if (cols[i] == 2) {
      dfsCol(i, 0);
    }
  }
  vector<Pii> ans;
  for (int i = (0); i < (n); i++) {
    if (rows[i]) ans.push_back({i, 0});
    if (cols[i]) ans.push_back({i, 1});
  }
  cout << int((ans).size()) << '\n';
  for (auto& a : (ans)) {
    cout << (a.second ? "col " : "row ") << a.first << '\n';
  }
}
