Little E fell in love with a game called "Meow Meow". This game has a pile of cards and
At the beginning, there are
- Choose a stack and put the top card of the deck on top of the stack. If after doing this, the top two cards of the stack have the same pattern, these two cards will be eliminated automatically.
- Choose two different stacks. If the cards at the bottom of the two stacks have the same pattern, these two cards can be eliminated, and the card above the bottom of the stack will become the new bottom of the stack. If different, nothing will be done.
There are a total of
Input Specification
The first line contains a positive integer
Next, there are
- The first line contains three positive integers
, , , which respectively represent the number of stacks, the number of cards, and the type of pattern on the card. - The second line contains
positive integers, representing , respectively, representing the pattern of the cards in the deck from top to bottom.
The input data is guaranteed to have a solution.
Output Specification
For each set of data, output several lines.
The first line contains a positive integer
For the next
- If two integers 1
, do the first operation once and select stack . - three integers 2
, do a second operation and select stacks and .
You need to guarantee that
Sample Input 1
1
2 4 2
1 2 1 2
Sample Output 1
5
1 1
1 1
1 2
2 1 2
1 1
Explanation of Sample 1
Additional Samples
Additional sample cases can be found here.
Included is a grader meow_e.cpp
.
Constraints
Let
For all data, guarnatee
Case | ||||
---|---|---|---|---|
no additional constraints | ||||
no additional constraints | ||||
Note that you can use the value of
Comments