#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long INF = 4e18;
const int inf = 2e9;
const double eps = 1e-13;
const int N = 1e5 + 5;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
vector<pair<pair<int, int>, pair<int, int> > > item;
set<pair<pair<int, int>, int> > actor;
int ans[N];
int main(void) {
  int i, j, n, m;
  scanf("%d", &n);
  for (i = 0; i < n; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    item.push_back(make_pair(make_pair(a, inf), make_pair(b, i)));
  }
  scanf("%d", &m);
  for (i = 0; i < m; ++i) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    item.push_back(make_pair(make_pair(a, c), make_pair(b, i)));
  }
  sort(item.begin(), item.end());
  for (i = 0; i < item.size(); ++i) {
    if (item[i].first.second == inf) {
      pair<pair<int, int>, int> cari =
          make_pair(make_pair(item[i].second.first, 0), 0);
      set<pair<pair<int, int>, int> >::iterator it = actor.lower_bound(cari);
      if (it == actor.end()) {
        puts("NO");
        return 0;
      }
      ans[item[i].second.second] = it->second;
      pair<pair<int, int>, int> newActor = *it;
      actor.erase(it);
      newActor.first.second--;
      if (newActor.first.second > 0) {
        actor.insert(newActor);
      }
    } else {
      actor.insert(
          make_pair(make_pair(item[i].second.first, item[i].first.second),
                    item[i].second.second));
    }
  }
  puts("YES");
  for (i = 0; i < n; ++i) printf("%d ", ans[i] + 1);
  printf("\n");
  return 0;
}
