각 조각의 네 변 모양이 반시계 방향으로 주어질 때, n개의 조각을 맞물려 h x w 직사각형으로 완성할 수 있는지 판정하고 배치를 출력한다.
어려움8그래프DFS구현해시맵아직 제출이 없습니다시간 제한2초메모리 제한512 MBYou found a box with old games when cleaning up your attic, and among them was also a jigsaw puzzle. Unfortunately, the packaging was damaged, so a couple of puzzle pieces are scattered around the bottom of the box, and you suspect that some of the pieces may have been lost elsewhere. In fact, given the orderliness of your attic, some of the pieces in the box may even come from some entirely different puzzle! So now you have a pile of puzzle pieces lying in front of you and you are trying to assemble them into a solved puzzle.

Figure J.1: Illustration of the first sample.
More formally:
The input consists of:
A connection of type 0 stands for a straight edge. The other connection types are numbered with consecutive positive integers starting from 1 and each of them occurs exactly two times, on two different lines.
If the pieces cannot be assembled as described above, output impossible. Otherwise, output the solved puzzle in the following format:
Any rotation of the correct solution will by accepted.