#include <bits/stdc++.h>
using namespace std;
vector<pair<int, pair<int, int> > > songs;
vector<pair<pair<int, int>, pair<int, int> > > singers;
set<pair<pair<int, int>, pair<int, int> > > toQuery;
int ans[100001];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int t1, t2;
    scanf("%d%d", &t1, &t2);
    songs.push_back(make_pair(t1, make_pair(t2, i + 1)));
  }
  sort(songs.begin(), songs.end());
  int m;
  scanf("%d", &m);
  for (int i = 0; i < m; i++) {
    int a, b, k;
    scanf("%d%d%d", &a, &b, &k);
    singers.push_back(make_pair(make_pair(a, b), make_pair(k, i + 1)));
  }
  sort(singers.rbegin(), singers.rend());
  for (int i = 0; i < n; i++) {
    while (singers.size() && singers.back().first.first <= songs[i].first) {
      swap(singers.back().first.first, singers.back().first.second);
      toQuery.insert(singers.back());
      singers.pop_back();
    }
    set<pair<pair<int, int>, pair<int, int> > >::iterator it =
        toQuery.lower_bound(
            make_pair(make_pair(songs[i].second.first, 0), make_pair(0, 0)));
    if (it == toQuery.end()) {
      printf("NO\n");
      return 0;
    }
    ans[songs[i].second.second] = (*it).second.second;
    pair<pair<int, int>, pair<int, int> > temp = *it;
    toQuery.erase(it);
    temp.second.first--;
    if (temp.second.first != 0) toQuery.insert(temp);
  }
  printf("YES\n");
  for (int i = 1; i <= n; i++)
    if (i != n)
      printf("%d ", ans[i]);
    else
      printf("%d\n", ans[i]);
  return 0;
}
