#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1000 + 5;
int n;
bool matrr[N][N], pattern[N];
short int constColor[N << 1], color[N << 1];
vector<pair<int, bool> > adj[N << 1];
void input() {
  cin.tie(0);
  cin >> n;
  string tmp;
  for (int i = 0; i < 2 * n; i++) {
    cin >> tmp;
    for (int j = 0; j < n; j++) matrr[i % n][j] ^= (tmp[j] - '0');
  }
  cin >> tmp;
  for (int i = 0; i < n; i++) pattern[i] = tmp[i] - '0';
  return;
}
void prePros() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (pattern[i] && pattern[j]) {
        adj[i].push_back({n + j, matrr[i][j]});
        adj[n + j].push_back({i, matrr[i][j]});
      } else if (pattern[i] || pattern[j]) {
        if (pattern[i])
          constColor[n + j] = matrr[i][j] + 1;
        else
          constColor[i] = matrr[i][j] + 1;
      } else if (matrr[i][j]) {
        cout << -1 << endl;
        exit(0);
      }
    }
  return;
}
bool DFS(int v, short int cl) {
  if (constColor[v] != 0 && constColor[v] != cl) return false;
  color[v] = cl;
  for (pair<int, bool> p : adj[v]) {
    if (!color[p.first]) {
      if (!DFS(p.first, ((cl - 1) ^ p.second) + 1)) {
        color[v] = 0;
        return false;
      }
    } else if (color[p.first] != ((cl - 1) ^ p.second) + 1) {
      color[v] = 0;
      return false;
    }
  }
  return true;
}
void solve() {
  prePros();
  for (int i = 0; i < 2 * n; i++)
    if (!color[i] && !DFS(i, 1) && !DFS(i, 2)) {
      cout << -1 << endl;
      cerr << i << endl;
      exit(0);
    }
  return;
}
void output() {
  cout.tie(0);
  int cnt = 0;
  for (int i = 0; i < 2 * n; i++)
    if (color[i] == 2) cnt++;
  cout << cnt << '\n';
  for (int i = 0; i < n; i++)
    if (color[i] == 2) cout << "row " << i << '\n';
  for (int i = n; i < 2 * n; i++)
    if (color[i] == 2) cout << "col " << i - n << '\n';
  return;
}
int main() {
  ios::sync_with_stdio(false);
  input();
  solve();
  output();
  return 0;
}
