#include <bits/stdc++.h>
using namespace std;
int const N = 2e3 + 10;
bool a[N][N], b[N][N], c[N], mark[4 * N], col[N], row[N];
vector<int> from[4 * N], to[4 * N], v, topol;
int n, cmp, cnt, comp[4 * N];
set<int> vrtx;
void read_input() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < n; j++) a[i][j] = (s[j] == '1');
  }
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < n; j++) b[i][j] = (s[j] == '1');
  }
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) c[i] = (s[i] == '1');
}
void add_edge(int x, int y) {
  from[x].push_back(y), to[y].push_back(x);
  vrtx.insert(x), vrtx.insert(y);
}
void dfs_t(int v) {
  mark[v] = true;
  for (int u : from[v])
    if (!mark[u]) dfs_t(u);
  topol.push_back(v);
}
void dfs_c(int v, int c) {
  comp[v] = c;
  for (int u : to[v])
    if (!comp[u]) dfs_c(u, c);
}
void solve() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (c[i] == 0 && c[j] == 0 && a[i][j] != b[i][j]) {
        cout << -1;
        exit(0);
      }
      if (c[i] == 0 && c[j] == 1) row[i] = (a[i][j] != b[i][j]);
      if (c[i] == 1 && c[j] == 0) col[j] = (a[i][j] != b[i][j]);
      if (c[i] == 1 && c[j] == 1) {
        if (a[i][j] != b[i][j]) {
          add_edge(2 * i, 2 * (j + n) + 1);
          add_edge(2 * (j + n), 2 * i + 1);
          add_edge(2 * i + 1, 2 * (j + n));
          add_edge(2 * (j + n) + 1, 2 * i);
        } else {
          add_edge(2 * i, 2 * (j + n));
          add_edge(2 * (j + n), 2 * i);
          add_edge(2 * i + 1, 2 * (j + n) + 1);
          add_edge(2 * (j + n) + 1, 2 * i + 1);
        }
      }
    }
  set<int>::iterator itt;
  for (itt = vrtx.begin(); itt != vrtx.end(); itt++) v.push_back(*itt);
  for (int u : v)
    if (!mark[u]) dfs_t(u);
  reverse(topol.begin(), topol.end());
  for (int u : topol)
    if (!comp[u]) dfs_c(u, ++cmp);
  for (int u : v) {
    if (comp[u] == comp[u ^ 1]) {
      cout << -1;
      exit(0);
    }
    if (comp[u / 2 * 2] > comp[u / 2 * 2 + 1])
      (u / 2 >= n ? col[u / 2 - n] : row[u / 2]) = true;
  }
}
void write_output() {
  for (int i = 0; i < n; i++) cnt += row[i] + col[i];
  cout << cnt << '\n';
  for (int i = 0; i < n; i++)
    if (row[i]) cout << "row " << i << '\n';
  for (int i = 0; i < n; i++)
    if (col[i]) cout << "col " << i << '\n';
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  read_input(), solve(), write_output();
  return 0;
}
