#include <bits/stdc++.h>
using namespace std;
struct PARTS {
  int l, r, id;
  bool operator<(const PARTS &b) const {
    if (l != b.l)
      return l < b.l;
    else
      return r < b.r;
  }
} a[100010];
struct ACTOR {
  int l, r, k, id;
  bool operator<(const ACTOR &b) const { return r < b.r; }
  ACTOR(){};
  ACTOR(int l, int r, int k, int id) : l(l), r(r), k(k), id(id){};
} b[100010];
bool cmp(ACTOR a, ACTOR b) { return a.l < b.l; }
int n, m, ans[100010];
int used[100010];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    a[i].l = l, a[i].r = r, a[i].id = i;
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int l, r, k;
    scanf("%d%d%d", &l, &r, &k);
    b[i].l = l, b[i].r = r, b[i].k = k, b[i].id = i;
  }
  sort(a + 1, a + n + 1);
  sort(b + 1, b + m + 1, cmp);
  multiset<ACTOR> s1;
  multiset<ACTOR>::iterator it;
  memset(used, 0, sizeof(used));
  for (int i = 1, j = 1; i <= n; i++) {
    for (; j <= m && (b[j].l <= a[i].l); j++) {
      s1.insert(b[j]);
    }
    if (s1.empty()) {
      printf("NO");
      return 0;
    }
    it = s1.lower_bound(ACTOR(1, a[i].r, 1, 1));
    if (it == s1.end()) {
      printf("NO");
      return 0;
    }
    ans[a[i].id] = it->id;
    used[it->id]++;
    if (used[it->id] == it->k) s1.erase(it);
  }
  printf("YES\n");
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
