#include <bits/stdc++.h>
using namespace std;
struct fast_ios {
  fast_ios() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  };
} fast_ios_;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  for (long long i = 0; i < v.size(); i++) {
    cout << v[i];
    if (i != v.size() - 1) cout << endl;
  };
  return os;
}
template <typename T>
void Out(T x) {
  cout << x << endl;
}
template <typename T1, typename T2>
void Ans(bool first, T1 y, T2 n) {
  if (first)
    Out(y);
  else
    Out(n);
}
using vec = vector<long long>;
using mat = vector<vec>;
using Pii = pair<long long, long long>;
using PiP = pair<long long, Pii>;
using PPi = pair<Pii, long long>;
using bools = vector<bool>;
using pairs = vector<Pii>;
const long long mod = 1000000007;
signed main() {
  long long n;
  cin >> n;
  vec a(n), b(n);
  vector<PPi> pa(n);
  for (long long i = (0); i < (n); i++) {
    cin >> a[i] >> b[i];
    pa[i] = PPi(Pii(a[i], -b[i]), i);
  }
  sort(pa.begin(), pa.end());
  long long m;
  cin >> m;
  vec c(m), d(m), k(m);
  vector<PPi> pc(m);
  for (long long i = (0); i < (m); i++) {
    cin >> c[i] >> d[i] >> k[i];
    pc[i] = PPi(Pii(c[i], d[i]), i);
  }
  sort(pc.begin(), pc.end());
  map<long long, set<long long>> U;
  vec ans(n);
  long long l = 0;
  for (long long i = (0); i < (n); i++) {
    long long i0 = pa[i].second;
    while (l < m && pc[l].first.first <= a[i0]) {
      U[pc[l].first.second].insert(pc[l].second);
      l++;
    }
    auto it = U.lower_bound(b[i0]);
    if (it == U.end()) {
      Out("NO");
      return 0;
    }
    long long x = *((it->second).begin());
    ans[i0] = x;
    k[x]--;
    if (k[x] == 0) {
      (it->second).erase(x);
      if (((long long)it->second.size()) == 0) U.erase(it);
    }
  }
  Out("YES");
  for (long long i = (0); i < (n); i++) cout << ans[i] + 1 << ' ';
  cout << endl;
  return 0;
}
