#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int maxn = 2e5 + 10;
const int maxv = 1e3 + 10;
const double eps = 1e-9;
struct sta {
  int low, hig, k, id;
  sta(int _low = 0, int _hig = 0, int _k = 0, int _id = 0)
      : low(_low), hig(_hig), k(_k), id(_id) {}
  bool operator<(const sta& rhs) const {
    if (hig == rhs.hig && k == rhs.k) return id < rhs.id;
    if (hig == rhs.hig) return k < rhs.k;
    return hig < rhs.hig;
  }
  void print() const {
    printf("low = %d hig = %d k = %d id = %d\n", low, hig, k, id);
  }
} v[maxn];
bool cmp(sta a, sta b) {
  if (a.low == b.low) return a.k > b.k;
  return a.low < b.low;
}
int ans[maxn];
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    v[i] = sta(a, b, 0, i);
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int a, b, k;
    scanf("%d%d%d", &a, &b, &k);
    v[n + i] = sta(a, b, k, i);
  }
  n += m;
  sort(v + 1, v + 1 + n, cmp);
  int flag = 1;
  set<sta> s;
  for (int i = 1; i <= n; i++) {
    if (v[i].k > 0)
      s.insert(v[i]);
    else {
      auto iter = s.lower_bound(v[i]);
      if (iter == s.end()) {
        flag = 0;
        break;
      }
      ans[v[i].id] = iter->id;
      sta u = (*iter);
      u.k--;
      s.erase(iter);
      if (u.k) s.insert(u);
    }
  }
  if (!flag) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 1; i <= n - m; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
