#include <bits/stdc++.h>
using namespace std;
const int maxN = 100 * 1000 + 5;
const int mod = 1000 * 1000 * 1000;
vector<int> v;
int mp(int t) {
  int ps = lower_bound(v.begin(), v.end(), t) - v.begin();
  return ps;
}
vector<pair<int, int> > c[16 * maxN];
pair<pair<int, int>, int> a[maxN];
pair<pair<int, int>, pair<int, int> > b[maxN];
int ans[maxN];
int seg[16 * maxN];
void add(int p, int val, int s, int e, int ind) {
  if (e - s == 1) {
    if (val == 1)
      seg[ind] = s;
    else
      seg[ind] = v.size();
    return;
  }
  int mid = (s + e) >> 1;
  if (p < mid)
    add(p, val, s, mid, 2 * ind);
  else
    add(p, val, mid, e, 2 * ind + 1);
  seg[ind] = min(seg[2 * ind], seg[2 * ind + 1]);
}
int get(int l, int r, int s, int e, int ind) {
  if (l >= e || r <= s) return v.size();
  if (l <= s && e <= r) return seg[ind];
  int mid = (s + e) >> 1;
  int x = get(l, r, s, mid, 2 * ind + 0);
  int y = get(l, r, mid, e, 2 * ind + 1);
  return min(x, y);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i].first.first >> a[i].first.second, v.push_back(a[i].first.first),
        v.push_back(a[i].first.second), a[i].second = i;
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> b[i].first.first >> b[i].first.second >> b[i].second.first;
    b[i].second.second = i + 1;
    v.push_back(b[i].first.second);
    v.push_back(b[i].first.first);
  }
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  fill(seg, seg + 16 * maxN, v.size());
  sort(a, a + n);
  sort(b, b + m);
  int st = 0;
  for (int i = 0; i < n; i++) {
    while (st < m && b[st].first.first <= a[i].first.first) {
      add(mp(b[st].first.second), 1, 0, v.size(), 1);
      c[mp(b[st].first.second)].push_back(
          make_pair(b[st].second.first, b[st].second.second));
      st++;
    }
    int res = get(mp(a[i].first.second), v.size(), 0, v.size(), 1);
    if (res == v.size()) {
      cout << "NO" << endl;
      return 0;
    }
    ans[a[i].second] = c[res].back().second;
    c[res].back().first--;
    if (c[res].back().first == 0) {
      c[res].pop_back();
      if (c[res].size() == 0) add(res, 0, 0, v.size(), 1);
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) cout << ans[i] << ' ';
  cout << endl;
  return 0;
}
