#include <bits/stdc++.h>
using namespace std;
const int N = 1e4 + 7;
vector<int> G[N], Gt[N], order, answer;
int n;
int vis[N], ss[N];
string s, s1[N], s2[N];
void add_edge(int a, int b) {
  G[a].push_back(b);
  Gt[b].push_back(a);
}
void add_or(int a, int b) {
  add_edge(a ^ 1, b);
  add_edge(b ^ 1, a);
}
void dfs1(int v) {
  if (vis[v]) return;
  vis[v] = 1;
  for (auto x : G[v]) {
    dfs1(x);
  }
  order.push_back(v);
}
void dfs2(int v, int nr) {
  if (ss[v] != 0) return;
  ss[v] = nr;
  for (auto x : Gt[v]) {
    dfs2(x, nr);
  }
}
bool sat() {
  for (int i = 0; i < 4 * n; i++) {
    dfs1(i);
  }
  reverse(order.begin(), order.end());
  int nr = 0;
  for (auto x : order) {
    if (ss[x] == 0) {
      nr++;
      dfs2(x, nr);
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    if (ss[i * 2] == ss[i * 2 + 1]) return false;
    if (ss[i * 2] > ss[i * 2 + 1]) answer.push_back(i);
  }
  return true;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s1[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> s2[i];
  }
  cin >> s;
  for (int i = 0; i < 2 * n; i++) {
    add_or(2 * i, 2 * i + 1);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int X = (s1[i][j] - '0') ^ (s2[i][j] - '0');
      int A = s[j] - '0';
      int B = s[i] - '0';
      int a = i;
      int b = j + n;
      if (X == 1) add_or(2 * a, 2 * b);
      if ((X ^ A) == 1) add_edge(2 * a, 2 * b);
      if ((X ^ B) == 1) add_edge(2 * b, 2 * a);
      if ((X ^ A ^ B) == 1) add_or(2 * a + 1, 2 * b + 1);
    }
  }
  if (!sat()) {
    cout << -1;
    return 0;
  }
  cout << answer.size() << endl;
  for (auto x : answer) {
    if (x < n)
      cout << "row " << x << endl;
    else
      cout << "col " << x - n << endl;
  }
}
