#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > part(n), pbh(n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &part[i].first, &part[i].second);
    pbh[i] = pair<int, int>(part[i].second, i);
  }
  sort(pbh.begin(), pbh.end());
  int m;
  scanf("%d", &m);
  vector<pair<int, int> > actor(m);
  vector<int> k(m);
  vector<pair<int, int> > abh(m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &actor[i].first, &actor[i].second, &k[i]);
    abh[i] = pair<int, int>(actor[i].second, i);
  }
  sort(abh.begin(), abh.end());
  bool ok = 1;
  vector<int> will_sing(n);
  set<pair<int, int> > halda;
  for (int i = n - 1; i >= 0; i--) {
    int cur = pbh[i].second;
    while (1) {
      if (abh.size() == 0) break;
      ;
      ;
      if (abh.back().first >= part[cur].second) {
        int id = abh.back().second;
        abh.pop_back();
        halda.insert(pair<int, int>(actor[id].first, id));
      } else
        break;
    }
    while (1) {
      ;
      set<pair<int, int> >::iterator pom =
          halda.upper_bound(pair<int, int>(part[cur].first, 1023456789));
      if (halda.size() == 0 || pom == halda.begin()) {
        ok = 0;
        break;
      }
      pom--;
      int id = pom->second;
      halda.erase(pom);
      if (k[id] <= 0) continue;
      will_sing[cur] = id;
      k[id]--;
      if (k[id] > 0) {
        halda.insert(pair<int, int>(actor[id].first, id));
      }
      break;
    }
    if (!ok) break;
  }
  if (ok) {
    printf("YES\n");
    for (int i = 0; i < n; i++) {
      printf("%d", will_sing[i] + 1);
      if (i < n - 1)
        printf(" ");
      else
        printf("\n");
    }
  } else {
    printf("NO\n");
  }
  return 0;
}
