#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 1;
struct node {
  int a, b, k, vt;
};
int n, m, res[MAX], cnt;
node data[MAX];
multimap<int, int> myMap;
multimap<int, int>::iterator itSet;
bool cmp(const node& x, const node& y) {
  if (x.a != y.a) return x.a > y.a;
  if (x.b != y.b) return x.b < y.b;
  return x.k < y.k;
}
multimap<int, int>::iterator findSet(const int& val) {
  if (myMap.empty()) return myMap.end();
  multimap<int, int>::iterator res = myMap.lower_bound(val);
  if (res == myMap.end() || res->first != val)
    if (res == myMap.begin())
      return myMap.end();
    else
      --res;
  return res;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> data[i].a >> data[i].b;
    data[i].vt = i;
  }
  cin >> m;
  for (int i = n + 1; i <= n + m; ++i) {
    cin >> data[i].a >> data[i].b >> data[i].k;
    data[i].vt = i - n;
  }
  sort(data + 1, data + 1 + n + m, cmp);
  myMap.clear();
  for (int i = 1; i <= n + m; ++i)
    if (data[i].k) {
      do {
        map<int, int>::iterator it = findSet(data[i].b);
        if (it == myMap.end()) break;
        res[it->second] = data[i].vt;
        ++cnt;
        myMap.erase(it);
        --data[i].k;
      } while (data[i].k);
    } else {
      myMap.insert(pair<int, int>(data[i].b, data[i].vt));
    }
  if (cnt < n)
    cout << "NO";
  else {
    cout << "YES\n";
    for (int i = 1; i <= n; ++i) cout << res[i] << ' ';
  }
  return 0;
}
