#include <bits/stdc++.h>
using namespace std;
const int MX = 2010, MX2 = 9000;
bool table1[MX][MX], table2[MX][MX], ans[MX2], mark[MX2], magic[MX2];
vector<int> order, adj[MX2], adjr[MX2];
int n, mark1[MX2];
int NOT(int i) {
  if (i % 2) return i - 1;
  return i + 1;
}
void add_or(int i, int j) {
  adj[NOT(i)].push_back(j);
  adj[NOT(j)].push_back(i);
  adjr[i].push_back(NOT(j));
  adjr[j].push_back(NOT(i));
}
pair<int, int> g_i(int i) { return {2 * i, 2 * i + 1}; }
pair<int, int> g_j(int j) {
  j += n;
  return {j * 2, j * 2 + 1};
}
void DFS1(int u) {
  mark[u] = 1;
  for (auto x : adjr[u])
    if (!mark[x]) DFS1(x);
  order.push_back(u);
}
void DFS2(int u, int comp) {
  mark1[u] = comp;
  for (auto x : adj[u])
    if (!mark1[x]) DFS2(x, comp);
}
bool solve() {
  for (int i = 0; i < 4 * n; i++)
    if (!mark[i]) DFS1(i);
  reverse(order.begin(), order.end());
  int comp = 1;
  for (auto x : order)
    if (!mark1[x]) DFS2(x, comp), comp++;
  for (int i = 0; i < 2 * n; i++) {
    if (mark1[i * 2] == mark1[i * 2 + 1]) return false;
    ans[i] = mark1[i * 2] < mark1[i * 2 + 1];
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    string temp;
    cin >> temp;
    for (int j = 0; j < n; j++) table1[i][j] = (int)temp[j] - (int)'0';
  }
  for (int i = 0; i < n; i++) {
    string temp;
    cin >> temp;
    for (int j = 0; j < n; j++) table2[i][j] = (int)temp[j] - (int)'0';
  }
  string temp;
  cin >> temp;
  for (int i = 0; i < n; i++) magic[i] = (int)temp[i] - (int)'0';
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (table1[i][j] == table2[i][j]) {
        if (magic[i] == 1 and magic[j] == 1) {
          add_or(g_i(i).first, g_j(j).second);
          add_or(g_i(i).second, g_j(j).first);
        } else if (magic[i] == 1 and magic[j] == 0) {
          add_or(g_j(j).second, g_j(j).second);
        } else if (magic[i] == 0 and magic[j] == 1) {
          add_or(g_i(i).second, g_i(i).second);
        }
      } else {
        if (magic[i] == 1 and magic[j] == 1) {
          add_or(g_i(i).first, g_j(j).first);
          add_or(g_i(i).second, g_j(j).second);
        } else if (magic[i] == 1 and magic[j] == 0) {
          add_or(g_j(j).first, g_j(j).first);
        } else if (magic[i] == 0 and magic[j] == 1) {
          add_or(g_i(i).first, g_i(i).first);
        } else {
          cout << -1 << endl;
          return 0;
        }
      }
    }
  }
  bool k = solve();
  if (!k) {
    cout << -1 << endl;
    return 0;
  }
  int num = 0;
  for (int i = 0; i < 2 * n; i++) num += ans[i];
  cout << num << endl;
  for (int i = 0; i < 2 * n; i++)
    if (ans[i]) {
      if (i < n)
        cout << "row " << i << endl;
      else
        cout << "col " << i - n << endl;
    }
  return 0;
}
