WEDDING

    In our villages, the wedding tables are rectangulare, various sizes,
and the wedding guests are sittings on the both sides of the table. No
person sits at the heads of the tables! At one of the wedding party were
invited only traditional families (husband and wife), but during the
wedding persons switched their places, so that some families the husband
and wife do not stay together.
    At a specific time (festive moment) husbands and their wives should
stay together, [no necessarily at same table as at the beginning] [but
not at the same table as they stood before]. Determine the minimum
necessary number of moves so that every husband and his wife should stay
at the same table and beside one another; at the margin places of the
tables should stay only men! Determine a succession of such moves, too!
A moving means placing one person on another sit.

Input/output restrictions:
Input datas are read from the file NUNTA.INP.
The file contains one set of testing datas with the following structure:
n                   //number of invited families, n<=1000
k                   //number of tables, k<=200
p1 p2 ... pk        // pi = number of free places on one side of the table i, i=1,k
a1,1 a1,2 ... a1,p1    // indexes of persons sitting at table 1, in order, on the side 1
a2,1 a2,2 ... a2,p1    // indexes of persons sitting at table 1, in order, on the side 2
a3,1 a3,2 ... a3,p2    // indexes of persons sitting at table 2, in order, on the side 1
a4,1 a4,2 ... a4,p2    // indexes of persons sitting at table 2, in order, on the side 2
...
a2k-1,1 a2k-1,2 ... a2k-1,pk  // indexes of persons sitting at table k, in order, on the side 1
a2k,1 a2k,2 ... a2k,pk        // indexes of persons sitting at table k, in order, on the side 2

Output file, NUNTA.OUT, contains the message NU EXISTA SOLUTIE or has the
following structure:
- on the first line MIN, the minimum number of necessary moves;
- each of the following MIN lines represents a move, given by the
specification of the index of the person who moves, number of table which
he moves to, the side and the place on which he sits, separated by spaces.

Observations:
1. Persons are numbered from 1 to 2n.
2. Every man has his index an odd number, his wife has her index the
following even number.
3. Tables are completely occupated.
4. Every moment can be standing no more than 2 persons (standing doesn't
include the moving of a person from one place to another in that moment).

Sample input 1:
4
1
4
4 2 3 1
5 6 8 7

Sample outpu 1:
3
1 1 1 1
3 1 1 4
4 1 1 3

Sample input 2:
8
2
3 5
1 4 2
6 7 10
3 5 11 12 13
14 16 15 9 8

Sample output 2:
NU EXISTA SOLUTIE
                           teacher Emanuela Mateescu
                                 High-school "G. Moisil" Iasi
                           teacher Marinel Serban
                                 High-school "G. Moisil" Timisoara
