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*<sub class="lower-index">*i*</sub> and *d*<sub class="lower-index">*i*</sub> (*c*<sub class="lower-index">*i*</sub> ≤ *d*<sub class="lower-index">*i*</sub>) — the pitch of the lowest and the highest note that the actor can sing. There also are two integers for each part — *a*<sub class="lower-index">*j*</sub> and *b*<sub class="lower-index">*j*</sub> (*a*<sub class="lower-index">*j*</sub> ≤ *b*<sub class="lower-index">*j*</sub>) — 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*<sub class="lower-index">*i*</sub> ≤ *a*<sub class="lower-index">*j*</sub> ≤ *b*<sub class="lower-index">*j*</sub> ≤ *d*<sub class="lower-index">*i*</sub>, 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*<sub class="lower-index">*i*</sub> 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!
The first line contains a single integer *n* — the number of parts in the play (1 ≤ *n* ≤ 10<sup class="upper-index">5</sup>).

Next *n* lines contain two space-separated integers each, *a*<sub class="lower-index">*j*</sub> and *b*<sub class="lower-index">*j*</sub> — the range of notes for the *j*-th part (1 ≤ *a*<sub class="lower-index">*j*</sub> ≤ *b*<sub class="lower-index">*j*</sub> ≤ 10<sup class="upper-index">9</sup>).

The next line contains a single integer *m* — the number of actors (1 ≤ *m* ≤ 10<sup class="upper-index">5</sup>).

Next *m* lines contain three space-separated integers each, *c*<sub class="lower-index">*i*</sub>, *d*<sub class="lower-index">*i*</sub> and *k*<sub class="lower-index">*i*</sub> — the range of the *i*-th actor and the number of parts that he can perform (1 ≤ *c*<sub class="lower-index">*i*</sub> ≤ *d*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>, 1 ≤ *k*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>).
n = int(input())
a = []
b = []
for i in range(n):
    l,r = map(int,input().split())
    a.append([l,r])
m = int(input())
for i in range(m):
    l,r,x = map(int,input().split())
    b.append([l,r,x])
a.sort()
b.sort()
f = 0
c2 = 0
c = [0] * (n)
for i in range(len(a)):
    c1 = 0
    for j in range(f,len(b)):
        if ((a[i][0] >= b[j][0]) and (a[i][1] <= b[j][1]) and (b[j][2] != 0)):
            b[j][2] = b[j][2] - 1
            c1 = -1
            f = j
            break
    if (c1 != -1):
        print('NO')
        c2 = -1
        break
    else:
        c[i] = f + 1
if (c2 != -1):
    print('YES')
    print(*c)