#include <bits/stdc++.h>
using namespace std;
void doit() {
  int n, m, a, b, k;
  vector<pair<pair<int, int>, int> > vp;
  pair<int, int>* p;
  pair<pair<int, int>, int>* t;
  map<int, vector<int> > mp;
  map<int, vector<int> >::iterator it;
  int* r;
  scanf("%d", &n);
  p = new pair<int, int>[n];
  r = new int[n];
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a, &b);
    vp.push_back(make_pair(make_pair(a, 1), i));
    p[i] = make_pair(a, b);
  }
  scanf("%d", &m);
  t = new pair<pair<int, int>, int>[m];
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &a, &b, &k);
    vp.push_back(make_pair(make_pair(a, 0), i));
    t[i] = make_pair(make_pair(a, b), k);
  }
  sort(vp.begin(), vp.end());
  for (int i = 0; i < vp.size(); i++) {
    a = vp[i].second;
    if (vp[i].first.second == 0) {
      mp[t[a].first.second].push_back(a);
    } else {
      it = mp.lower_bound(p[a].second);
      if (it != mp.end()) {
        b = (*it).second[0];
        r[a] = b;
        t[b].second--;
        if (t[b].second == 0) {
          (*it).second.erase((*it).second.begin());
          if ((*it).second.empty()) {
            mp.erase(it);
          }
        }
      } else {
        cout << "NO" << endl;
        return;
      }
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) {
    cout << r[i] + 1 << endl;
  }
  return;
}
int main() {
  doit();
  return 0;
}
