#include <bits/stdc++.h>
using namespace std;
const int MX = 2e3 + 10;
bool a[MX][MX], m[MX];
int n, c[4 * MX];
vector<int> adj[4 * MX];
int NOT(int x) {
  if (x <= 2 * n) return x + 2 * n;
  return x - 2 * n;
}
int alaki = 1, impos = 0;
void solve(int i, int j) {
  if (a[i][j] == 0) {
    if (m[i] == 0) {
      if (m[j] == 0) {
        alaki = 1;
      } else {
        if (c[i] == -1 || c[i] == 0) {
          c[NOT(i)] = 1;
          c[i] = 0;
        } else {
          impos = 1;
        }
      }
    } else {
      if (m[j] == 0) {
        if (c[j + n] == -1 || c[j + n] == 0) {
          c[NOT(j + n)] = 1;
          c[j + n] = 0;
        }
      } else {
        if (c[i] == 0) {
          if (c[j + n] == -1 || c[j + n] == 0) {
            c[j + n] = 0;
            c[NOT(j + n)] = 1;
          } else
            impos = 1;
        } else if (c[i] == 1) {
          if (c[j + n] == -1 || c[j + n] == 1) {
            c[j + n] = 1;
            c[NOT(j + n)] = 0;
          } else
            impos = 1;
        } else if (c[j + n] == 0) {
          if (c[i] == 0 || c[i] == -1) {
            c[i] = 0;
            c[NOT(i)] = 1;
          } else
            impos = 1;
        } else if (c[j + n] == 1) {
          if (c[i] == -1 || c[i] == 1) {
            c[i] = 1;
            c[NOT(i)] = 0;
          } else
            impos = 1;
        } else {
          adj[NOT(i)].push_back(NOT(j + n));
          adj[j + n].push_back(i);
          adj[NOT(j + n)].push_back(NOT(i));
          adj[i].push_back(j + n);
        }
      }
    }
  } else {
    if (m[i] == 0) {
      if (m[j] == 0) {
        impos = 1;
      } else {
        if ((c[i] == -1 || c[i] == 1)) {
          c[i] = 1;
          c[NOT(i)] = 0;
        } else {
          impos = 1;
        }
      }
    } else {
      if (m[j] == 0) {
        if (c[j + n] == -1 || c[j + n] == 1) {
          c[j + n] = 1;
          c[NOT(j + n)] = 0;
        } else {
          impos = 1;
        }
      } else {
        if (c[i] == 0) {
          if (c[j + n] == -1 || c[j + n] == 1) {
            c[j + n] = 1;
            c[NOT(j + n)] = 0;
          } else
            impos = 1;
        } else if (c[i] == 1) {
          if (c[j + n] == -1 || c[j + n] == 0) {
            c[j + n] = 0;
            c[NOT(j + n)] = 1;
          } else
            impos = 1;
        } else if (c[j + n] == 0) {
          if (c[i] == -1 || c[i] == 1) {
            c[i] = 1;
            c[NOT(i)] = 0;
          } else
            impos = 1;
        } else if (c[j + n] == 1) {
          if (c[i] == -1 || c[i] == 0) {
            c[i] = 0;
            c[NOT(i)] = 1;
          } else
            impos = 1;
        } else {
          adj[i].push_back(NOT(j + n));
          adj[j + n].push_back(NOT(i));
          adj[NOT(j + n)].push_back(i);
          adj[NOT(i)].push_back(j + n);
        }
      }
    }
  }
}
bool mrk[4 * MX];
int l = 0;
vector<int> comps[4 * MX];
void dfs1(int v) {
  mrk[v] = 1;
  comps[l].push_back(v);
  for (int u : adj[v]) {
    if (!mrk[u]) dfs1(u);
  }
}
set<int> s;
set<int> ans;
void dfs_ans(int v) {
  mrk[v] = 1;
  if (v <= 2 * n) ans.insert(v);
  c[v] = 1;
  c[NOT(v)] = 0;
  for (int u : adj[v]) {
    if (!mrk[u]) dfs_ans(u);
  }
}
void dfs_ans2(int v) {
  mrk[v] = 1;
  if (v > 2 * n) ans.insert(NOT(v));
  c[v] = 0;
  c[NOT(v)] = 1;
  for (int u : adj[v]) {
    if (!mrk[u]) dfs_ans2(u);
  }
}
int main() {
  fill(c, c + 4 * MX, -1);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      char h;
      cin >> h;
      if (h == '1')
        a[i][j] = 1;
      else
        a[i][j] = 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      char h;
      cin >> h;
      int k = h - '0';
      a[i][j] ^= k;
    }
  }
  for (int i = 1; i <= n; i++) {
    char h;
    cin >> h;
    int k = h - '0';
    m[i] = k;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      solve(i, j);
      if (impos == 1) {
        cout << -1 << endl;
        return 0;
      }
    }
  }
  for (int i = 1; i <= 4 * n; i++) {
    if (!mrk[i]) dfs1(i);
    l++;
  }
  for (int i = 0; i < l; i++) {
    for (int v : comps[i]) {
      s.insert(v);
      if (s.count(NOT(v))) {
        cout << -1 << endl;
        return 0;
      }
    }
    s.clear();
  }
  fill(mrk, mrk + 4 * MX, 0);
  int t = 4 * n;
  while (t--) {
    for (int i = 1; i <= 2 * n; i++) {
      if (c[i] == 1 && !mrk[i])
        dfs_ans(i);
      else if (c[i] == 0 && !mrk[i])
        dfs_ans2(i);
    }
  }
  for (int i = 1; i < 2 * n; i++) {
    if (!mrk[i]) {
      if (c[i] == -1 || c[i] == 1) {
        c[i] = 1;
        dfs_ans(i);
      } else {
        dfs_ans2(i);
      }
    }
  }
  cout << ans.size() << endl;
  for (int v : ans) {
    if (c[v] == 1) {
      if (v <= n)
        cout << "row " << v - 1 << endl;
      else if (v <= 2 * n)
        cout << "col " << v - n - 1 << endl;
    }
  }
}
