#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 7;
vector<int> op[N];
vector<int> cl[N];
vector<int> st[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  int m;
  cin >> m;
  vector<int> c(m);
  vector<int> d(m);
  vector<int> k(m);
  for (int i = 0; i < m; i++) {
    cin >> c[i] >> d[i] >> k[i];
  }
  {
    vector<int> sn;
    for (auto t : a) sn.push_back(t);
    for (auto t : b) sn.push_back(t);
    for (auto t : c) sn.push_back(t);
    for (auto t : d) sn.push_back(t);
    sort(sn.begin(), sn.end());
    sn.resize(unique(sn.begin(), sn.end()) - sn.begin());
    for (auto &t : a) t = lower_bound(sn.begin(), sn.end(), t) - sn.begin();
    for (auto &t : b) t = lower_bound(sn.begin(), sn.end(), t) - sn.begin();
    for (auto &t : c) t = lower_bound(sn.begin(), sn.end(), t) - sn.begin();
    for (auto &t : d) t = lower_bound(sn.begin(), sn.end(), t) - sn.begin();
  }
  for (int i = 0; i < m; i++) {
    op[c[i]].push_back(i);
    cl[d[i]].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    st[a[i]].push_back(i);
  }
  set<pair<int, int>> s;
  vector<int> ans(n);
  for (int p = 0; p < N; p++) {
    for (auto i : op[p]) {
      s.insert({d[i], i});
    }
    for (auto i : st[p]) {
      if (s.empty() || s.rbegin()->first < b[i]) {
        cout << "NO\n";
        return 0;
      }
      auto it = s.lower_bound(make_pair(b[i], -1));
      int ind = it->second;
      ans[i] = ind;
      s.erase(it);
      k[ind]--;
      if (k[ind] > 0) {
        s.insert({d[ind], ind});
      }
    }
    for (auto i : cl[p]) {
      s.erase({d[i], i});
    }
  }
  cout << "YES\n";
  for (auto t : ans) {
    cout << t + 1 << ' ';
  }
  cout << '\n';
}
