Puzzle
시간 제한2초메모리 제한2048 MB
각 조각은 H개의 구간이 쌓인 형태이며, 모든 조각을 나란히 놓아 하나의 직사각형을 만드는 순서를 찾는다.
문제
Zigmas has a rectangular jigsaw puzzle of height and width . The puzzle consists of pieces. Each piece is constructed from rectangles of unit height stacked on one another. The pieces are shuffled, but neither rotated nor flipped.
Help Zigmas solve the puzzle by writing down how to order the pieces to get a perfect rectangle. The pieces can't be rotated or flipped, they can't overlap and there must be no gaps left.
입력
The first line contains two integers and (): the number of puzzle pieces and the puzzle height, respectively.
Each of the remaining lines contains integers: -st line describes the -th puzzle piece as (), where is the -coordinate of the left side and the -coordinate of the right side of the -th rectangle of the -th piece.
It is known that each puzzle piece is a connected figure ( and for all and ).
출력
Output distinct integers, each in the range : the numbers of the puzzle pieces in such an order that they form a perfect rectangle when laid out side by side. If there are several solutions, output any one of them. It is known that at least on soluton exists in each test case.