#include <bits/stdc++.h>
using namespace std;
bool __hack = std::ios::sync_with_stdio(false);
auto __hack1 = cin.tie(nullptr);
namespace template_util {
constexpr int bytecount(uint64_t x) { return x ? 1 + bytecount(x >> 8) : 0; }
template <int N>
struct bytetype {};
template <uint64_t N>
struct minimal_uint : bytetype<bytecount(N)> {};
}  // namespace template_util
template <class T>
T next(istream& in) {
  T ret;
  in >> ret;
  return ret;
}
struct Event {
  int x;
  int type;
  int y;
  Event(int x, int type, int y) : x(x), type(type), y(y) {}
  bool operator<(const Event& e) const {
    if (x != e.x) {
      return x < e.x;
    }
    if (type != e.type) {
      return type < e.type;
    }
    return y < e.y;
  }
};
struct Singer {
  int x;
  int id;
  int leftSongs;
  Singer(int x, int id, int leftSongs) : x(x), id(id), leftSongs(leftSongs) {}
};
void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  multiset<pair<int, int>> Q;
  vector<Event> events;
  vector<pair<int, int>> songs;
  for (int i = 0; i < (n); ++i) {
    auto st = next<int>(in);
    auto en = next<int>(in);
    songs.push_back({st, en});
    events.push_back({st, 1, i});
  }
  auto m = next<int>(in);
  vector<Singer> singers;
  for (int i = 0; i < (m); ++i) {
    auto st = next<int>(in);
    auto en = next<int>(in);
    auto ki = next<int>(in);
    singers.push_back({en, i, ki});
    events.push_back({st, 0, i});
    events.push_back({en, 2, i});
  }
  sort(events.begin(), events.end());
  vector<int> res(n);
  for (auto& ev : events) {
    if (ev.type == 0) {
      Q.insert({singers[ev.y].x, ev.y});
    } else if (ev.type == 2) {
      Q.erase({singers[ev.y].x, ev.y});
    } else {
      auto it = Q.lower_bound({songs[ev.y].second, -1});
      if (it == Q.end()) {
        out << "NO\n";
        return;
      }
      int idx = it->second;
      singers[idx].leftSongs--;
      res[ev.y] = idx;
      if (singers[idx].leftSongs == 0) {
        Q.erase({singers[idx].x, idx});
      }
    }
  }
  out << "YES\n";
  for (int i = 0; i < (n); ++i) {
    out << res[i] + 1 << ' ';
  }
  out << "\n";
}
int main() {
  solve(cin, cout);
  return 0;
}
