#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void ckmin(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
void ckmax(T &a, U b) {
  if (a < b) a = b;
}
int N;
bitset<2013> grid[2013];
bitset<2013> arr;
vector<pair<int, int> > edge[2013 << 1];
int req[2013 << 1];
int ans[2013 << 1];
vector<int> guys;
void dfs(int u, bool b) {
  if (ans[u] == (b ^ 1) || req[u] == (b ^ 1)) {
    cout << "-1\n";
    exit(0);
  }
  if (ans[u] == b) return;
  ans[u] = b;
  for (pair<int, int> p : edge[u]) {
    dfs(p.first, b ^ p.second);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  srand(69);
  cin >> N;
  for (auto i = (0); i < (N); i++) {
    string temps;
    cin >> temps;
    for (auto j = (0); j < (N); j++) {
      bool b = (temps[j] == '1');
      grid[i][j] = grid[i][j] ^ b;
    }
  }
  for (auto i = (0); i < (N); i++) {
    string temps;
    cin >> temps;
    for (auto j = (0); j < (N); j++) {
      bool b = (temps[j] == '1');
      grid[i][j] = grid[i][j] ^ b;
    }
  }
  string temps;
  cin >> temps;
  for (auto i = (0); i < (2 * N); i++) {
    req[i] = -1;
    ans[i] = -1;
  }
  for (auto i = (0); i < (N); i++) {
    arr[i] = (temps[i] == '1');
  }
  for (auto i = (0); i < (N); i++) {
    for (auto j = (0); j < (N); j++) {
      if (arr[i]) {
        if (arr[j]) {
          edge[j].push_back({i + N, grid[i][j]});
          edge[i + N].push_back({j, grid[i][j]});
        } else {
          req[j] = grid[i][j];
        }
      } else {
        if (arr[j]) {
          req[i + N] = grid[i][j];
        } else {
          if (grid[i][j]) {
            cout << "-1\n";
            return 0;
          }
        }
      }
    }
  }
  for (auto i = (0); i < (2 * N); i++) {
    if (ans[i] != -1) continue;
    if (req[i] != -1) {
      dfs(i, req[i]);
    }
  }
  for (auto i = (0); i < (2 * N); i++) {
    if (ans[i] != -1) continue;
    dfs(i, (rand() & 1));
  }
  for (auto i = (0); i < (2 * N); i++) {
    if (ans[i] == 1) {
      guys.push_back(i);
    }
  }
  cout << ((int)((guys).size())) << '\n';
  for (int x : guys) {
    if (x < N) {
      cout << "col " << x << '\n';
    } else {
      cout << "row " << x - N << '\n';
    }
  }
  return 0;
}
