#include <bits/stdc++.h>
using namespace std;
void yesno(bool a) {
  if (a) {
    cout << "YES" << '\n';
  } else {
    cout << "NO" << '\n';
  }
}
long long power(long long x, long long n, long long m) {
  if (n == 0) return 1;
  long long u = power(x, n / 2, m);
  u = (u * u) % m;
  if (n % 2) u = (u * x) % m;
  return u;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  pair<pair<int, int>, int> parts[n];
  int i;
  for (i = 0; i < n; i++) {
    cin >> parts[i].first.first >> parts[i].first.second;
    parts[i].second = i;
  }
  sort(parts, parts + n);
  int m;
  cin >> m;
  pair<pair<int, int>, pair<int, int> > actors[m];
  for (i = 0; i < m; i++) {
    cin >> actors[i].first.first >> actors[i].first.second >>
        actors[i].second.first;
    actors[i].second.second = i;
  }
  sort(actors, actors + m);
  int pos = 0;
  int p1 = 0;
  multiset<pair<int, pair<int, int> > > s;
  int ans[n];
  while (pos < n) {
    while (p1 < m && actors[p1].first.first <= parts[pos].first.first) {
      s.insert({actors[p1].first.second,
                {actors[p1].second.first, actors[p1].second.second}});
      p1++;
    }
    auto it = s.lower_bound({parts[pos].first.second, {-1, -1}});
    if (it == s.end()) break;
    pair<int, pair<int, int> > temp = (*it);
    if (temp.second.first > 1)
      s.insert({temp.first, {temp.second.first - 1, temp.second.second}});
    s.erase(it);
    ans[parts[pos].second] = temp.second.second;
    pos++;
  }
  if (pos == n) {
    cout << "YES" << '\n';
    for (i = 0; i < n; i++) cout << ans[i] + 1 << " ";
  } else
    cout << "NO" << '\n';
}
