#include <bits/stdc++.h>
using namespace std;
const int maxx = 600010;
const double pi = acos(-1.0);
const double eps = 1e-15;
stack<int> h;
vector<int> g[maxx];
int t, n, m;
int ans = 0, total = 0, sum = 0, cnt = 0;
int a[maxx], bj[maxx], vis[maxx], dfn[maxx], low[maxx];
char ch[3111];
char c[3111][3111], s[3111][3111];
void tarjan(int x, int father) {
  dfn[x] = low[x] = ++cnt, vis[x] = 1, h.push(x);
  for (int i = 0; i < g[x].size(); i++) {
    int to = g[x][i];
    if (to == father) continue;
    if (!dfn[to]) {
      tarjan(to, x);
      low[x] = min(low[x], low[to]);
    } else if (vis[to])
      low[x] = min(low[x], dfn[to]);
  }
  if (low[x] == dfn[x]) {
    bj[x] = ++total, vis[x] = 0;
    while (h.top() != x) {
      bj[h.top()] = total, vis[h.top()] = 0, h.pop();
    }
    h.pop();
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf(" %c", &c[i][j]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf(" %c", &s[i][j]);
  for (int i = 1; i <= n; i++) scanf(" %c", &ch[i]);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (c[i][j] == '0') {
        if (s[i][j] == '1') {
          if (ch[j] == '0' && ch[i] == '0') {
            ans = -1;
            i = n + 1;
            break;
          }
          if (ch[j] == '0' && ch[i] == '1') g[j + 3 * n].push_back(j + n);
          if (ch[j] == '1' && ch[i] == '0') g[i + 2 * n].push_back(i);
          if (ch[j] == '1' && ch[i] == '1')
            g[i].push_back(j + 3 * n), g[j + 3 * n].push_back(i),
                g[i + 2 * n].push_back(j + n), g[j + n].push_back(i + 2 * n);
        } else {
          if (ch[j] == '0' && ch[i] == '1') g[j + n].push_back(j + 3 * n);
          if (ch[j] == '1' && ch[i] == '0') g[i].push_back(i + 2 * n);
          if (ch[j] == '1' && ch[i] == '1')
            g[i].push_back(j + n), g[j + n].push_back(i),
                g[i + 2 * n].push_back(j + 3 * n),
                g[j + 3 * n].push_back(i + 2 * n);
        }
      } else {
        if (s[i][j] == '1') {
          if (ch[j] == '0' && ch[i] == '1') g[j + n].push_back(j + 3 * n);
          if (ch[j] == '1' && ch[i] == '0') g[i].push_back(i + 2 * n);
          if (ch[j] == '1' && ch[i] == '1')
            g[i].push_back(j + n), g[i + 2 * n].push_back(j + 3 * n),
                g[j + n].push_back(i), g[j + 3 * n].push_back(i + 2 * n);
        } else {
          if (ch[j] == '0' && ch[i] == '0') {
            i = n + 1;
            ans = -1;
            break;
          }
          if (ch[j] == '0' && ch[i] == '1') g[j + 3 * n].push_back(j + n);
          if (ch[j] == '1' && ch[i] == '0') g[i + 2 * n].push_back(i);
          if (ch[j] == '1' && ch[i] == '1')
            g[j + n].push_back(i + 2 * n), g[i].push_back(j + 3 * n),
                g[i + 2 * n].push_back(j + n), g[j + 3 * n].push_back(i);
        }
      }
    }
  if (ans)
    printf("%d", ans);
  else {
    for (int i = 1; i <= 4 * n; i++)
      if (!dfn[i]) tarjan(i, i);
    for (int i = 1; i <= 2 * n; i++)
      if (bj[i] == bj[i + 2 * n]) {
        ans = 1;
        break;
      }
    if (ans)
      printf("-1");
    else {
      for (int i = 1; i <= n; i++)
        if (bj[i] < bj[i + 2 * n]) ans++;
      for (int i = n + 1; i <= 2 * n; i++)
        if (bj[i] < bj[i + 2 * n]) ans++;
      printf("%d\n", ans);
      for (int i = 1; i <= n; i++)
        if (bj[i] < bj[i + 2 * n]) printf("row %d\n", i - 1);
      for (int i = n + 1; i <= 2 * n; i++)
        if (bj[i] < bj[i + 2 * n]) printf("col %d\n", i - n - 1);
    }
  }
  return 0;
}
