#include <bits/stdc++.h>
using namespace std;
int n;
int a[2005][2005];
int b[2005][2005];
int magic[2005];
string s;
vector<int> adj[100005], rev_adj[100005];
int scc[100005];
vector<int> scc_adj[100005];
stack<int> stk;
bool vis[100005];
int in[100005];
int tim[100005];
vector<int> topo;
vector<pair<int, int> > ans;
void dfs(int i) {
  vis[i] = 1;
  for (auto j : adj[i])
    if (!vis[j]) dfs(j);
  stk.push(i);
}
void rev_dfs(int i, int r) {
  scc[i] = r;
  vis[i] = 1;
  for (auto j : rev_adj[i])
    if (!vis[j]) rev_dfs(j, r);
}
void work_scc() {
  for (int i = 1; i <= 4 * n; i++)
    if (!vis[i]) dfs(i);
  memset(vis, 0, sizeof vis);
  while (stk.size()) {
    int x = stk.top();
    stk.pop();
    if (vis[x]) continue;
    rev_dfs(x, x);
  }
  for (int i = 1; i <= 4 * n; i++)
    if (scc[i] == i)
      for (auto j : adj[i])
        if (scc[i] != scc[j]) scc_adj[i].push_back(scc[j]), in[scc[j]]++;
  int tot = 0;
  for (int i = 1; i <= 4 * n; i++)
    if (scc[i] == i) {
      tot++;
      if (in[i] == 0) topo.push_back(i);
    }
  int cur = 0;
  while ((int)topo.size() < tot) {
    int sz = topo.size();
    for (; cur < sz; cur++) {
      int i = topo[cur];
      for (auto j : scc_adj[i]) {
        in[j]--;
        if (in[j] == 0) topo.push_back(j);
      }
    }
  }
  for (int i = 0; i < (int)topo.size(); i++) tim[topo[i]] = i;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    for (int j = 1; j <= n; j++) a[i][j] = s[j - 1] - '0';
  }
  for (int i = 1; i <= n; i++) {
    cin >> s;
    for (int j = 1; j <= n; j++) b[i][j] = s[j - 1] - '0';
  }
  cin >> s;
  for (int i = 1; i <= n; i++) magic[i] = s[i - 1] - '0';
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[i][j] != b[i][j]) {
        if (magic[i] == 0 && magic[j] == 0) return cout << "-1" << '\n', 0;
        if (magic[j] && !magic[i])
          adj[i + 2 * n].push_back(i), rev_adj[i].push_back(i + 2 * n);
        else if (magic[i] && !magic[j])
          adj[j + n + 2 * n].push_back(j + n),
              rev_adj[j + n].push_back(j + n + 2 * n);
        else {
          adj[i].push_back(j + n + 2 * n), rev_adj[j + n + 2 * n].push_back(i);
          adj[i + 2 * n].push_back(j + n), rev_adj[j + n].push_back(i + 2 * n);
          adj[j + n].push_back(i + 2 * n), rev_adj[i + 2 * n].push_back(j + n);
          adj[j + n + 2 * n].push_back(i), rev_adj[i].push_back(j + n + 2 * n);
        }
      } else {
        if (magic[j] && !magic[i])
          adj[i].push_back(i + 2 * n), rev_adj[i + 2 * n].push_back(i);
        else if (magic[i] && !magic[j])
          adj[j + n].push_back(j + n + 2 * n),
              rev_adj[j + n + 2 * n].push_back(j + n);
        else if (magic[i] && magic[j]) {
          adj[i].push_back(j + n), rev_adj[j + n].push_back(i);
          adj[j + n].push_back(i), rev_adj[i].push_back(j + n);
          adj[i + 2 * n].push_back(j + n + 2 * n),
              rev_adj[j + n + 2 * n].push_back(i + 2 * n);
          adj[j + n + 2 * n].push_back(i + 2 * n),
              rev_adj[i + 2 * n].push_back(j + n + 2 * n);
        }
      }
    }
  }
  work_scc();
  for (int i = 1; i <= 2 * n; i++)
    if (scc[i] == scc[i + 2 * n]) return cout << "-1" << '\n', 0;
  for (int i = 1; i <= n; i++)
    if (tim[scc[i]] > tim[scc[i + 2 * n]]) ans.push_back(make_pair(0, i));
  for (int i = n + 1; i <= 2 * n; i++)
    if (tim[scc[i]] > tim[scc[i + 2 * n]]) ans.push_back(make_pair(1, i - n));
  cout << ans.size() << '\n';
  for (auto j : ans)
    if (j.first == 0)
      cout << "row " << j.second - 1 << '\n';
    else
      cout << "col " << j.second - 1 << '\n';
  return 0;
}
