#P1718E. Impressionism
Impressionism
Description
Burenka has two pictures and , which are tables of the same size . Each cell of each painting has a color — a number from to , and there are no repeating colors in any row or column of each of the two paintings, except color .
Burenka wants to get a picture from the picture . To achieve her goal, Burenka can perform one of operations: swap any two rows of or any two of its columns. Tell Burenka if she can fulfill what she wants, and if so, tell her the sequence of actions.
The rows are numbered from to from top to bottom, the columns are numbered from to from left to right.
The first line contains two integers and () — the sizes of the table.
The -th of the next lines contains integers () — the colors of the -th row of picture . It is guaranteed that there are no identical colors in the same row or column, except color .
The -th of the following lines contains integers () — the colors of the -th row of picture . It is guaranteed that there are no identical colors in the same row or column, except color .
In the first line print the number if it is impossible to achieve what Burenka wants, otherwise print the number of actions in your solution (). It can be proved that if a solution exists, then there exists a solution where .
In the next lines print the operations. First print the type of the operation ( — swap rows, — columns), and then print the two indices of rows or columns to which the operation is applied.
Note that you don't have to minimize the number of operations.
Input
The first line contains two integers and () — the sizes of the table.
The -th of the next lines contains integers () — the colors of the -th row of picture . It is guaranteed that there are no identical colors in the same row or column, except color .
The -th of the following lines contains integers () — the colors of the -th row of picture . It is guaranteed that there are no identical colors in the same row or column, except color .
Output
In the first line print the number if it is impossible to achieve what Burenka wants, otherwise print the number of actions in your solution (). It can be proved that if a solution exists, then there exists a solution where .
In the next lines print the operations. First print the type of the operation ( — swap rows, — columns), and then print the two indices of rows or columns to which the operation is applied.
Note that you don't have to minimize the number of operations.