#include <bits/stdc++.h>
using namespace std;
int n, v[2002][2002], ar[2002], par[4004], vis[4004], ans[4004], cnt = 0;
vector<int> ed[4004], col[4004];
set<int> ed2[4004];
int find_p(int x) {
  if (par[x] == x) return x;
  return par[x] = find_p(par[x]);
}
void union_r(int a, int b) {
  a = find_p(a), b = find_p(b);
  if (a != b) par[a] = b;
}
void dfs(int u, int c) {
  vis[u] = c, col[c].push_back(u);
  for (auto v : ed[u])
    if (vis[v] == -2) dfs(v, c ^ 1);
}
void done() {
  cout << -1 << endl;
  exit(0);
}
void dfs1(int u, int c) {
  ans[u] = c;
  for (auto v : ed2[u]) {
    if (ans[v] != c ^ 1) done();
    if (ans[v] == -1) dfs1(v, c ^ 1);
  }
}
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < 2 * n + 1; i++) vis[i] = ans[i] = -1, par[i] = i;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      char x;
      cin >> x;
      v[i][j] = x - '0';
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      char x;
      cin >> x;
      v[i][j] = (v[i][j] != x - '0');
    }
  for (int i = 0; i < n; i++) {
    char x;
    cin >> x;
    ar[i] = x - '0';
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (v[i][j]) {
        if (!(ar[i] || ar[j])) done();
        if (ar[i] && ar[j]) {
          ed[i].push_back(n + j), ed[n + j].push_back(i);
          vis[i] = vis[n + j] = -2;
        }
      }
      if (!v[i][j] && ar[i] && ar[j]) union_r(i, n + j);
    }
  for (int i = 0; i < 2 * n + 1; i++)
    if (vis[i] == -2) dfs(i, cnt), cnt += 2;
  for (int i = 0; i < cnt; i++) {
    int p = col[i][0];
    for (auto x : col[i]) union_r(p, x);
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (!ar[i] && ar[j]) {
        if (ans[find_p(i)] == !v[i][j]) done();
        ans[find_p(i)] = v[i][j];
      }
      if (ar[i] && !ar[j]) {
        if (ans[find_p(n + j)] == !v[i][j]) done();
        ans[find_p(n + j)] = v[i][j];
      }
    }
  for (int i = 0; i < cnt / 2; i++) {
    int a = col[2 * i][0], b = col[2 * i + 1][0];
    a = find_p(a), b = find_p(b);
    if (ans[a] == ans[b] && ans[a] != -1) done();
    if (ans[a] == -1 && ans[b] != -1) ans[a] = !ans[b];
    if (ans[a] != -1 && ans[b] == -1) ans[b] = !ans[a];
  }
  for (int i = 0; i < cnt / 2; i++) {
    int a = col[2 * i][0], b = col[2 * i + 1][0];
    a = find_p(a), b = find_p(b);
    if (ans[a] == -1 && ans[b] == -1) ed2[a].insert(b), ed2[b].insert(a);
  }
  for (int i = 0; i < 2 * n + 1; i++)
    if (!ed2[i].empty() && ans[i] == -1) dfs1(i, 0);
  int temp = 0;
  for (int i = 0; i < 2 * n + 1; i++)
    if (ans[find_p(i)] == 1) temp++;
  cout << temp << endl;
  for (int i = 0; i < 2 * n + 1; i++)
    if (ans[find_p(i)] == 1) {
      if (i < n)
        cout << "row " << i << endl;
      else
        cout << "col " << i - n << endl;
    }
}
