Dumae

각 학생이 가능한 위치 구간과 M개의 선후 관계 u가 v보다 앞선다는 조건을 모두 만족하는 줄 순서를 찾고, 없으면 -1을 출력한다.

어려움8위상 정렬그리디그래프아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Do you know Dumae? It is a nickname of the most famous restaurant nearby KAIST, Dumae Charcoal-grilled Barbecue. Because 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 L_iL\_i-th, (L_i+1)(L\_i+1)-th, \cdots, (R_i1)(R\_i-1)-th, or R_iR\_i-th person in the line. (i.e. the number of people standing relatively in front of him/her is in the interval \left\[L\_{i} - 1,\ R\_{i} - 1\right]) Also, MM claims are made, of which the ii-th says that student v_iv\_i can see student u_iu\_i in the waiting line. It means student u_iu\_i is relatively in front of student v_iv\_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. (1N300,000, 0M1,000,0001 \leq N \leq 300,000,\ 0 \leq M \leq 1,000,000)

In the next NN lines, two space-separated integers L_i, R_iL\_i,\ R\_i are given. (1L_iR_iN1 \leq L\_i \leq R\_i \leq N)

In the next MM lines, two space-separated integers u_i, v_iu\_i,\ v\_i are given. (1u_iN1 \leq u\_i \leq N, 1v_iN1 \leq v\_i \leq N, u_iv_iu\_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.