#include <bits/stdc++.h>
const long long INF = 1LL << 61;
const int inf = 2e9;
const long double PI = acos(-1);
bool debug;
using namespace std;
void solve();
int main() {
  debug = 0;
  cout.precision(30);
  solve();
}
const int N = 2000005;
struct ev {
  int a, b;
  int ind, k;
  ev(int a, int b, int ind, int k = inf) : a(a), b(b), ind(ind), k(k) {}
};
bool operator<(const ev& s, const ev& v) {
  return (s.a < v.a || (s.a == v.a && s.k < v.k) ||
          (s.a == v.a && s.k == v.k && s.ind < v.ind));
}
struct node {
  int b, ind, k;
  node(int b, int ind, int k) : b(b), ind(ind), k(k) {}
};
bool operator<(const node& s, const node& v) {
  return s.b < v.b || (s.b == v.b && s.ind < v.ind) ||
         (s.b == v.b && s.ind == v.ind && s.k < v.k);
}
set<node> q;
vector<ev> all;
int n, m, a, b, k;
int ans[N];
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    all.push_back(ev(a, b, i));
  }
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b >> k;
    all.push_back(ev(a, b, i, k));
  }
  sort(all.begin(), all.end());
  for (int i = 0; i < (int)all.size(); i++) {
    if (all[i].k == inf) {
      auto it = q.lower_bound(node(all[i].b, -1, -1));
      if (it == q.end()) {
        cout << "NO" << endl;
        return;
      }
      ans[all[i].ind] = it->ind;
      if (it->k != 1) q.insert(node(it->b, it->ind, it->k - 1));
      q.erase(it);
    } else
      q.insert(node(all[i].b, all[i].ind, all[i].k));
  }
  cout << "YES" << endl;
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << endl;
}
