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, ci and di (ci ≤ di) — the pitch of the lowest and the highest note that the actor can sing. There also are two integers for each part — aj and bj (aj ≤ bj) — 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 ci ≤ aj ≤ bj ≤ di, 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 ki 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 ≤ 105).

Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109).

The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105).

Next m lines contain three space-separated integers each, ci, di and ki — the range of the i-th actor and the number of parts that he can perform (1 ≤ ci ≤ di ≤ 109, 1 ≤ ki ≤ 109).

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).

Examples

Input

3
1 3
2 4
3 5
2
1 4 2
2 5 1


Output

YES
1 1 2


Input

3
1 3
2 4
3 5
2
1 3 2
2 5 1


Output

NO
#include <bits/stdc++.h>
using namespace std;
void output(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x == 0) {
    putchar('0');
    return;
  }
  int a[20], num = 0;
  while (x) a[++num] = x % 10, x /= 10;
  while (num > 0) putchar('0' + a[num--]);
}
inline long long myInt() {
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  int flag = 1;
  if (c == '-') flag = -1, c = getchar();
  long long x = 0;
  while (isdigit(c)) {
    x = (x * 10) + (c - '0');
    c = getchar();
  }
  if (flag == -1) return -x;
  return x;
}
const int INF = 1e9;
const int N = 400005;
struct node {
  int L, R, cnt;
  int id;
};
node p[N], q[N];
int n, m;
int b[N], bNum;
struct Node {
  int L, R, cnt, Min;
};
Node a[N << 2];
void build(int t, int L, int R) {
  a[t].L = L;
  a[t].R = R;
  a[t].cnt = 0;
  a[t].Min = INF;
  if (L == R) return;
  int M = (L + R) >> 1;
  build(t << 1, L, M);
  build(t << 1 | 1, M + 1, R);
}
int cmp(node a, node b) {
  if (a.L != b.L) return a.L < b.L;
  return a.R < b.R;
}
int ans[N];
struct NNode {
  int next, id, cnt;
};
NNode edges[N * 10];
int e;
int head[N];
void add(int id, int cnt, int y) {
  edges[e].id = id;
  edges[e].cnt = cnt;
  edges[e].next = head[y];
  head[y] = e++;
}
void pushUp(int t) {
  if (a[t].L == a[t].R) return;
  a[t].cnt = 0;
  a[t].Min = INF;
  if (a[t << 1].cnt != 0) {
    a[t].cnt += a[t << 1].cnt;
    a[t].Min = min(a[t].Min, a[t << 1].Min);
  }
  if (a[t << 1 | 1].cnt != 0) {
    a[t].cnt += a[t << 1 | 1].cnt;
    a[t].Min = min(a[t].Min, a[t << 1 | 1].Min);
  }
}
void insert(int t, int y, int cnt) {
  if (a[t].L == a[t].R) {
    a[t].cnt += cnt;
    if (a[t].cnt == 0)
      a[t].Min = INF;
    else
      a[t].Min = a[t].L;
    return;
  }
  int M = (a[t].L + a[t].R) >> 1;
  if (y <= M)
    insert(t << 1, y, cnt);
  else
    insert(t << 1 | 1, y, cnt);
  pushUp(t);
}
int get(int t, int y) {
  if (a[t].L >= y) {
    if (a[t].cnt == 0) return -1;
    return a[t].Min;
  }
  int M = (a[t].L + a[t].R) >> 1;
  if (y <= M) {
    int tmp = get(t << 1, y);
    if (tmp != -1) return tmp;
  }
  return get(t << 1 | 1, y);
}
int cal(int t) {
  int p = head[t];
  int ans = edges[p].id;
  edges[p].cnt--;
  if (edges[p].cnt == 0) {
    head[t] = edges[p].next;
  }
  return ans;
}
int main() {
  n = myInt();
  for (int i = 1; i <= n; i++) {
    p[i].L = myInt();
    p[i].R = myInt();
    p[i].cnt = i;
    b[++bNum] = p[i].L;
    b[++bNum] = p[i].R;
  }
  m = myInt();
  for (int i = 1; i <= m; i++) {
    q[i].L = myInt();
    q[i].R = myInt();
    q[i].cnt = myInt();
    q[i].id = i;
    b[++bNum] = q[i].L;
    b[++bNum] = q[i].R;
  }
  sort(b + 1, b + bNum + 1);
  int M = unique(b + 1, b + bNum + 1) - (b + 1);
  for (int i = 1; i <= n; i++) {
    p[i].L = lower_bound(b + 1, b + M + 1, p[i].L) - b;
    p[i].R = lower_bound(b + 1, b + M + 1, p[i].R) - b;
  }
  for (int i = 1; i <= m; i++) {
    q[i].L = lower_bound(b + 1, b + M + 1, q[i].L) - b;
    q[i].R = lower_bound(b + 1, b + M + 1, q[i].R) - b;
  }
  build(1, 1, M);
  sort(p + 1, p + n + 1, cmp);
  sort(q + 1, q + m + 1, cmp);
  memset(head, -1, sizeof(head));
  int cur = 1;
  for (int i = 1; i <= n; i++) {
    while (cur <= m && q[cur].L <= p[i].L) {
      insert(1, q[cur].R, q[cur].cnt);
      add(q[cur].id, q[cur].cnt, q[cur].R);
      cur++;
    }
    int t = get(1, p[i].R);
    if (t == -1) {
      puts("NO");
      return 0;
    }
    insert(1, t, -1);
    ans[p[i].cnt] = cal(t);
  }
  puts("YES");
  for (int i = 1; i <= n; i++) {
    printf("%d", ans[i]);
    if (i < n) putchar(' ');
  }
  puts("");
}
