#include <bits/stdc++.h>
using namespace std;
const int mx = 8002;
bool g[mx][mx], fg[mx][mx], row[mx], mrk[mx], mrk1[mx], cp[mx];
int col[mx];
vector<int> adj[mx], adj1[mx], v;
void dfs(int t) {
  mrk[t] = 1;
  for (int i = 0; i < adj[t].size(); i++) {
    int u = adj[t][i];
    if (!mrk[u]) {
      dfs(u);
    }
  }
  v.push_back(t);
}
void dfs1(int t, int c) {
  col[t] = c;
  mrk1[t] = 1;
  for (int i = 0; i < adj1[t].size(); i++) {
    int u = adj1[t][i];
    if (!mrk1[u]) {
      dfs1(u, c);
    }
  }
}
int main() {
  int n;
  cin >> n;
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < n; j++) {
      g[i][j] = (s[j] == '1') ? 1 : 0;
    }
  }
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < n; j++) {
      fg[i][j] = (s[j] == '1') ? 1 : 0;
    }
  }
  cin >> s;
  for (int i = 0; i < n; i++) {
    row[i] = (s[i] == '1') ? 1 : 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      bool a = g[i][j], fa = fg[i][j];
      bool rc = row[i], rr = row[j];
      if (a == fa) {
        if (rr == 1 && rc == 1) {
          adj[i].push_back(j + n);
          adj[i + 2 * n].push_back(j + 3 * n);
          adj[j + n].push_back(i);
          adj[j + 3 * n].push_back(i + 2 * n);
          adj1[j + n].push_back(i);
          adj1[j + 3 * n].push_back(i + 2 * n);
          adj1[i].push_back(j + n);
          adj1[i + 2 * n].push_back(j + 3 * n);
        }
        if (rr == 1 && rc == 0) {
          adj[i].push_back(i + 2 * n);
          adj1[i + 2 * n].push_back(i);
        }
        if (rr == 0 && rc == 1) {
          adj[j + n].push_back(j + 3 * n);
          adj1[j + 3 * n].push_back(j + n);
        }
      } else {
        if (rr == 1 && rc == 1) {
          adj[i + 2 * n].push_back(j + n);
          adj[i].push_back(j + 3 * n);
          adj[j + 3 * n].push_back(i);
          adj[j + n].push_back(i + 2 * n);
          adj1[j + n].push_back(i + 2 * n);
          adj1[j + 3 * n].push_back(i);
          adj1[i].push_back(j + 3 * n);
          adj1[i + 2 * n].push_back(j + n);
        }
        if (rr == 1 && rc == 0) {
          adj[i + 2 * n].push_back(i);
          adj1[i].push_back(i + 2 * n);
        }
        if (rr == 0 && rc == 1) {
          adj[j + 3 * n].push_back(j + n);
          adj1[j + n].push_back(j + 3 * n);
        }
        if (rr == 0 && rc == 0) {
          cout << -1;
          return 0;
        }
      }
    }
  }
  for (int i = 0; i < 4 * n; i++) {
    if (!mrk[i]) {
      dfs(i);
    }
  }
  int c = 1;
  for (int i = 4 * n - 1; i >= 0; i--) {
    if (!mrk1[v[i]]) {
      dfs1(v[i], c);
      c++;
    }
  }
  for (int i = 0; i < 2 * n; i++) {
    if (col[i] == col[i + 2 * n]) {
      cout << -1;
      return 0;
    } else {
      if (col[i] < col[i + 2 * n]) {
        cp[i + 2 * n] = 1;
      } else {
        cp[i] = 1;
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (cp[i]) {
      cnt++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (cp[i + n]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  for (int i = 0; i < n; i++) {
    if (cp[i]) {
      cout << "row " << i << endl;
    }
  }
  for (int i = 0; i < n; i++) {
    if (cp[i + n]) {
      cout << "col " << i << endl;
    }
  }
}
