#P14624. [2018 KAIST RUN Fall] Dumae
[2018 KAIST RUN Fall] Dumae
题目描述
Do you know ? It is a nickname of the most famous restaurant nearby KAIST, . Because is a very famous restaurant, lots of KAIST students stand in line even though it has not opened yet. Students wonder how long they have to wait, so they started to guess their order.
There are students in waiting line and each of them has a distinct student ID from to . Student (student with student ID ) guessed that he/she is either -th, -th, ..., -th, or -th person in the line. (i.e. the number of people standing relatively in front of him/her is in the interval ) Also, claims are made, of which the -th says that student can see student in the waiting line. It means student is relatively in front of student .
You wonder if all of students' guesses and claims were right. Find an order of waiting line that satisfies all the guesses and claims, or report that such an order does not exist.
输入格式
The first line contains two space-separated integers . ()
In the next lines, two space-separated integers are given. ()
In the next lines, two space-separated integers are given. (, , )
输出格式
If there is no answer that satisfies the condition, print .
Otherwise, print lines. In the -th line, print the student ID of the -th student from the front.
3 3
1 3
1 3
1 3
1 2
2 3
3 1
-1
3 3
1 3
1 3
1 3
1 2
2 3
1 3
1
2
3