Codeforces Round 283 (Div. 1)
C
Distributing Parts
Codeforces
未评级
原题
← BD →
翻译中…

You are an assistant director in a new musical play. The play consists of $*n*$ musical parts, each part must be performed by exactly one actor. After the casting the director chose $*m*$ actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.

翻译中…

First, each actor has a certain voice range and there are some parts that he cannot sing. Formally, there are two integers for each actor, $*c*_{*i*}$ and $*d*_{*i*}$ ($*c*_{*i*} ≤ *d*_{*i*}$) — the pitch of the lowest and the highest note that the actor can sing. There also are two integers for each part — $*a*_{*j*}$ and $*b*_{*j*}$ ($*a*_{*j*} ≤ *b*_{*j*}$) — the pitch of the lowest and the highest notes that are present in the part. The $*i*$-th actor can perform the $*j*$-th part if and only if $*c*_{*i*} ≤ *a*_{*j*} ≤ *b*_{*j*} ≤ *d*_{*i*}$, i.e. each note of the part is in the actor's voice range.

翻译中…

According to the contract, the $*i*$-th actor can perform at most $*k*_{*i*}$ parts. Besides, you are allowed not to give any part to some actors (then they take part in crowd scenes).

翻译中…

The rehearsal starts in two hours and you need to do the assignment quickly!

翻译中…

Input

翻译中…

The first line contains a single integer $*n*$ — the number of parts in the play ($1 ≤ *n* ≤ 10^{5}$).

翻译中…

Next $*n*$ lines contain two space-separated integers each, $*a*_{*j*}$ and $*b*_{*j*}$ — the range of notes for the $*j*$-th part ($1 ≤ *a*_{*j*} ≤ *b*_{*j*} ≤ 10^{9}$).

翻译中…

The next line contains a single integer $*m*$ — the number of actors ($1 ≤ *m* ≤ 10^{5}$).

翻译中…

Next $*m*$ lines contain three space-separated integers each, $*c*_{*i*}$, $*d*_{*i*}$ and $*k*_{*i*}$ — the range of the $*i*$-th actor and the number of parts that he can perform ($1 ≤ *c*_{*i*} ≤ *d*_{*i*} ≤ 10^{9}$, $1 ≤ *k*_{*i*} ≤ 10^{9}$).

翻译中…

Output

翻译中…

If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line.

翻译中…

In the next line print $*n*$ space-separated integers. The $*i*$-th integer should be the number of the actor who should perform the $*i*$-th part. If there are multiple correct assignments, print any of them.

翻译中…

If there is no correct assignment, print a single word "NO" (without the quotes).

翻译中…

样例

Input #1
3
1 3
2 4
3 5
2
1 4 2
2 5 1
Output #1
YES
1 1 2
InputCopy OutputCopy
Input #2
3
1 3
2 4
3 5
2
1 3 2
2 5 1
Output #2
NO
InputCopy OutputCopy
题目信息
题号
497C
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。