#include <bits/stdc++.h>
using namespace std;
const string problemName = "";
const string inputFile = problemName + ".in";
const string outputFile = problemName + ".out";
const int INF = (1LL << 31) - 1;
const long long int LINF = (1LL << 62) - 1;
const int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
const int MOD = (int)(1e9) + 7;
const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
const int KMAX = 100000 + 5;
const int PMAX = 100000 + 5;
const int LMAX = 100000 + 5;
const int VMAX = 100000 + 5;
struct event {
  int timp, type, ind;
  event() { timp = type = ind = 0; }
  event(int a, int b, int c) {
    timp = a;
    type = b;
    ind = c;
  }
};
struct cmp {
  bool operator()(event A, event B) {
    if (A.timp == B.timp) return A.type < B.type;
    return A.timp < B.timp;
  }
};
int N, M;
int P[NMAX];
int A[NMAX];
int X[NMAX];
int Y[NMAX];
vector<event> E;
set<pair<int, int> > mlc;
int show[NMAX];
int main() {
  int i, x, y, j, a, b, c, ok = 1;
  scanf("%d", &N);
  for (i = 1; i <= N; i++) {
    scanf("%d%d", &x, &P[i]);
    E.push_back(event(x, 1, i));
  }
  scanf("%d", &M);
  for (i = 1; i <= M; i++) {
    scanf("%d%d%d", &X[i], &Y[i], &A[i]);
    E.push_back(event(X[i], 0, i));
    E.push_back(event(Y[i], 2, i));
  }
  sort(E.begin(), E.end(), cmp());
  for (auto e : E) {
    a = e.timp;
    b = e.type;
    c = e.ind;
    if (b == 1) {
      if (!mlc.size()) {
        ok = 0;
        break;
      }
      auto p = mlc.upper_bound(make_pair(P[c], 0));
      if (p == mlc.end()) {
        ok = 0;
        break;
      }
      auto s = *p;
      mlc.erase(p);
      if (P[c] <= Y[s.second]) {
        A[s.second]--;
        show[c] = s.second;
        if (A[s.second]) mlc.insert(s);
      } else {
        ok = 0;
        break;
      }
    } else if (b == 0) {
      mlc.insert(make_pair(Y[c], c));
    } else {
      mlc.erase(make_pair(Y[c], c));
    }
  }
  if (ok) {
    printf("YES\n");
    for (i = 1; i <= N; i++) printf("%d ", show[i]);
  } else
    printf("NO\n");
  return 0;
}
