#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T SQR(T x) {
  return x * x;
}
template <class T>
inline string TOSTR(const T &x) {
  stringstream ss;
  ss << x;
  return ss.str();
}
template <class T>
void UPDATE_MIN(T &x, T y) {
  if (y < x) {
    x = y;
  }
}
template <class T>
void UPDATE_MAX(T &x, T y) {
  if (x < y) {
    x = y;
  }
}
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
long long gcd(long long a, long long b) { return a ? gcd(b % a, a) : b; }
long long powmod(long long a, long long p, long long m) {
  long long r = 1;
  while (p) {
    if (p & 1) r = r * a % m;
    p >>= 1;
    a = a * a % m;
  }
  return r;
}
const int MOD = 1000 * 1000 * 1000 + 7;
const double PI = 3.1415926535897932384626433832795l;
int N, M, t;
struct Obj {
  int no;
  int a;
  int b;
  int k;
  int type;
};
Obj objects_data[100001 * 2];
Obj *objects[100001 * 2];
bool compr1(Obj *a, Obj *b) {
  if (a->a < b->a) return true;
  if (a->a > b->a) return false;
  if (a->type < b->type) return true;
  if (a->type > b->type) return false;
  if (a->b < b->b) return true;
  if (a->b > b->b) return false;
  return false;
}
struct compr2 {
  bool operator()(Obj *a, Obj *b) const {
    if (a->b < b->b) return true;
    if (a->b > b->b) return false;
    return (a->no < b->no);
  }
};
int who[100001];
Obj *to_delete[100001];
int main() {
  cin >> N;
  for (int(i) = 0; (i) < (int)(N); (i)++) {
    int a, b;
    cin >> a >> b;
    objects_data[i] = {i, a, b, 0, 777};
    objects[i] = &objects_data[i];
    Obj &obj = objects_data[i];
  }
  cin >> M;
  for (int(i) = N; (i) < (int)(N + M); (i)++) {
    int c, d, k;
    cin >> c >> d >> k;
    objects_data[i] = {i - N + 1, c, d, k, 333};
    objects[i] = &objects_data[i];
    Obj &obj = objects_data[i];
  }
  sort(objects, objects + N + M, compr1);
  set<Obj *, compr2> singers;
  for (int(ii) = 0; (ii) < (int)(N + M); (ii)++) {
    Obj *objptr = objects[ii];
    Obj &obj = *objptr;
    if (obj.type == 333) {
      singers.insert(objptr);
    } else {
      Obj fake = {0, 0, obj.b, 0, 0};
      int found = 0;
      int delcount = 0;
      for (__typeof(singers.lower_bound(&fake)) iter =
               singers.lower_bound(&fake);
           iter != singers.end(); iter++) {
        Obj &singer = **iter;
        singer.k--;
        if (singer.k <= 0) {
          to_delete[delcount++] = *iter;
        }
        who[obj.no] = singer.no;
        found = 1;
        break;
      }
      for (int(id) = 0; (id) < (int)(delcount); (id)++)
        singers.erase(to_delete[id]);
      if (!found) goto fail;
    }
  }
  cout << "YES\n";
  for (int(i) = 0; (i) < (int)(N); (i)++) {
    cout << who[i] << " ";
  }
  cout << endl;
  return 0;
fail:
  cout << "NO" << endl;
  return 0;
}
