#include <bits/stdc++.h>
using namespace std;
char s[2010][2010];
char t[2010][2010];
char s1[2010][2010];
char t1[2010][2010];
char x[2010];
vector<int> row, col;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= n; i++) scanf("%s", t[i] + 1);
  scanf("%s", x + 1);
  for (int i = 1; i <= n; i++) {
    x[i] -= '0';
    for (int j = 1; j <= n; j++) {
      s[i][j] -= '0';
      t[i][j] -= '0';
    }
  }
  memcpy(s1, s, sizeof(s));
  memcpy(t1, t, sizeof(t));
  int idx = -1;
  for (int i = 1; i <= n; i++) {
    if (x[i] == 1) {
      idx = i;
      break;
    }
  }
  if (idx == -1) {
    bool flag = false;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (s[i][j] != t[i][j]) flag = true;
    if (flag)
      return 0 * puts("-1");
    else
      return 0 * puts("0");
  }
  for (int i = 1; i <= n; i++) {
    if (s[i][idx] != t[i][idx]) {
      row.push_back(i);
      for (int j = 1; j <= n; j++) s[i][j] = s[i][j] ^ x[j];
    }
  }
  for (int i = 1; i <= n; i++) {
    bool flag = false;
    for (int j = 1; j <= n; j++) {
      if (s[j][i] != t[j][i]) {
        col.push_back(i);
        flag = true;
        break;
      }
    }
    if (flag) {
      for (int j = 1; j <= n; j++) {
        s[j][i] = s[j][i] ^ x[j];
      }
    }
  }
  bool succ = true;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) succ &= (s[i][j] == t[i][j]);
  if (succ) {
    cout << col.size() + row.size() << endl;
    for (int i = 0; i < col.size(); i++) {
      cout << "col " << col[i] - 1 << endl;
    }
    for (int i = 0; i < row.size(); i++) {
      cout << "row " << row[i] - 1 << endl;
    }
    return 0;
  } else {
    memcpy(s, s1, sizeof(s));
    memcpy(t, t1, sizeof(t));
    col.clear();
    row.clear();
    for (int i = 1; i <= n; i++) {
      if (s[i][idx] != t[i][idx]) {
        if (x[i] == 0) {
          row.push_back(i);
          for (int j = 1; j <= n; j++) s[i][j] = s[i][j] ^ x[j];
        }
      } else if (s[i][idx] == t[i][idx]) {
        if (x[i] == 1) {
          row.push_back(i);
          for (int j = 1; j <= n; j++) s[i][j] = s[i][j] ^ x[j];
        }
      }
    }
    for (int i = 1; i <= n; i++) {
      bool flag = false;
      for (int j = 1; j <= n; j++) {
        if (s[j][i] != t[j][i]) {
          col.push_back(i);
          flag = true;
          break;
        }
      }
      if (flag) {
        for (int j = 1; j <= n; j++) {
          s[j][i] = s[j][i] ^ x[j];
        }
      }
    }
    bool succ = true;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++) succ &= (s[i][j] == t[i][j]);
    if (succ) {
      cout << col.size() + row.size() << endl;
      for (int i = 0; i < col.size(); i++) {
        cout << "col " << col[i] - 1 << endl;
      }
      for (int i = 0; i < row.size(); i++) {
        cout << "row " << row[i] - 1 << endl;
      }
      return 0;
    } else {
      return 0 * puts("-1");
    }
  }
  return 0;
}
