#include <bits/stdc++.h>
using namespace std;
const int N = int(3e5) + 100;
int n, m;
pair<pair<int, int>, int> a[N];
pair<pair<int, int>, pair<int, int> > p[N];
int ans[N];
set<pair<int, int> > st;
int x;
int y;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a[i].first.second, &a[i].first.first);
    a[i].second = i;
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &p[i].first.second, &p[i].first.first,
          &p[i].second.first);
    p[i].second.second = i;
  }
  sort(a + 1, a + n + 1);
  sort(p + 1, p + m + 1);
  int j = m;
  for (int i = n; i > 0; i--) {
    while (p[j].first.first >= a[i].first.first && j > 0) {
      st.insert(make_pair(-p[j].first.second, j));
      j--;
    }
    x = -a[i].first.second;
    set<pair<int, int> >::iterator it = st.lower_bound(make_pair(x, -1));
    if (it == st.end()) {
      cout << "NO";
      return 0;
    }
    int id = (*it).second;
    ans[a[i].second] = p[id].second.second;
    p[id].second.first--;
    if (p[id].second.first == 0) st.erase(*it);
  }
  puts("YES");
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
