#include <bits/stdc++.h>
using namespace std;
int main() {
  int nb_parts;
  scanf("%d", &nb_parts);
  vector<pair<int, int> > parts(nb_parts);
  vector<pair<int, pair<int, int> > > gesorteerd;
  for (int i = 0; i < nb_parts; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    parts[i] = make_pair(a, b);
    gesorteerd.push_back(make_pair(a, make_pair(2, i)));
  }
  int nb_actors;
  scanf("%d", &nb_actors);
  vector<pair<int, pair<int, int> > > actors(nb_actors);
  vector<int> beschikbaar(nb_actors);
  for (int i = 0; i < nb_actors; i++) {
    int c, d, k;
    scanf("%d %d %d", &c, &d, &k);
    actors[i] = make_pair(c, make_pair(d, k));
    beschikbaar[i] = k;
    gesorteerd.push_back(make_pair(c, make_pair(1, i)));
    gesorteerd.push_back(make_pair(d, make_pair(3, i)));
  }
  sort(gesorteerd.begin(), gesorteerd.end());
  set<pair<int, int> > se;
  vector<int> antwoord(nb_parts, -1);
  for (int i = 0; i < gesorteerd.size(); i++) {
    if (gesorteerd[i].second.first == 1) {
      int idx = gesorteerd[i].second.second;
      se.insert(make_pair(actors[idx].second.first, idx));
    } else if (gesorteerd[i].second.first == 2) {
      int idx = gesorteerd[i].second.second;
      int eindpunt = parts[idx].second;
      set<pair<int, int> >::iterator it =
          se.lower_bound(make_pair(eindpunt, -1));
      if (it == se.end()) {
        printf("NO\n");
        return 0;
      }
      int actor_idx = (*it).second;
      antwoord[idx] = actor_idx;
      beschikbaar[actor_idx]--;
      if (beschikbaar[actor_idx] == 0) {
        se.erase(it);
      }
    } else {
      int idx = gesorteerd[i].second.second;
      se.erase(make_pair(actors[idx].second.first, idx));
    }
  }
  printf("YES\n");
  for (int i = 0; i < antwoord.size(); i++) {
    if (i != 0) {
      printf(" ");
    }
    printf("%d", antwoord[i] + 1);
  }
  printf("\n");
  return 0;
}
