#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000000,100000000000")
using namespace std;
struct pt {
  int a, b, k, n;
  bool act;
  pt() {}
  pt(int a, int b, int n) : a(a), b(b), n(n) {}
  friend bool operator<(pt x, pt y) {
    return x.b < y.b || (x.b == y.b && x.n < y.n);
  }
};
bool asd(pt x, pt y) { return (x.a < y.a) || (x.a == y.a && x.act && !y.act); }
int main() {
  int n;
  cin >> n;
  vector<pt> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i].a >> v[i].b;
    v[i].n = i;
    v[i].k = 0;
    v[i].act = false;
  }
  int m;
  cin >> m;
  v.resize(n + m);
  for (int i = n; i < n + m; ++i) {
    cin >> v[i].a >> v[i].b >> v[i].k;
    v[i].act = true;
    v[i].n = i - n;
  }
  sort(v.begin(), v.end(), asd);
  set<pt> acts;
  vector<int> nom(n);
  for (int i = 0; i < n + m; ++i) {
    if (v[i].act) {
      acts.insert(v[i]);
    } else {
      set<pt>::iterator si = acts.lower_bound(pt(0, v[i].b, -1));
      if (si == acts.end()) {
        cout << "NO";
        return 0;
      }
      pt cur = *si;
      acts.erase(si);
      --cur.k;
      nom[v[i].n] = cur.n;
      if (cur.k) acts.insert(cur);
    }
  }
  cout << "YES\n";
  for (int i = 0; i < n; ++i) cout << nom[i] + 1 << ' ';
  return 0;
}
