Sam the monkey has recently been playing a grid game in his AAC retirement home. Keenan the monkey came to visit him, and Sam showed him his game.
Sam's game is played on a grid with rows and columns. Each move, Sam chooses an empty cell and it is filled with the smallest positive integer not present in that row or column.
Sam has been having trouble getting the number to appear. Keenan, for some reason, told him that it was easy to achieve , so Sam challenged him to get it to appear for the first time on a move between the and move inclusive.
Keenan is actually unsure that this is possible, or how to do it, so please help him out.
Constraints
Subtask 1 [20%]
Subtask 2 [30%]
Subtask 3 [50%]
No additional constraints.
Input Specification
The first and only line of input will contain five space-separated integers, .
Output Specification
If it is impossible to produce between the and move inclusive, output on its own line.
Otherwise, output an integer which is the number of moves you used to achieve .
lines should follow each containing integers and , denoting a move at cell .
If you output an invalid cell, repeat a cell, produce before the move, or do not produce on the move, you will receive WA
.
Note: Any valid output will be accepted.
Sample Input
4 4 4 1 16
Sample Output
6
1 1
2 1
3 1
1 2
1 3
1 4
Explanation
The moves produce, in order, the values .
Comments