#include <bits/stdc++.h>
using namespace std;
const int nmax = 2e5 + 42;
struct singer {
  int c, d, songs, ind;
};
int n;
singer inp[nmax];
bool cmp(singer a, singer b) {
  if (a.c != b.c) return a.c < b.c;
  if (a.songs >= 0 && b.songs >= 0) return 0;
  if (a.songs < 0 && b.songs < 0) return 0;
  return a.songs > b.songs;
}
int outp[nmax];
set<pair<pair<long long, long long>, long long> > active;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> inp[i].c >> inp[i].d;
    inp[i].songs = -1;
    inp[i].ind = i;
  }
  int m;
  cin >> m;
  for (int i = n + 1; i <= n + m; i++) {
    cin >> inp[i].c >> inp[i].d >> inp[i].songs;
    inp[i].ind = i - n;
  }
  sort(inp + 1, inp + n + m + 1, cmp);
  for (int i = 1; i <= n + m; i++) {
    if (inp[i].songs > 0) {
      active.insert({{inp[i].d, inp[i].songs}, inp[i].ind});
    } else {
      set<pair<pair<long long, long long>, long long> >::iterator it =
          active.lower_bound({{inp[i].d, 0}, 0});
      if (it == active.end()) {
        cout << "NO" << endl;
        return 0;
      }
      pair<pair<long long, long long>, long long> val = *it;
      outp[inp[i].ind] = val.second;
      val.first.second--;
      active.erase(it);
      if (val.first.second) active.insert(val);
    }
  }
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) cout << outp[i] << " ";
  cout << endl;
  return 0;
}
