#include <bits/stdc++.h>
using namespace std;
int n, a, b, c, d, k, m, q, z;
const int MXN = 1e5 + 5;
int who[MXN];
set<pair<int, int> > S;
int C[MXN];
int main() {
  scanf("%d", &n);
  vector<pair<int, pair<int, int> > > events;
  for (int i = 1; i <= (n); i++) {
    scanf("%d%d", &a, &b);
    events.push_back(make_pair(b, make_pair(i, a)));
  }
  scanf("%d", &m);
  for (int i = 1; i <= (m); i++) {
    scanf("%d%d%d", &a, &b, &C[i]);
    events.push_back(make_pair(b, make_pair(1e9 + i, a)));
  }
  sort(events.begin(), events.end());
  for (int i = 0; i < (events.size()); i++) {
    int a = events[i].second.second;
    int type = events[i].second.first;
    if (type <= n) {
      S.insert(make_pair(a, type));
    } else {
      type -= 1e9;
      int k = C[type];
      set<pair<int, int> >::iterator it = S.upper_bound(make_pair(a, 0)), it2;
      while (k && it != S.end()) {
        k--;
        it2 = it;
        it++;
        who[it2->second] = type;
        S.erase(it2);
      }
    }
  }
  if (S.size() != 0) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 1; i <= (n); i++) printf("%d ", who[i]);
}
