#include <bits/stdc++.h>
using namespace std;
bool debug = 1;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
struct pp {
  int id, a, b, k;
} p[100005];
struct play {
  int id, c, d;
  bool operator<(const play &o) const { return d < o.d; }
} py[100005];
struct cmpx {
  bool operator()(const pp &a, const pp &o) {
    if (a.b != o.b) return a.b > o.b;
    return a.id > o.id;
  }
};
vector<pair<int, int>> vp;
int ans[100005], tt[100005];
bool del[100005];
void cal() {
  set<pair<int, int>> vs;
  for (auto pp : vp) {
    int tid = pp.second, rid;
    if (tid < 0) {
      assert(tid < -100005);
      rid = -tid - 100005;
      vs.insert({p[rid].b, rid});
    } else if (tid < 100005) {
      rid = tid;
      play z = py[rid];
      auto it = vs.lower_bound({z.d, 0});
      if (it == vs.end()) {
        puts("NO");
        exit(0);
      }
      int pid = (*it).second;
      ans[z.id] = pid;
      if (++tt[pid] == p[pid].k) {
        vs.erase({p[pid].b, pid});
      }
    } else {
      rid = tid - 100005;
      del[rid] = 1;
      vs.erase({p[rid].b, rid});
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    scanf("%d%d", &py[i].c, &py[i].d);
    py[i].id = i;
  }
  sort(py + 1, py + 1 + n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) {
    vp.push_back({py[i].c, i});
  }
  scanf("%d", &m);
  for (int(i) = 1; (i) <= (int)(m); (i)++) {
    scanf("%d%d%d", &p[i].a, &p[i].b, &p[i].k);
    p[i].id = i;
    vp.push_back({p[i].a, -i - 100005});
    vp.push_back({p[i].b, i + 100005});
  }
  sort(vp.begin(), vp.end());
  cal();
  puts("YES");
  for (int(i) = 1; (i) <= (int)(n); (i)++) printf("%d ", ans[i]);
  return 0;
}
