#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e4 + 10;
int n, comp = 0;
;
string a[maxn], b[maxn], x;
vector<int> g[maxn], bg[maxn], myStack;
int mark[maxn], ans[maxn];
void dfs(int u) {
  mark[u] = true;
  for (int i = 0; i < bg[u].size(); i++)
    if (!mark[bg[u][i]]) dfs(bg[u][i]);
  myStack.push_back(u);
  return;
}
void back_dfs(int u) {
  mark[u] = comp;
  for (int i = 0; i < g[u].size(); i++)
    if (mark[g[u][i]] == -1) back_dfs(g[u][i]);
}
void find_comps() {
  memset(mark, 0, sizeof mark);
  for (int i = 0; i < 4 * n; i++) {
    if (!mark[i]) dfs(i);
  }
  memset(mark, -1, sizeof mark);
  comp = 0;
  while (myStack.size() != 0) {
    myStack.pop_back();
    int tmp = *(myStack.end());
    if (mark[tmp] == -1) {
      back_dfs(tmp);
      comp++;
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    if (mark[2 * i] == mark[2 * i + 1]) {
      cout << "-1\n";
      exit(0);
    }
    ans[i] = mark[2 * i] < mark[2 * i + 1];
  }
  int cnt = 0;
  for (int i = 0; i < 2 * n; i++) cnt += ans[i];
  cout << cnt << "\n";
  for (int i = 0; i < 2 * n; i++) {
    if (ans[i]) {
      if (i < n)
        cout << "row " << i << "\n";
      else
        cout << "col " << i - n << "\n";
    }
  }
  exit(0);
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  cin >> x;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i][j] == b[i][j]) {
        if (x[i] == '0' && x[j] == '0')
          continue;
        else if (x[i] == '0' && x[j] == '1') {
          g[2 * i].push_back(2 * i + 1);
          bg[2 * i + 1].push_back(2 * i);
        } else if (x[i] == '1' && x[j] == '0') {
          j += n;
          g[2 * j].push_back(2 * j + 1);
          bg[2 * j + 1].push_back(2 * j);
          j -= n;
        } else {
          j += n;
          g[2 * i].push_back(2 * j);
          g[2 * j + 1].push_back(2 * i + 1);
          g[2 * i + 1].push_back(2 * j + 1);
          g[2 * j].push_back(2 * i);
          bg[2 * j].push_back(2 * i);
          bg[2 * i + 1].push_back(2 * j + 1);
          bg[2 * j + 1].push_back(2 * i + 1);
          bg[2 * i].push_back(2 * j);
          j -= n;
        }
      } else {
        if (x[i] == '0' && x[j] == '0') {
          cout << "-1\n";
          return 0;
        } else if (x[i] == '0' && x[j] == '1') {
          g[2 * i + 1].push_back(2 * i);
          bg[2 * i].push_back(2 * i + 1);
        } else if (x[i] == '1' && x[j] == '0') {
          j += n;
          g[2 * j + 1].push_back(2 * j);
          bg[2 * j].push_back(2 * j + 1);
          j -= n;
        } else {
          j += n;
          g[2 * i + 1].push_back(2 * j);
          g[2 * j + 1].push_back(2 * i);
          g[2 * i].push_back(2 * j + 1);
          g[2 * j].push_back(2 * i + 1);
          bg[2 * j].push_back(2 * i + 1);
          bg[2 * i].push_back(2 * j + 1);
          bg[2 * j + 1].push_back(2 * i);
          bg[2 * i + 1].push_back(2 * j);
          j -= n;
        }
      }
    }
  }
  find_comps();
}
