#include <bits/stdc++.h>
using namespace std;
const int MX = 2000, MXN = MX * 5;
int N, n;
string S[MX], T[MX], M;
bitset<MX> s[MX], t[MX], m;
vector<int> adjList[MXN], adjListR[MXN];
bitset<MXN> visited;
int comp[MXN], sccs = 0;
stack<int> stck;
int getRN(int i, int b) { return i * 2 + b; }
int getCN(int i, int b) { return N * 2 + i * 2 + b; }
void reverseEdges() {
  for (int i = int(0); i < int(n); i++)
    for (int v : adjList[i]) adjListR[v].push_back(i);
  for (int i = int(0); i < int(n); i++) adjList[i] = adjListR[i];
}
void dfs1(int u) {
  if (visited[u]) return;
  visited[u] = 1;
  for (int v : adjList[u]) dfs1(v);
  stck.push(u);
}
void dfs2(int u, int r) {
  if (visited[u]) return;
  visited[u] = 1;
  comp[u] = r;
  for (int v : adjList[u]) dfs2(v, r);
}
void findScc() {
  visited.reset();
  for (int i = int(0); i < int(n); i++) dfs1(i);
  visited.reset();
  reverseEdges();
  while (!stck.empty()) {
    int u = stck.top();
    stck.pop();
    if (!visited[u]) dfs2(u, sccs++);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  n = N * 4;
  for (int i = int(0); i < int(N); i++) cin >> S[i];
  for (int i = int(0); i < int(N); i++) cin >> T[i];
  cin >> M;
  for (int i = int(0); i < int(N); i++)
    for (int j = int(0); j < int(N); j++)
      s[i][j] = S[i][j] == '1', t[i][j] = T[i][j] == '1';
  for (int i = int(0); i < int(N); i++) m[i] = M[i] == '1';
  for (int r = int(0); r < int(N); r++) {
    for (int c = int(0); c < int(N); c++) {
      if (s[r][c] == t[r][c]) {
        if (m[r] && m[c]) {
          adjList[getRN(r, 0)].push_back(getCN(c, 0));
          adjList[getCN(c, 0)].push_back(getRN(r, 0));
          adjList[getRN(r, 1)].push_back(getCN(c, 1));
          adjList[getCN(c, 1)].push_back(getRN(r, 1));
        } else if (m[r]) {
          adjList[getCN(c, 1)].push_back(getCN(c, 0));
        } else if (m[c]) {
          adjList[getRN(r, 1)].push_back(getRN(r, 0));
        }
      } else {
        if (m[r] && m[c]) {
          adjList[getRN(r, 0)].push_back(getCN(c, 1));
          adjList[getCN(c, 0)].push_back(getRN(r, 1));
          adjList[getRN(r, 1)].push_back(getCN(c, 0));
          adjList[getCN(c, 1)].push_back(getRN(r, 0));
        } else if (m[r]) {
          adjList[getCN(c, 0)].push_back(getCN(c, 1));
        } else if (m[c]) {
          adjList[getRN(r, 0)].push_back(getRN(r, 1));
        } else {
          adjList[getRN(r, 0)].push_back(getRN(r, 1));
          adjList[getRN(r, 1)].push_back(getRN(r, 0));
          adjList[getCN(c, 0)].push_back(getCN(c, 1));
          adjList[getCN(c, 1)].push_back(getCN(c, 0));
        }
      }
    }
  }
  findScc();
  bool possible = 1;
  for (int i = int(0); i < int(N); i++) {
    if (comp[getRN(i, 0)] == comp[getRN(i, 1)]) possible = 0;
    if (comp[getCN(i, 0)] == comp[getCN(i, 1)]) possible = 0;
  }
  if (possible) {
    vector<int> rows;
    vector<int> cols;
    for (int i = int(0); i < int(N); i++) {
      if (comp[getRN(i, 0)] < comp[getRN(i, 1)]) rows.push_back(i);
      if (comp[getCN(i, 0)] < comp[getCN(i, 1)]) cols.push_back(i);
    }
    cout << rows.size() + cols.size() << endl;
    for (int v : rows) cout << "row " << v << endl;
    for (int v : cols) cout << "col " << v << endl;
  } else {
    cout << -1 << endl;
  }
}
