#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5, M = 100000 + 5;
int n, m, a[N + M], b[N + M], idx[N + M], k[M + N], ans[N + M];
set<pair<int, int> > ac;
bool cmp(const int &i, const int &j) {
  if (a[i] != a[j]) return a[i] < a[j];
  if (i < n && n <= j) return false;
  if (j < n && n <= i) return true;
  return b[i] < b[j];
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", a + i, b + i);
    idx[i] = i;
  }
  scanf("%d", &m);
  for (int i = n; i < n + m; i++) {
    scanf("%d%d%d", a + i, b + i, k + i);
    idx[i] = i;
  }
  sort(idx, idx + n + m, cmp);
  memset(ans, 0, sizeof ans);
  for (int x, i = 0; i < n + m; i++) {
    if (n <= idx[i]) {
      ac.insert(pair<int, int>(b[idx[i]], idx[i]));
      continue;
    }
    set<pair<int, int> >::iterator ite =
        ac.lower_bound(pair<int, int>(b[idx[i]], -1));
    if (ite == ac.end()) {
      printf("NO\n");
      return 0;
    }
    x = ite->second;
    k[x]--;
    if (!k[x]) ac.erase(pair<int, int>(b[x], x));
    ans[idx[i]] = x;
  }
  printf("YES\n");
  for (int i = 0; i < n; i++) {
    printf("%d ", ans[i] - n + 1);
  }
  return 0;
}
