#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n, m, a[N << 1], b[N << 1], c[N << 1], aux[N << 1], p[N << 1], ans[N];
bool cmp(int x, int y) { return a[x] < a[y] || (a[x] == a[y] && c[x] > c[y]); }
void solve(int n) {
  for (int i = 1; i <= n; ++i) c[i] = aux[i];
  sort(p + 1, p + n + 1, cmp);
  set<pair<int, int> > pq;
  int st = p[1] == 0 ? 2 : 1;
  for (int i = st; i <= n; ++i) {
    if (c[p[i]] == -1) {
      if (!pq.empty()) {
        while (-pq.begin()->first < b[p[i]]) {
          pq.erase(*pq.begin());
          if (pq.empty()) break;
        }
        if (pq.empty()) continue;
        set<pair<int, int> >::iterator it =
            pq.upper_bound(make_pair(-b[p[i]], n + 1));
        if (it == pq.begin()) continue;
        --it;
        int wh = it->second;
        ans[p[i]] = wh;
        c[wh]--;
        if (c[wh] == 0) pq.erase(*it);
      }
    } else {
      pq.insert(make_pair(-b[p[i]], p[i]));
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
    p[i] = i;
    aux[i] = -1;
  }
  cin >> m;
  for (int i = n + 1; i <= n + m; ++i) {
    cin >> a[i] >> b[i] >> aux[i];
    p[i] = i;
  }
  solve(n + m);
  bool ok = 0;
  if (ans[1] == 0) {
    cout << "NO\n";
    return 0;
  }
  for (int i = 2; i <= n; ++i) {
    if (ans[i] == 0) {
      cout << "NO\n";
      return 0;
    }
    if (ans[i] != ans[i - 1]) ok = 1;
  }
  cout << "YES\n";
  for (int i = 1; i <= n; ++i) cout << ans[i] - n << ' ';
  cout << '\n';
}
