#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (auto i = begin(v); i != end(v); i++)
    os << *i << (i == end(v) - 1 ? "" : " ");
  return os;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto i = begin(v); i != end(v); i++) is >> *i;
  return is;
}
vector<vector<pair<int, int>>> g;
vector<int> will_use;
bool visited[10000000];
bool run_dfs(int v) {
  if (visited[v]) return true;
  visited[v] = true;
  if (will_use[v] == -1) will_use[v] = 1;
  for (auto u : g[v]) {
    int targ_use = will_use[v] ^ u.second;
    if (will_use[u.first] != -1 && will_use[u.first] != targ_use) return false;
    will_use[u.first] = targ_use;
    if (!run_dfs(u.first)) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<string> orig(n), target(n);
  cin >> orig >> target;
  string row;
  cin >> row;
  g.resize(2 * n);
  will_use.resize(2 * n, -1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int h_vtx = i, v_vtx = n + j;
      bool needs_change = orig[i][j] != target[i][j];
      bool h_bit = (row[j] == '1');
      bool v_bit = (row[i] == '1');
      if (needs_change) {
        if (h_bit && !v_bit) {
          if (will_use[h_vtx] != -1 && !will_use[h_vtx]) {
            cout << -1;
            return 0;
          }
          will_use[h_vtx] = true;
        } else if (!h_bit && v_bit) {
          if (will_use[v_vtx] != -1 && !will_use[v_vtx]) {
            cout << -1;
            return 0;
          }
          will_use[v_vtx] = true;
        } else if (h_bit && v_bit) {
          g[h_vtx].push_back({v_vtx, 1});
          g[v_vtx].push_back({h_vtx, 1});
        } else {
          cout << -1;
          return 0;
        }
      } else {
        if (h_bit && !v_bit) {
          if (will_use[h_vtx] != -1 && will_use[h_vtx]) {
            cout << -1;
            return 0;
          }
          will_use[h_vtx] = false;
        } else if (!h_bit && v_bit) {
          if (will_use[v_vtx] != -1 && will_use[v_vtx]) {
            cout << -1;
            return 0;
          }
          will_use[v_vtx] = false;
        } else if (h_bit && v_bit) {
          g[h_vtx].push_back({v_vtx, 0});
          g[v_vtx].push_back({h_vtx, 0});
        }
      }
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    if (will_use[i] != -1 && !run_dfs(i)) {
      cout << -1;
      return 0;
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    if (!run_dfs(i)) {
      cout << -1;
      return 0;
    }
  }
  vector<string> ans;
  for (int i = 0; i < 2 * n; i++) {
    if (will_use[i]) {
      string val = "";
      if (i < n)
        val = "row " + to_string(i);
      else
        val = "col " + to_string(i - n);
      ans.push_back(val);
    }
    for (auto u : g[i]) {
      if (will_use[i] != (u.second ^ will_use[u.first])) {
        cout << -1;
        return 0;
      }
    }
  }
  cout << ans.size() << "\n";
  for (auto x : ans) cout << x << "\n";
  return 0;
}
