#include <bits/stdc++.h>
using namespace std;
template <typename T>
T gcd(T a, T b) {
  while (b > 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}
template <class _T>
inline _T sqr(const _T& first) {
  return first * first;
}
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
const long double PI = 3.1415926535897932384626433832795L;
const double EPS = 1e-9;
char TEMPORARY_CHAR;
const int INF = 1e9;
inline void input(int& a) {
  a = 0;
  while (((TEMPORARY_CHAR = getchar()) > '9' || TEMPORARY_CHAR < '0') &&
         (TEMPORARY_CHAR != '-')) {
  }
  char neg = 0;
  if (TEMPORARY_CHAR == '-') {
    neg = 1;
    TEMPORARY_CHAR = getchar();
  }
  while (TEMPORARY_CHAR <= '9' && TEMPORARY_CHAR >= '0') {
    a = 10 * a + TEMPORARY_CHAR - '0';
    TEMPORARY_CHAR = getchar();
  }
  if (neg) a = -a;
}
inline void out(long long a) {
  if (!a) putchar('0');
  if (a < 0) {
    putchar('-');
    a = -a;
  }
  char s[20];
  int i;
  for (i = 0; a; ++i) {
    s[i] = '0' + a % 10;
    a /= 10;
  }
  for (int j = (i)-1; j >= 0; j--) putchar(s[j]);
}
inline int nxt() {
  int(ret);
  input((ret));
  ;
  return ret;
}
struct Event {
  int type;
  int l, r;
  int k;
  int id;
  bool operator<(const Event& V) const {
    if (l != V.l) {
      return l < V.l;
    }
    if (type != V.type) {
      return type < V.type;
    }
    if (r != V.r) {
      return r < V.r;
    }
    return id < V.id;
  }
};
int main() {
  int(n);
  input((n));
  ;
  pair<int, int> a[n];
  vector<Event> q;
  for (int i = 0; i < n; ++i) {
    a[i].first = nxt();
    a[i].second = nxt();
    q.push_back(Event{1, a[i].first, a[i].second, 0, i});
  }
  int(m);
  input((m));
  ;
  int R[m + 1];
  int K[m + 1];
  for (int i = 0; i < m; ++i) {
    int(l);
    input((l));
    ;
    int(r);
    input((r));
    ;
    int(k);
    input((k));
    ;
    q.push_back(Event{0, l, r, k, i});
    q.push_back(Event{2, r, -1, k, i});
    R[i] = r;
    K[i] = k;
  }
  sort((q).begin(), (q).end());
  auto cmp = [&](int a, int b) {
    return R[a] < R[b] || (R[a] == R[b] && K[a] > K[b]) ||
           (R[a] == R[b] && K[a] == K[b] && a < b);
  };
  int ans[n];
  set<int, decltype(cmp)> ex(cmp);
  for (int i = 0; i < (int)q.size(); ++i) {
    if (q[i].type == 0) {
      ex.insert(q[i].id);
      continue;
    }
    if (q[i].type == 1) {
      R[m] = q[i].r;
      K[m] = 2e9;
      auto it = ex.lower_bound(m);
      if (it == ex.end()) {
        puts("NO");
        return 0;
      }
      int pos = *it;
      ex.erase(pos);
      K[pos]--;
      ans[q[i].id] = pos;
      if (K[pos] > 0) {
        ex.insert(pos);
      }
      continue;
    }
    ex.erase(q[i].id);
  }
  puts("YES");
  for (int i = 0; i < n; ++i) {
    cout << ans[i] + 1 << " ";
  }
  return 0;
}
