#P14624. [2018 KAIST RUN Fall] Dumae

    ID: 14394 Type: RemoteJudge 2000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>2018Special Judge高校校赛

[2018 KAIST RUN Fall] Dumae

题目描述

Do you know Dumae\textit{Dumae}? It is a nickname of the most famous restaurant nearby KAIST, Dumae Charcoal-grilled Barbecue\textit{Dumae Charcoal-grilled Barbecue}. Because Dumae\textit{Dumae} 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 NN students in waiting line and each of them has a distinct student ID from 11 to NN. Student ii (student with student ID ii) guessed that he/she is either LiL_i-th, (Li+1)(L_i+1)-th, ..., (Ri1)(R_i-1)-th, or RiR_i-th person in the line. (i.e. the number of people standing relatively in front of him/her is in the interval [Li1,Ri1]\left[L_{i} - 1, R_{i} - 1\right]) Also, MM claims are made, of which the ii-th says that student viv_i can see student uiu_i in the waiting line. It means student uiu_i is relatively in front of student viv_i.

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 N,MN, M. (1N300000,0M10000001 \leq N \leq 300\,000, 0 \leq M \leq 1\,000\,000)

In the next NN lines, two space-separated integers Li,RiL_i, R_i are given. (1LiRiN1 \leq L_i \leq R_i \leq N)

In the next MM lines, two space-separated integers ui,viu_i, v_i are given. (1uiN1 \leq u_i \leq N, 1viN1 \leq v_i \leq N, uiviu_i \neq v_i)

输出格式

If there is no answer that satisfies the condition, print 1-1.

Otherwise, print NN lines. In the ii-th line, print the student ID of the ii-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