#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const long long LLINF = 9223372036854775807LL;
const int ST = 100010;
const int ST1 = 1000010;
const long long MOD = 1000000007;
long long ABS(long long a) {
  if (a < 0)
    return a * (-1);
  else
    return a;
}
struct ac {
  int a, b, k;
};
vector<ac> act;
vector<pair<pair<int, int>, int> > songs;
set<pair<int, int> > ss;
int ans[ST];
int main() {
  int n;
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    songs.push_back(make_pair(make_pair(a, b), i));
  }
  cin >> n;
  vector<pair<int, int> > pp;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    ac tem = {a, b, c};
    act.push_back(tem);
    pp.push_back(make_pair(a, i));
  }
  sort(songs.begin(), songs.end());
  sort(pp.begin(), pp.end());
  bool can = true;
  int uk = 0;
  for (int i = 0; i < m; i++) {
    int l = songs[i].first.first;
    int r = songs[i].first.second;
    int ind = songs[i].second;
    while (uk < (int)((pp).size()) && pp[uk].first <= l) {
      int v = pp[uk].second;
      ss.insert(make_pair(act[v].b, v));
      uk++;
    }
    set<pair<int, int> >::iterator it;
    it = ss.lower_bound(make_pair(r, 0));
    if (it == ss.end()) {
      can = false;
      break;
    } else {
      int v = it->second;
      act[v].k--;
      ans[ind] = v;
      if (act[v].k == 0) ss.erase(it);
    }
  }
  if (can) {
    cout << "YES" << endl;
    for (int i = 0; i < m; i++) {
      cout << ans[i] + 1 << " ";
    }
  } else {
    cout << "NO";
  }
  return 0;
}
