#include <bits/stdc++.h>
using namespace std;
const int N = 2020;
int n, c[N << 1];
string lamp, s[N], t[N];
bool mark[N << 1];
vector<pair<int, bool> > nei[N << 1];
int row(int x) { return x; }
int col(int x) { return n + x; }
void NO() {
  cout << -1;
  exit(0);
}
void input() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) cin >> t[i];
  cin >> lamp;
}
void add(int u, int v, bool b) {
  nei[u].push_back(pair<int, bool>(v, b));
  nei[v].push_back(pair<int, bool>(u, b));
}
void change(int v, int x) {
  if (c[v] == 0)
    c[v] = x;
  else if (c[v] != x)
    NO();
}
void ready() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (s[i][j] != t[i][j] && lamp[i] == '0' && lamp[j] == '0') NO();
      int x = (s[i][j] == t[i][j] ? 2 : 1);
      if (lamp[i] == '1' && lamp[j] == '1')
        add(row(i), col(j), x % 2);
      else if (lamp[i] == '1')
        change(col(j), x);
      else if (lamp[j] == '1')
        change(row(i), x);
    }
}
void dfs(int v) {
  mark[v] = true;
  for (pair<int, bool> e : nei[v]) {
    int u = e.first;
    bool b = e.second;
    change(u, b ? 3 - c[v] : c[v]);
    if (mark[u] == false) dfs(u);
  }
}
void solve() {
  for (int i = 0; i < 2 * n; i++)
    if (c[i] && mark[i] == false) dfs(i);
  for (int i = 0; i < 2 * n; i++)
    if (mark[i] == false) {
      c[i] = 2;
      dfs(i);
    }
}
void output() {
  int ans = 0;
  for (int i = 0; i < 2 * n; i++) ans += (c[i] == 1);
  cout << ans << '\n';
  for (int i = 0; i < 2 * n; i++)
    if (c[i] == 1) cout << (i < n ? "row " : "col ") << i % n << '\n';
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  input();
  ready();
  solve();
  output();
}
