#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
int main() {
  std::ios_base::sync_with_stdio(0);
  int n, m, a, b, c, d, k, type, indx;
  cin >> n;
  vector<pair<int, pair<int, pair<int, pair<int, int> > > > > tot;
  for (int i = 0; i < n; ++i) {
    cin >> a >> b;
    tot.push_back(make_pair(a, make_pair(1, make_pair(b, make_pair(0, i)))));
  }
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> c >> d >> k;
    tot.push_back(make_pair(c, make_pair(0, make_pair(d, make_pair(k, i)))));
  }
  sort((tot).begin(), (tot).end());
  set<pair<int, pair<int, int> > > actors;
  vector<pair<int, int> > res;
  for (int i = 0; i < int((tot).size()); ++i) {
    type = tot[i].second.first;
    d = tot[i].second.second.first;
    k = tot[i].second.second.second.first;
    indx = tot[i].second.second.second.second;
    if (type == 0) {
      actors.insert(make_pair(d, make_pair(k, indx)));
    } else {
      if (actors.lower_bound(make_pair(d, make_pair(0, 0))) == actors.end()) {
        cout << "NO" << endl;
        return 0;
      }
      pair<int, pair<int, int> > exist =
          *actors.lower_bound(make_pair(d, make_pair(0, 0)));
      res.push_back(make_pair(indx, exist.second.second));
      actors.erase(make_pair(
          exist.first, make_pair(exist.second.first, exist.second.second)));
      exist.second.first--;
      if (exist.second.first > 0) {
        actors.insert(make_pair(
            exist.first, make_pair(exist.second.first, exist.second.second)));
      }
    }
  }
  sort((res).begin(), (res).end());
  cout << "YES" << endl;
  for (int i = 0; i < int((res).size()); ++i) {
    cout << res[i].second + 1 << " ";
  }
  cout << endl;
  return 0;
}
