#include <bits/stdc++.h>
using namespace std;
int n, edgenum, head[8080], top = 0, id, vet[16002020], ru[8080], jie[16002020];
char s1[2080][2080], s2[2080][2080], temp[2080];
int edgenew, headnew[2080 * 4], vetnew[16002020], jienew[16002020];
int dfn[8080], tim, low[8080], yt[8080], col[8080], allcol[8080], stak[8080];
vector<int> vec[8080];
map<int, map<int, int> > g;
void add(int u, int v) {
  edgenum++;
  vet[edgenum] = v;
  jie[edgenum] = head[u];
  head[u] = edgenum;
}
void addnew(int u, int v) {
  edgenew++;
  vetnew[edgenew] = v;
  jienew[edgenew] = headnew[u];
  headnew[u] = edgenew;
}
void tarjan(int u) {
  int e = head[u];
  tim++;
  low[u] = tim;
  dfn[u] = tim;
  top++;
  stak[top] = u;
  while (e > 0) {
    int v = vet[e];
    if (dfn[v] == 0) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
    } else if (yt[v] == 0)
      low[u] = min(low[u], dfn[v]);
    e = jie[e];
  }
  if (low[u] == dfn[u]) {
    id++;
    yt[u] = id;
    while (stak[top] != u) {
      int v = stak[top];
      yt[v] = id;
      top--;
    }
    top--;
  }
}
void solve1(int i, int j) {
  int x1 = i * 2 - 1, x2 = i * 2, y1 = 2 * n + j * 2 - 1, y2 = y1 + 1;
  if (temp[i] == '0' && temp[j] == '0') {
    printf("-1\n");
    exit(0);
  }
  if (temp[i] == '0' && temp[j] == '1') {
    add(x2, x1);
    return;
  }
  if (temp[i] == '1' && temp[j] == '0') {
    add(y2, y1);
    return;
  }
  add(x2, y1);
  add(y2, x1);
  add(x1, y2);
  add(y1, x2);
  return;
}
void solve0(int i, int j) {
  int x1 = i * 2 - 1, x2 = x1 + 1, y1 = 2 * n + j * 2 - 1, y2 = y1 + 1;
  if (temp[i] == '0' && temp[j] == '0') return;
  if (temp[i] == '0' && temp[j] == '1') {
    add(x1, x2);
    return;
  }
  if (temp[i] == '1' && temp[j] == '0') {
    add(y1, y2);
    return;
  }
  add(x1, y1);
  add(x2, y2);
  add(y1, x1);
  add(y2, x2);
}
void color() {
  queue<int> Q;
  while (!Q.empty()) Q.pop();
  for (int i = 1; i <= id; i++)
    if (ru[i] == 0) Q.push(i);
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    if (allcol[u] == 0) allcol[u] = 1;
    for (int i = 0; i < vec[u].size(); i++) {
      int v = vec[u][i], vv = v + 1;
      col[v] = allcol[u];
      if (v % 2 == 0) vv = v - 1;
      col[vv] = 3 - allcol[u];
      allcol[yt[vv]] = col[vv];
    }
    int e = headnew[u];
    while (e > 0) {
      int v = vetnew[e];
      ru[v]--;
      if (ru[v] == 0) {
        Q.push(v);
      }
      e = jienew[e];
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s", s1[i] + 1);
  for (int i = 1; i <= n; i++) scanf("%s", s2[i] + 1);
  scanf("%s", temp + 1);
  g.clear();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      if (s1[i][j] != s2[i][j])
        solve1(i, j);
      else
        solve0(i, j);
    }
  for (int i = 1; i <= n * 4; i++)
    if (dfn[i] == 0) {
      tarjan(i);
    }
  for (int i = 1; i <= n * 4; i++) {
    int u = yt[i];
    vec[u].push_back(i);
  }
  for (int i = 1; i <= 2 * n; i += 2)
    if (yt[i] == yt[i + 1]) {
      printf("-1\n");
      return 0;
    }
  for (int j = 2 * n + 1; j <= n * 4; j += 2)
    if (yt[j] == yt[j + 1]) {
      printf("-1\n");
      return 0;
    }
  g.clear();
  for (int i = 1; i <= n; i++) {
    int e = head[i];
    while (e > 0) {
      int v = vet[e];
      int uu = yt[i], vv = yt[v];
      if (uu != vv) {
        addnew(vv, uu);
        ru[uu]++;
      }
      e = jie[e];
    }
  }
  color();
  int op = 0;
  for (int i = 1; i <= n; i++)
    if (col[i * 2 - 1] == 1) op++;
  for (int i = 1; i <= n; i++)
    if (col[n * 2 + i * 2 - 1] == 1) op++;
  printf("%d\n", op);
  for (int i = 1; i <= n; i++)
    if (col[i * 2 - 1] == 1) {
      printf("row %d\n", i - 1);
    }
  for (int i = 1; i <= n; i++)
    if (col[2 * n + i * 2 - 1] == 1) {
      printf("col %d\n", i - 1);
    }
  return 0;
}
