#include <bits/stdc++.h>
using namespace std;
int N, M;
pair<pair<int, int>, int> A[1000100];
pair<pair<int, int>, pair<int, int> > B[1000100];
int ans[1000100];
set<pair<pair<int, int>, pair<int, int> > > S;
set<pair<pair<int, int>, pair<int, int> > >::iterator it;
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i].first.first >> A[i].first.second;
    A[i].second = i;
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> B[i].first.first >> B[i].first.second >> B[i].second.second;
    B[i].second.first = i + 1;
  }
  sort(A, A + N);
  sort(B, B + M);
  int at = 0;
  for (int i = 0; i < N; i++) {
    int l = A[i].first.first, r = A[i].first.second;
    int to =
        lower_bound(B, B + M,
                    make_pair(pair<int, int>(l + 1, 0), pair<int, int>(0, 0))) -
        B;
    for (int j = at; j < to; j++) {
      S.insert(
          make_pair(pair<int, int>(B[j].first.second, B[j].first.first),
                    pair<int, int>(B[j].second.first, B[j].second.second)));
    }
    at = to;
    it = S.lower_bound(make_pair(pair<int, int>(r, 0), pair<int, int>(0, 0)));
    if (it == S.end()) {
      cout << "NO" << endl;
      return 0;
    }
    ans[A[i].second] = it->second.first;
    if (it->second.second > 1)
      S.insert(
          make_pair(pair<int, int>(it->first.first, it->first.second),
                    pair<int, int>(it->second.first, it->second.second - 1)));
    S.erase(it);
  }
  cout << "YES" << endl;
  for (int i = 0; i < N; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
}
