#include <bits/stdc++.h>
using namespace std;
const int N = 1001000;
const long long P = 1e9 + 7, INF = 2 * 1e9;
vector<pair<pair<int, int>, pair<int, int> > > eventy;
set<pair<int, int> > aktorzy;
set<pair<int, int> >::iterator it;
int cap[N], nr[N], n, m, a, b;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a, &b);
    eventy.push_back(make_pair(make_pair(a, 1), make_pair(b, i)));
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &a, &b, &cap[i]);
    eventy.push_back(make_pair(make_pair(a, 0), make_pair(b, i)));
  }
  sort(eventy.begin(), eventy.end());
  for (int i = 0; i < eventy.size(); i++) {
    if (eventy[i].first.second == 0) {
      aktorzy.insert(
          make_pair(eventy[i].second.first, eventy[i].second.second));
    } else {
      it = aktorzy.upper_bound(make_pair(eventy[i].second.first, 0));
      if (it == aktorzy.end()) {
        printf("NO");
        return 0;
      }
      nr[eventy[i].second.second] = (*it).second;
      cap[(*it).second]--;
      if (cap[(*it).second] == 0) aktorzy.erase(it);
    }
  }
  printf("YES\n");
  for (int i = 0; i < n; i++) printf("%d ", nr[i]);
}
