#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const long long LINF = 2e18;
void inv(bool e);
template <typename T>
T sign(T a);
template <typename T>
void die(T &a);
template <typename T>
void umax(T &a, T b);
template <typename T>
void umin(T &a, T b);
bool brute, alter;
int cnt_tests = 1;
int n, m;
const int N = 1e5 + 5;
struct Part {
  int a, b, id;
  Part() {}
  Part(int x, int y, int i) {
    a = x;
    b = y;
    id = i;
  }
};
struct Actor {
  int c, d, k, id;
  Actor() {}
  Actor(int x, int y, int kk, int i) {
    c = x;
    d = y;
    k = kk;
    id = i;
  }
};
inline bool operator<(Actor a, Actor b) { return a.c < b.c; }
inline bool operator<(Part a, Part b) { return a.b < b.b; }
vector<Part> parts;
vector<Actor> actors;
void inp() {
  cin >> n;
  parts.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> parts[i].a >> parts[i].b;
    parts[i].id = i;
  }
  cin >> m;
  actors.resize(m);
  for (int i = 0; i < m; i++) {
    cin >> actors[i].c >> actors[i].d >> actors[i].k;
    actors[i].id = i;
  }
}
template <typename T>
struct Segment_tree {
  vector<T> data, orig;
  T net;
  T (*f)(T a, T b);
  void build(int l, int r, int v) {
    if (l > r) {
      return;
    }
    if (l == r) {
      data[v] = orig[l];
      return;
    }
    int ls = v + v + 1, rs = v + v + 2, m = (l + r) >> 1;
    build(l, m, ls);
    build(m + 1, r, rs);
    data[v] = (*f)(data[ls], data[rs]);
  }
  T get(int ql, int qr, int l, int r, int v) {
    if (ql > r || qr < l) {
      return net;
    }
    if (ql == l && r == qr) {
      return data[v];
    }
    int ls = v + v + 1, rs = v + v + 2, m = (l + r) >> 1;
    T resL, resR;
    resL = get(ql, min(m, qr), l, m, ls);
    resR = get(max(ql, m + 1), qr, m + 1, r, rs);
    return (*f)(resL, resR);
  }
  T get(int ql, int qr) { return get(ql, qr, 0, ((int)(orig).size()) - 1, 0); }
  void change(int pos, T val, int l, int r, int v) {
    if (pos < l || pos > r) {
      return;
    }
    if (l == r && pos == l) {
      data[v] = orig[l] = val;
      return;
    }
    int ls = v + v + 1, rs = v + v + 2, m = (l + r) >> 1;
    change(pos, val, l, m, ls);
    change(pos, val, m + 1, r, rs);
    data[v] = (*f)(data[ls], data[rs]);
  }
  void change(int pos, T val) {
    change(pos, val, 0, ((int)(orig).size()) - 1, 0);
  }
  void init(vector<T> &prot, T (*ff)(T a, T b), T nt) {
    f = ff;
    net = nt;
    orig = prot;
    data.resize(((int)(orig).size()) * 4 + 1, net);
    build(0, ((int)(orig).size()) - 1, 0);
  }
};
int f[N], cur[N], ans[N];
Actor comp(Actor a, Actor b) {
  if (a.d > b.d) return a;
  return b;
}
void solve() {
  sort((parts).rbegin(), (parts).rend());
  sort((actors).begin(), (actors).end());
  for (int i = 0; i < ((int)(actors).size()); i++) {
    f[actors[i].id] = i;
    cur[actors[i].id] = actors[i].k;
  }
  Segment_tree<Actor> tree;
  tree.init(actors, comp, Actor(-INF, -INF, 0, 0));
  for (auto x : parts) {
    int l = 0, r = ((int)(actors).size()) - 1, m;
    while (r - l > 3) {
      m = (l + r) >> 1;
      if (actors[m].c <= x.a) {
        l = m;
      } else {
        r = m;
      }
    }
    bool ok = false;
    for (int i = r; i >= l; i--) {
      if (actors[i].c <= x.a) {
        int ll = 0, rr = i, mm;
        while (rr - ll > 3) {
          mm = (ll + rr) >> 1;
          if (tree.get(mm, i).d < x.b) {
            rr = mm;
          } else {
            ll = mm;
          }
        }
        bool good = false;
        for (int ii = rr; ii >= ll; ii--) {
          if (tree.get(ii, i).d >= x.b) {
            good = true;
            Actor res = tree.get(ii, i);
            ans[x.id] = res.id + 1;
            cur[res.id]--;
            if (!cur[res.id]) {
              tree.change(f[res.id], Actor(-INF, -INF, 0, 0));
            }
            break;
          }
        }
        if (!good) {
          die("NO");
        }
        ok = true;
        break;
      }
    }
    if (!ok) {
      die("NO");
    }
  }
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    cout << ans[i] << ' ';
  }
}
void stress() {}
void naive() {}
void run();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  if (0) {
    freopen("magic.in", "r", stdin);
    freopen("magic.out", "w", stdout);
  }
  brute = false;
  for (int i = 0; (i < cnt_tests); i++) {
    run();
  }
  cerr << '\n' << "Time: " << clock() / 1000.0 << " ms";
  return 0;
}
void run() {
  if (!brute) {
    inp();
  } else {
    stress();
  }
  solve();
}
template <typename T>
void die(T &a) {
  cout << a;
  exit(0);
}
template <typename T>
T sign(T a) {
  if (a == 0) return 0;
  if (a < 0) return -1;
  return 1;
}
template <typename T>
void umax(T &a, T b) {
  if (b > a) a = b;
}
template <typename T>
void umin(T &a, T b) {
  if (b < a) a = b;
}
void inv(bool e) {
  if (!e) {
    vector<int> a;
    a[-1] += 1;
  }
}
