#include <bits/stdc++.h>
using namespace std;
int n, tim = 0, dfn[8010], low[8010], stk[8010], top = 0, bel[8010], bcccnt = 0;
bool vis[8010];
vector<int> v[8010];
inline int TRUE(int x) { return x * 2 - 1; }
inline int FALSE(int x) { return x * 2; }
void dfs(int np) {
  dfn[np] = low[np] = ++tim;
  stk[++top] = np;
  vis[np] = 1;
  for (int i = 0; i < v[np].size(); i++) {
    int x = v[np][i];
    if (!dfn[x]) {
      dfs(x);
      low[np] = min(low[np], low[x]);
    } else if (vis[x])
      low[np] = min(low[np], dfn[x]);
  }
  if (low[np] == dfn[np]) {
    bcccnt++;
    int tmp;
    while ((tmp = stk[top--])) {
      vis[tmp] = 0;
      bel[tmp] = bcccnt;
      if (tmp == np) break;
    }
  }
}
int status[4010];
char v1[2010][2010], v2[2010][2010], bar[2010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", v1[i] + 1);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%s", v2[i] + 1);
  }
  scanf("%s", bar + 1);
  memset(status, 255, sizeof(status));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (v1[i][j] != v2[i][j]) {
        if (bar[j] == '1') {
          if (bar[i] == '1') {
            v[TRUE(i)].push_back(FALSE(j + n));
            v[FALSE(j + n)].push_back(TRUE(i));
            v[TRUE(j + n)].push_back(FALSE(i));
            v[FALSE(i)].push_back(TRUE(j + n));
          } else {
            v[FALSE(i)].push_back(TRUE(i));
          }
        } else {
          if (bar[i] == '1') {
            v[FALSE(j + n)].push_back(TRUE(j + n));
          } else {
            puts("-1");
            return 0;
          }
        }
      } else {
        if (bar[j] == '1') {
          if (bar[i] == '1') {
            v[TRUE(i)].push_back(TRUE(j + n));
            v[TRUE(j + n)].push_back(TRUE(i));
            v[FALSE(j + n)].push_back(FALSE(i));
            v[FALSE(i)].push_back(FALSE(j + n));
          } else {
            v[TRUE(i)].push_back(FALSE(i));
          }
        } else {
          if (bar[i] == '1') {
            v[TRUE(j + n)].push_back(FALSE(j + n));
          }
        }
      }
    }
  }
  for (int i = 1; i <= 4 * n; i++) {
    if (!dfn[i]) dfs(i);
  }
  for (int i = 1; i <= 2 * n; i++) {
    if (bel[TRUE(i)] == bel[FALSE(i)]) {
      puts("-1");
      return 0;
    }
  }
  int cnt = 0;
  for (int i = 1; i <= 2 * n; i++) {
    if (bel[TRUE(i)] < bel[FALSE(i)]) cnt++;
  }
  printf("%d\n", cnt);
  for (int i = 1; i <= 2 * n; i++) {
    if (bel[TRUE(i)] < bel[FALSE(i)]) {
      if (i <= n)
        printf("row %d\n", i - 1);
      else
        printf("col %d\n", i - n - 1);
    }
  }
  return 0;
}
