| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 74 | 39 | 39 | 58.209% |
Coming back home after triumphally winning your long-coveted trophy, you discover that it was shattered to pieces in your trunk. It just remains to repair it.
Your trophy had the shape of a rectangle of size 3ドル \times N,ドル for some integer $N \ge 1,ドル thereby consisting of 3ドル$ lines and $N$ columns, containing a total of 3ドルN$ unit squares. It was broken into $K$ pieces, the $k$th piece being a rectangle of size $A_k \times B_k$ for some integers $A_k$ and $B_k$ such that 1ドル \le A_k \le B_k \le 3$. Such pieces may have been rotated, or even flipped, in the havoc that is your trunk.
As the first step towards repairing your trophy, you should reassemble them in the form of a rectangle of size 3ドル \times N$. More precisely, you have drawn, on a sheet of paper, a 3ドル \times N$ rectangle on which you will place your $K$ pieces, and you need to know, for all integers $i \le 3$ and $j \le N,ドル which piece will cover the unit square on the $i$th line and $j$th column of your rectangle.
The input consists of three lines, each one containing space-separated integers. The first line contains the numbers $K$ and $N$. The second line contains the numbers $A_1, A_2, \dots , A_K$. The third line contains the numbers $B_1, B_2, \dots, B_K$.
The output should contain three lines, each one consisting of $N$ space-separated integers. If you plan to cover the unit square on the $i$th line and $j$th column with the $k$th piece, the $j$th number on the $i$th output line should be the integer $k$.
In case there are several ways to reassemble your pieces in the form of a rectangle of size 3ドル \times N,ドル every output representing one of these ways is considered correct.
16 17 1 2 1 1 2 1 2 1 1 1 1 1 2 2 1 1 3 3 1 3 2 3 3 1 1 2 2 3 3 3 1 3
1 2 2 2 12 6 4 13 13 16 16 16 9 10 10 7 7 1 2 2 2 12 6 4 13 13 5 5 14 14 14 11 7 7 1 3 15 8 12 6 4 13 13 5 5 14 14 14 11 7 7
This output represents the following reassembling:
16 17 1 2 1 1 2 1 2 1 1 1 1 1 2 2 1 1 3 3 1 3 2 3 3 1 1 2 2 3 3 3 1 3
4 2 2 2 1 1 1 7 7 6 6 6 10 10 15 14 14 4 2 2 2 16 16 16 7 7 5 5 13 13 13 9 14 14 4 11 11 3 12 12 12 7 7 5 5 13 13 13 8 14 14
This output represents the following reassembling:
Both reassemblings are valid, even though sample inputs 1 and 2 are the same.