Tommaso is one of the best Tetris players in the world. Today he became bored of playing the game and decided to create a different version. He wants to fill a grid with the standard Tetris pieces.
The pieces can be rotated, but they cannot overlap or go outside the grid. Help Tommaso by writing a program that, given the size of the grid, finds a way to completely fill it with tetris pieces.
Input data
The first line contains the integers and .
Output data
If it is not possible to fill the grid, you need to write a single line with the number . Otherwise on the first line you need to write the number of pieces used to fill the grid.
Then, you need to write lines with numbers each, where the -th number of the -th line is the number of the piece used to fill the cell . The different pieces must be numbered from to .
Constraints and Clarifications
- .
- .
- If there are multiple solutions, you can print any of them.
- Tommaso has an infinite amount of pieces of each type.
# | Score | Restrictions |
---|---|---|
1 | 0 | Examples. |
2 | 20 | . |
3 | 30 | . |
4 | 50 | No additional limitations. |
Example 1
stdin
2 3
stdout
-1
Explanation
In the first sample case there is no way to completely fill a grid.
Example 2
stdin
4 3
stdout
3
0 0 0
1 2 0
1 2 2
1 1 2
Explanation
In the second sample case a possible way to fill the grid is shown in the image below: