#include <bits/stdc++.h>
using namespace std;
mt19937 Rand(time(0));
class TwoSat {
 private:
  struct Node {
    int low, num, compID;
    vector<int> adj;
    Node() {
      adj = vector<int>();
      low = num = compID = 0;
    }
  };
  vector<Node> nodes;
  struct Component {
    vector<int> adj, opp;
    int value, topo;
    bool vis;
    Component() {
      adj = vector<int>();
      opp = vector<int>();
      value = topo = -1;
      vis = false;
    }
  };
  vector<Component> components;
  int numNode, numComp, times;
  stack<int> st;
  int NODE_ID(int u, bool type) {
    if (u > numNode)
      return type ? u : u - numNode;
    else
      return type ? u : u + numNode;
  }
  void addEdge(int u, int v) { nodes[u].adj.push_back(v); }
  void dfs(int u) {
    nodes[u].low = nodes[u].num = ++times;
    st.push(u);
    for (auto v : nodes[u].adj) {
      if (nodes[v].compID) continue;
      if (nodes[v].num)
        nodes[u].low = min(nodes[u].low, nodes[v].num);
      else {
        dfs(v);
        nodes[u].low = min(nodes[u].low, nodes[v].low);
      }
    }
    if (nodes[u].low == nodes[u].num) {
      numComp++;
      while (true) {
        int v = st.top();
        st.pop();
        nodes[v].compID = numComp;
        if (v == u) break;
      }
    }
  }
  void dfsTopo(int u) {
    components[u].vis = true;
    for (auto v : components[u].adj) {
      if (components[v].vis == false) dfsTopo(v);
    }
    components[u].topo = times--;
  }
  void AssignValue(int u, int value) {
    if (components[u].value != -1) {
      assert(components[u].value == value);
      return;
    }
    components[u].value = value;
    for (auto v : components[u].opp) AssignValue(v, 1 - value);
    if (value == 1)
      for (auto v : components[u].adj) AssignValue(v, value);
  }

 public:
  void addChoiceCondition(int u, bool typeu, int v, bool typev) {
    u = NODE_ID(u, typeu);
    v = NODE_ID(v, typev);
    addEdge(NODE_ID(u, false), NODE_ID(v, true));
    addEdge(NODE_ID(v, false), NODE_ID(u, true));
  }
  TwoSat(int numNode) {
    this->numNode = numNode;
    nodes.assign(2 * numNode + 5, Node());
    numComp = times = 0;
  }
  bool haveSolution() {
    for (int u = (1); u <= (numNode * 2); ++u)
      if (nodes[u].num == 0) dfs(u);
    for (int u = (1); u <= (numNode); ++u)
      if (nodes[NODE_ID(u, true)].compID == nodes[NODE_ID(u, false)].compID)
        return false;
    return true;
  }
  vector<bool> getSolution() {
    components.assign(numComp + 5, Component());
    for (int u = (1); u <= (2 * numNode); ++u) {
      for (auto v : nodes[u].adj)
        if (nodes[u].compID != nodes[v].compID) {
          components[nodes[u].compID].adj.push_back(nodes[v].compID);
        }
      int POS = nodes[NODE_ID(u, true)].compID;
      int NEG = nodes[NODE_ID(u, false)].compID;
      components[POS].opp.push_back(NEG);
    }
    for (int u = (1); u <= (numComp); ++u)
      if (components[u].vis == false) dfsTopo(u);
    vector<pair<int, int> > allComp;
    for (int u = (1); u <= (numComp); ++u)
      allComp.push_back({components[u].topo, u});
    sort((allComp).begin(), (allComp).end());
    for (__typeof((allComp).begin()) it = (allComp).begin();
         it != (allComp).end(); ++it) {
      if (components[it->second].value == -1) AssignValue(it->second, 0);
    }
    vector<bool> res(numNode + 1, false);
    for (int u = (1); u <= (numNode); ++u)
      res[u] = components[nodes[u].compID].value;
    return res;
  }
};
const int maxn = 2000 + 912;
int n;
char a[maxn][maxn], b[maxn][maxn];
char s[maxn];
int idRow[maxn], idCol[maxn];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (n); ++j) cin >> a[i][j];
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (n); ++j) cin >> b[i][j];
  int numNode = 0;
  for (int i = (1); i <= (n); ++i) {
    cin >> s[i];
    idRow[i] = ++numNode;
    idCol[i] = ++numNode;
  }
  TwoSat ts(numNode);
  for (int i = (1); i <= (n); ++i) {
    for (int j = (1); j <= (n); ++j) {
      int v = idRow[i], u = idCol[j];
      if (a[i][j] != b[i][j]) {
        if (s[i] == s[j]) {
          if (s[i] == '0') return cout << -1, 0;
          ts.addChoiceCondition(u, true, v, true);
          ts.addChoiceCondition(u, false, v, false);
        } else {
          if (s[i] == '0')
            ts.addChoiceCondition(v, true, v, true);
          else
            ts.addChoiceCondition(u, true, u, true);
        }
      } else {
        if (s[i] == s[j]) {
          if (s[i] == '1') {
            ts.addChoiceCondition(u, true, v, false);
            ts.addChoiceCondition(u, false, v, true);
          }
        } else {
          if (s[i] == '1')
            ts.addChoiceCondition(u, false, u, false);
          else
            ts.addChoiceCondition(v, false, v, false);
        }
      }
    }
  }
  if (ts.haveSolution() == false) return cout << -1, 0;
  vector<bool> res = ts.getSolution();
  cout << count((res).begin(), (res).end(), true) << "\n";
  for (int i = (1); i <= (n); ++i)
    if (res[idRow[i]] == true) cout << "row " << i - 1 << "\n";
  for (int i = (1); i <= (n); ++i)
    if (res[idCol[i]] == true) cout << "col " << i - 1 << "\n";
  return 0;
}
