#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
const int MAXN = 2003;
const int INF = 1e9 + 7;
int n, arr[MAXN][MAXN], b[MAXN];
int col[2 * MAXN], vist[2 * MAXN], p[2 * MAXN];
vi gr[2 * MAXN];
string s;
bool feasible = true;
int parent(int u) { return p[u] = (p[u] == u ? u : parent(p[u])); }
void merge(int u, int v) {
  int pu = parent(u), pv = parent(v);
  p[pu] = pv;
}
bool dfs(int u, int c = 0) {
  vist[u] = 1;
  if (col[u] == 1 - c) return false;
  col[u] = c;
  for (int v : gr[u]) {
    if (col[v] == c) return false;
    if (!vist[v]) {
      if (!dfs(v, 1 - c)) return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < n; j++) {
      arr[i][j] = (s[j] == '1');
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < n; j++) {
      arr[i][j] ^= (s[j] == '1');
    }
    p[i] = i;
    p[n + i] = n + i;
  }
  cin >> s;
  for (int j = 0; j < n; j++) {
    b[j] = (s[j] == '1');
  }
  memset(col, -1, sizeof(col));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (arr[i][j]) {
        if (b[i]) {
          if (b[j]) {
            gr[i].push_back(n + j);
            gr[n + j].push_back(i);
          } else {
            col[n + j] = 1;
          }
        } else {
          if (b[j]) {
            col[i] = 1;
          } else {
            feasible = false;
          }
        }
      } else {
        if (b[i]) {
          if (b[j]) {
            merge(i, n + j);
          } else {
            col[n + j] = 0;
          }
        } else {
          if (b[j]) {
            col[i] = 0;
          }
        }
      }
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    parent(i);
    if (p[i] != i) {
      if (col[i] != -1) {
        if (col[p[i]] == 1 - col[i]) {
          feasible = false;
        } else {
          col[p[i]] = col[i];
        }
      }
      for (int j = 0; j < (int)gr[i].size(); j++) {
        gr[p[i]].push_back(gr[i][j]);
      }
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    if (p[i] == i) {
      for (int j = 0; j < (int)gr[i].size(); j++) {
        gr[i][j] = p[gr[i][j]];
      }
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    if (p[i] == i && !vist[i] && col[i] != -1) {
      if (!dfs(i, col[i])) {
        feasible = false;
      }
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    if (p[i] == i && !vist[i]) {
      if (!dfs(i, 0)) {
        feasible = false;
      }
    }
  }
  if (feasible) {
    int c = 0;
    for (int i = 0; i < n; i++) {
      if (col[p[i]]) {
        c++;
      }
      if (col[p[n + i]]) {
        c++;
      }
    }
    cout << c << endl;
    for (int i = 0; i < n; i++) {
      if (col[p[i]]) {
        cout << "row " << i << '\n';
      }
      if (col[p[n + i]]) {
        cout << "col " << i << '\n';
      }
    }
  } else {
    cout << -1 << endl;
  }
}
