#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int n, m;
struct GUGAN {
  int s, e;
  int type;
  int idx, x;
  bool operator<(const GUGAN &p) const { return e < p.e; }
  GUGAN() {}
  GUGAN(int s, int e, int type, int idx, int x) {
    this->s = s, this->e = e, this->type = type, this->idx = idx, this->x = x;
  }
};
bool cmp(GUGAN p, GUGAN q) {
  if (p.s != q.s) return p.s < q.s;
  return p.type < q.type;
}
vector<GUGAN> v;
multiset<GUGAN> s;
int dab[200000];
int main() {
  int i, j, k;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v.push_back(GUGAN(x, y, 2, i, -1));
  }
  scanf("%d", &m);
  for (i = 0; i < m; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    v.push_back(GUGAN(x, y, 1, i, z));
  }
  sort(v.begin(), v.end(), cmp);
  for (auto e : v) {
    if (e.type == 1)
      s.insert(e);
    else {
      auto it = s.lower_bound(GUGAN(0, e.e, 0, 0, 0));
      if (it == s.end()) return printf("NO"), 0;
      GUGAN u = *it;
      s.erase(it);
      u.x--;
      dab[e.idx] = u.idx;
      if (u.x != 0) s.insert(u);
    }
  }
  printf("YES\n");
  for (i = 0; i < n; i++) printf("%d ", dab[i] + 1);
  return 0;
}
