#include <bits/stdc++.h>
using namespace std;
struct event {
  int l, r, id, op;
} a[200002];
int n, m, i, k[200002], ans[200002], cnt;
set<pair<int, int> > s;
int read() {
  char c = getchar();
  int w = 0;
  while (c < '0' || c > '9') c = getchar();
  while (c <= '9' && c >= '0') {
    w = w * 10 + c - '0';
    c = getchar();
  }
  return w;
}
int my_comp(const event &x, const event &y) {
  if (x.l == y.l) return x.op > y.op;
  return x.l < y.l;
}
int main() {
  n = read();
  for (i = 1; i <= n; i++) {
    a[i].l = read(), a[i].r = read();
    a[i].op = 0, a[i].id = i;
  }
  m = read();
  for (i = n + 1; i <= n + m; i++) {
    a[i].l = read(), a[i].r = read(), k[i] = read();
    a[i].op = 1, a[i].id = i;
  }
  sort(a + 1, a + n + m + 1, my_comp);
  for (i = 1; i <= n + m; i++) {
    if (a[i].op == 1)
      s.insert(make_pair(a[i].r, a[i].id));
    else {
      set<pair<int, int> >::iterator it = s.lower_bound(make_pair(a[i].r, 0));
      int p = (*it).second;
      if (it != s.end()) {
        cnt++;
        ans[a[i].id] = p - n, k[p]--;
        if (k[p] == 0) s.erase(it);
      }
    }
  }
  if (cnt == n) {
    puts("YES");
    for (i = 1; i <= n; i++) printf("%d ", ans[i]);
    puts("");
  } else
    puts("NO");
  return 0;
}
