For her birthday Alice received an interesting gift from her friends – The Light Square. The Light Square game is played on an N × N lightbulbs square board with a magical lightbulb bar of size N × 1 that has magical properties. At the start of the game some lights on the square board and magical bar are turned on. The goal of the game is to transform the starting light square board pattern into some other pattern using the magical bar without rotating the square board. The magical bar works as follows: 

It can be placed on any row or column 

The orientation of the magical lightbulb must be left to right or top to bottom for it to keep its magical properties 

The entire bar needs to be fully placed on a board 

The lights of the magical bar never change 

If the light on the magical bar is the same as the light of the square it is placed on it will switch the light on the square board off, otherwise it will switch the light on 

The magical bar can be used an infinite number of times 

Alice has a hard time transforming her square board into the pattern Bob gave her. Can you help her transform the board or let her know it is impossible? If there are multiple solutions print any. 

Input

The first line contains one positive integer number N\ (1 ≤ N ≤ 2000) representing the size of the square board. 

The next N lines are strings of length N consisting of 1's and 0's representing the initial state of the square board starting from the top row. If the character in a string is 1 it means the light is turned on, otherwise it is off. 

The next N lines are strings of length N consisting of 1's and 0's representing the desired state of the square board starting from the top row that was given to Alice by Bob. 

The last line is one string of length N consisting of 1's and 0's representing the pattern of the magical bar in a left to right order. 

Output

Transform the instructions for Alice in order to transform the square board into the pattern Bob gave her. The first line of the output contains an integer number M\ (0 ≤ M ≤ 10^5) representing the number of times Alice will need to apply the magical bar. 

The next M lines are of the form "col X" or "row X", where X is 0-based index of the matrix, meaning the magical bar should be applied to either row X or column X. If there is no solution, print only -1. In case of multiple solutions print any correct one. 

Examples

Input


2
11
11
00
01
11


Output


-1


Input


2
10
00
00
00
10


Output


1
row 0


Input


3
110
011
100
100
011
100
100


Output


3
row 0
col 0
col 1

Note

Example 1: It is impossible to transform square board from one format to another

Example 2: Magic bar can be applied on first row or column.
#include <bits/stdc++.h>
const int N = 4050;
int n;
std::vector<int> G[N << 1];
bool mark[N << 1];
int S[N << 1], c;
bool dfs(int x) {
  if (mark[x ^ 1]) return 0;
  if (mark[x]) return 1;
  mark[x] = 1;
  S[c++] = x;
  for (int i = 0; i < G[x].size(); ++i)
    if (!dfs(G[x][i])) return 0;
  return 1;
}
void init(int xd) {
  n = xd;
  for (int i = 0; i < 2 * n; ++i) G[i].clear();
  memset(mark, 0, sizeof(mark));
}
void add_clause(int x, int xval, int y, int yval) {
  x = (x << 1) + xval;
  y = (y << 1) + yval;
  G[x ^ 1].push_back(y);
  G[y ^ 1].push_back(x);
}
void add_xor(int x, int y) {
  add_clause(x, 0, y, 0);
  add_clause(x, 1, y, 1);
}
void add_xnor(int x, int y) {
  add_clause(x, 1, y, 0);
  add_clause(x, 0, y, 1);
}
void add_true(int x) { add_clause(x, 1, x, 1); }
void add_false(int x) { add_clause(x, 0, x, 0); }
bool solve() {
  for (int i = 0; i < 2 * n; i += 2)
    if (!mark[i] && !mark[i + 1]) {
      c = 0;
      if (!dfs(i)) {
        while (c) mark[S[--c]] = 0;
        if (!dfs(i + 1)) return 0;
      }
    }
  return 1;
}
void fail() {
  std::cout << -1 << "\n";
  std::exit(0);
}
int mat[2005][2005];
int tab[2005];
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  int first;
  std::cin >> first;
  for (int i = 0; i < (first); ++i) {
    for (int j = 0; j < (first); ++j) {
      char x;
      std::cin >> x;
      mat[i][j] = (int)(x == '1');
    }
  }
  for (int i = 0; i < (first); ++i) {
    for (int j = 0; j < (first); ++j) {
      char a;
      std::cin >> a;
      mat[i][j] ^= (int)(a == '1');
    }
  }
  for (int i = 0; i < (first); ++i) {
    char x;
    std::cin >> x;
    tab[i] = (int)(x == '1');
  }
  init(2 * first);
  for (int i = 0; i < (first); ++i) {
    for (int j = 0; j < (first); ++j) {
      int a = tab[j];
      int b = tab[i];
      if (mat[i][j] == 1) {
        if (a == 0 && b == 0) fail();
        if (a == 1 && b == 0) add_true(i);
        if (a == 0 && b == 1) add_true(first + j);
        if (a == 1 && b == 1) add_xor(i, first + j);
      } else {
        if (a == 1 && b == 0) add_false(i);
        if (a == 0 && b == 1) add_false(first + j);
        if (a == 1 && b == 1) add_xnor(i, first + j);
      }
    }
  }
  if (solve() == false)
    std::cout << -1 << "\n";
  else {
    std::vector<std::pair<int, int> > ans;
    for (int i = 0; i < (first); ++i)
      if (mark[(i << 1) + 1]) ans.push_back(std::make_pair(0, i));
    for (int i = 0; i < (first); ++i)
      if (mark[((i + first) << 1) + 1]) ans.push_back(std::make_pair(1, i));
    std::cout << (int)(ans).size() << "\n";
    for (auto &i : (ans)) {
      if (i.first == 0)
        std::cout << "row " << i.second << "\n";
      else
        std::cout << "col " << i.second << "\n";
    }
  }
  return 0;
}
