#include <bits/stdc++.h>
int dr[] = {2, 2, -2, -2, 1, -1, 1, -1};
int dc[] = {1, -1, 1, -1, 2, 2, -2, -2};
int dr1[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dc1[] = {1, -1, 1, 0, -1, 0, 1, -1};
int dr2[] = {0, 0, 1, -1};
int dc2[] = {1, -1, 0, 0};
using namespace std;
long long int a[500005], b[500005], c[500005], d[500005], e[500005];
vector<pair<long long int, long long int> > adj[500005];
vector<pair<long long int, long long int> > v[500005];
long long int tree[500005 * 3];
void update(long long int n, long long int b, long long int e, long long int x,
            long long int val) {
  if (b == e) {
    tree[n] = val;
    return;
  }
  long long int mid = (b + e) >> 1, l = n * 2, r = l + 1;
  if (x <= mid)
    update(l, b, mid, x, val);
  else
    update(r, mid + 1, e, x, val);
  tree[n] = min(tree[l], tree[r]);
}
bool f = 0;
long long int pos;
void query1(long long int n, long long int b, long long int e,
            long long int y1) {
  if (b == e) {
    f = 1;
    pos = b;
    return;
  }
  long long int mid = (b + e) >> 1, l = n * 2, r = l + 1;
  if (tree[l] <= y1)
    query1(l, b, mid, y1);
  else
    query1(r, mid + 1, e, y1);
}
void query(long long int n, long long int b, long long int e, long long int x,
           long long int y, long long int y1) {
  if (f == 1) return;
  if (b > y || e < x) {
    return;
  }
  if (b >= x && e <= y) {
    if (tree[n] <= y1) {
      query1(n, b, e, y1);
    }
    return;
  }
  long long int mid = (b + e) >> 1, l = n * 2, r = l + 1;
  query(l, b, mid, x, y, y1);
  query(r, mid + 1, e, x, y, y1);
}
long long int aa[500005];
int main() {
  long long int n, i, j, j1, m;
  while (scanf("%lld", &n) == 1) {
    long long int n1 = n;
    map<long long int, long long int> mp;
    for (i = 1; i <= n; i++) {
      scanf("%lld%lld", &d[i], &e[i]);
      mp[d[i]];
      mp[e[i]];
    }
    scanf("%lld", &m);
    for (i = 1; i <= m; i++) {
      scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
      mp[a[i]];
      mp[b[i]];
    }
    long long int cn = 0;
    map<long long int, long long int>::iterator it;
    for (it = mp.begin(); it != mp.end(); it++) {
      it->second = ++cn;
    }
    for (i = 1; i <= n; i++) {
      d[i] = mp[d[i]];
      e[i] = mp[e[i]];
      v[d[i]].push_back(make_pair(e[i], i));
    }
    for (i = 1; i <= cn; i++) {
      sort(v[i].begin(), v[i].end());
      reverse(v[i].begin(), v[i].end());
      if (v[i].size() > 0) {
        long long int x = v[i].size() - 1;
        update(1, 1, cn, i, v[i][x].first);
      } else
        update(1, 1, cn, i, 2000000000000000000);
    }
    for (i = 1; i <= m; i++) {
      long long int x = mp[a[i]];
      long long int y = mp[b[i]];
      long long int z = mp[c[i]];
      adj[y].push_back(make_pair(x, i));
    }
    for (i = 1; i <= cn; i++) {
      if (n == 0) break;
      for (j = 0; j < adj[i].size(); j++) {
        if (n == 0) break;
        long long int x = adj[i][j].first;
        long long int k = adj[i][j].second;
        for (j1 = 1; j1 <= c[k]; j1++) {
          if (n == 0) break;
          f = 0, pos = -1;
          query(1, 1, cn, x, i, i);
          long long int y = pos;
          if (pos == -1) break;
          long long int y1 = v[y].size() - 1;
          long long int ind = v[y][y1].second;
          aa[ind] = k;
          v[y].pop_back();
          n--;
          if (v[y].size() > 0) {
            long long int y1 = v[y].size() - 1;
            update(1, 1, cn, y, v[y][y1].first);
          } else
            update(1, 1, cn, y, 2000000000000000000);
        }
      }
    }
    if (n != 0) {
      printf("NO\n");
      continue;
    }
    printf("YES\n");
    for (i = 1; i <= n1; i++) printf("%lld ", aa[i]);
    printf("\n");
  }
  return 0;
}
