Magical Plants
문제
John is growing plants on the windowsill. These are no ordinary plants: they are in telepathic communication with one another and will grow only if some other plants are already tall enough.
There are pots on the windowsill, numbered . Initially there is nothing planted in any of the pots. Also, there are constraints of the form "the plant in pot can grow metres tall only if the plant in is already at least metres tall".
Days consist of minutes. Each day, the following happens:
- On the -th minute (for every ): if there is a plant growing in the -th pot, it will grow 1 metre taller unless that would violate one of the constraints.
- On the -st minute: John can choose a pot with no plant in it, and plant a plant there. Initially, a plant is 1 metre tall.
We need each plant to be at least metres tall to brew a potion. Find the minimum number of days necessary, assuming John plants the plants optimally. Find one optimal way to plant the plants.
It is guaranteed that in all test cases it is possible to plant the plants so that all plants will grow metres tall in at most days.
입력
The first line of the input consists of three space-separated integers , and (, ).
The next lines describe the constraints. The -th such row consists of four integers , , , (, , ), describing a constraint.
출력
The first line of the output must consist of the minimum number of days needed for all plants to grow at least metres tall.
The second line must consist of integers, each from the interval . Of those, the -th should be the day John plants the -th plant.
If there are multiple optimal solutions, you can print any one of them.
예제
예제 1
4 3 4 4 4 3 4 2 2 4 2 1 3 3 2
7 2 4 3 1
예제 2
5 4 1000000000 1 2 2 1000000000 2 2 3 1000000000 3 2 4 1000000000 4 2 5 1000000000
4999999996 5 4 3 2 1