#include <bits/stdc++.h>
using namespace std;
template <class L, class R>
ostream &operator<<(ostream &out, pair<L, R> p) {
  return out << "(" << p.first << ", " << p.second << ")";
}
template <class T>
auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
  out << "{";
  for (auto it = a.begin(); it != a.end(); it = next(it))
    out << (it != a.begin() ? ", " : "") << *it;
  return out << "}";
}
void dump() { cerr << "\n"; }
template <class T, class... Ts>
void dump(T a, Ts... x) {
  cerr << a << ", ";
  dump(x...);
}
template <class T>
int size(T &&a) {
  return a.size();
}
using LL = long long;
using PII = pair<int, int>;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> tab(n, vector<int>(n));
  for (int i = 0; i < n * 2; i++) {
    string str;
    cin >> str;
    for (int j = 0; j < n; j++) tab[i % n][j] ^= str[j] == '1';
  }
  int cnt_1 = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cnt_1 += tab[i][j];
  vector<int> p(n);
  int any_1 = -1;
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    p[i] = c == '1';
    if (p[i]) any_1 = i;
  }
  false;
  if (any_1 == -1 && cnt_1 != 0) {
    cout << "-1\n";
    return 0;
  }
  vector<int> r(n), c(n);
  auto check = [&]() {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (tab[i][j] != ((r[i] & p[j]) ^ (c[j] & p[i]))) c[j] ^= 1;
    bool ok = true;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        if (tab[i][j] != ((r[i] & p[j]) ^ (c[j] & p[i]))) ok = false;
    return ok;
  };
  auto output = [&]() {
    vector<int> cols, rows;
    for (int i = 0; i < n; i++)
      if (c[i]) cols.emplace_back(i);
    for (int i = 0; i < n; i++)
      if (r[i]) rows.emplace_back(i);
    cout << size(cols) + size(rows) << "\n";
    for (int x : cols) cout << "col " << x << "\n";
    for (int x : rows) cout << "row " << x << "\n";
    exit(0);
  };
  for (int i = 0; i < n; i++) r[i] = tab[i][any_1];
  if (check()) output();
  c[any_1] = true;
  for (int i = 0; i < n; i++) r[i] = tab[i][any_1] ^ (c[any_1] & p[i]);
  if (check()) output();
  cout << "-1\n";
}
