You are an assistant director in a new musical play. The play consists of n musical parts, each part must be performed by exactly one actor. After the casting the director chose m actors who can take part in the play. Your task is to assign the parts to actors. However, there are several limitations.

First, each actor has a certain voice range and there are some parts that he cannot sing. Formally, there are two integers for each actor, ci and di (ci ≤ di) — the pitch of the lowest and the highest note that the actor can sing. There also are two integers for each part — aj and bj (aj ≤ bj) — the pitch of the lowest and the highest notes that are present in the part. The i-th actor can perform the j-th part if and only if ci ≤ aj ≤ bj ≤ di, i.e. each note of the part is in the actor's voice range.

According to the contract, the i-th actor can perform at most ki parts. Besides, you are allowed not to give any part to some actors (then they take part in crowd scenes).

The rehearsal starts in two hours and you need to do the assignment quickly!

Input

The first line contains a single integer n — the number of parts in the play (1 ≤ n ≤ 105).

Next n lines contain two space-separated integers each, aj and bj — the range of notes for the j-th part (1 ≤ aj ≤ bj ≤ 109).

The next line contains a single integer m — the number of actors (1 ≤ m ≤ 105).

Next m lines contain three space-separated integers each, ci, di and ki — the range of the i-th actor and the number of parts that he can perform (1 ≤ ci ≤ di ≤ 109, 1 ≤ ki ≤ 109).

Output

If there is an assignment that meets all the criteria aboce, print a single word "YES" (without the quotes) in the first line.

In the next line print n space-separated integers. The i-th integer should be the number of the actor who should perform the i-th part. If there are multiple correct assignments, print any of them.

If there is no correct assignment, print a single word "NO" (without the quotes).

Examples

Input

3
1 3
2 4
3 5
2
1 4 2
2 5 1


Output

YES
1 1 2


Input

3
1 3
2 4
3 5
2
1 3 2
2 5 1


Output

NO
#include <bits/stdc++.h>
using namespace std;
template <typename T>
T BigMod(T b, T p, T m) {
  if (p == 0) return 1;
  if (p % 2 == 0) {
    T s = BigMod(b, p / 2, m);
    return ((s % m) * (s % m)) % m;
  }
  return ((b % m) * (BigMod(b, p - 1, m) % m)) % m;
}
template <typename T>
T ModInv(T b, T m) {
  return BigMod(b, m - 2, m);
}
template <typename T>
T in() {
  char ch;
  T n = 0;
  bool ng = false;
  while (1) {
    ch = getchar();
    if (ch == '-') {
      ng = true;
      ch = getchar();
      break;
    }
    if (ch >= '0' && ch <= '9') break;
  }
  while (1) {
    n = n * 10 + (ch - '0');
    ch = getchar();
    if (ch < '0' || ch > '9') break;
  }
  return (ng ? -n : n);
}
template <typename T>
T POW(T B, T printf) {
  if (printf == 0) return 1;
  if (printf & 1)
    return B * POW(B, printf - 1);
  else
    return (POW(B, printf / 2) * POW(B, printf / 2));
}
template <typename T>
T Bigmod(T b, T p, T m) {
  if (p == 0)
    return 1;
  else if (!(p & 1))
    return (Bigmod(b, p / 2, m) * Bigmod(b, p / 2, m)) % m;
  else
    return ((b % m) * Bigmod(b, p - 1, m)) % m;
}
template <typename T>
T Dis(T x1, T y1, T x2, T y2) {
  return sqrt((x1 - x2 * x1 - x2) + (y1 - y2 * y1 - y2));
}
template <typename T>
T Angle(T x1, T y1, T x2, T y2) {
  return atan(double(y1 - y2) / double(x1 - x2));
}
template <typename T>
T DIFF(T a, T b) {
  T d = a - b;
  if (d < 0)
    return -d;
  else
    return d;
}
template <typename T>
T ABS(T a) {
  if (a < 0)
    return -a;
  else
    return a;
}
template <typename T>
T gcd(T a, T b) {
  if (a < 0) return gcd(-a, b);
  if (b < 0) return gcd(a, -b);
  return (b == 0) ? a : gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <typename T>
T euclide(T a, T b, T &x, T &y) {
  if (a < 0) {
    T d = euclide(-a, b, x, y);
    x = -x;
    return d;
  }
  if (b < 0) {
    T d = euclide(a, -b, x, y);
    y = -y;
    return d;
  }
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    T d = euclide(b, a % b, x, y);
    T t = x;
    x = y;
    y = t - (a / b) * y;
    return d;
  }
}
template <typename T>
void ia(T a[], int n) {
  for (int i = 0; i < n; i++) cin >> a[i];
}
template <typename T>
void pa(T a[], int n) {
  for (int i = 0; i < n - 1; i++) cout << a[i] << " ";
  cout << a[n - 1] << endl;
}
template <typename T>
long long int isLeft(T a, T b, T c) {
  return (a.x - b.x) * (b.y - c.y) - (b.x - c.x) * (a.y - b.y);
}
int Set(int N, int pos) { return N = N | (1 << pos); }
int Reset(int N, int pos) { return N = N & ~(1 << pos); }
bool Check(int N, int pos) { return (bool)(N & (1 << pos)); }
template <class T, class first>
inline T togglebit(T a, first i) {
  T t = 1;
  return (a ^ (t << i));
}
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int toLlint(string s) {
  long long int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int cdigittoint(char ch) { return ch - '0'; }
bool isVowel(char ch) {
  ch = toupper(ch);
  if (ch == 'A' || ch == 'U' || ch == 'I' || ch == 'O' || ch == 'E')
    return true;
  return false;
}
bool isConst(char ch) {
  if (isalpha(ch) && !isVowel(ch)) return true;
  return false;
}
double DEG(double x) { return (180.0 * x) / (2.0 * acos(0.0)); }
double RAD(double x) { return (x * (double)2.0 * acos(0.0)) / (180.0); }
struct Pair {
  int x, y, id;
  Pair() {}
  Pair(int _, int __, int ___) {
    x = _;
    y = __;
    id = ___;
  }
  bool operator<(const Pair &p) const {
    if (y < p.y) return true;
    if (y == p.y) {
      if (x > p.x) return true;
    }
    return false;
  }
};
Pair Note[100007], Singer[100007];
int a[100007 << 2];
int K[100007];
vector<int> ids[100007 << 2];
int BIT[100007 << 2];
int mxVal;
int ans[100007];
void Update(int idx, int val) {
  while (idx < mxVal) BIT[idx] += val, idx += idx & -idx;
}
int Query(int idx) {
  int ans = 0;
  while (idx) ans += BIT[idx], idx -= idx & -idx;
  return ans;
}
int LowerBound(Pair b[], int n, int x) {
  int l = 1, h = n;
  while (l <= h) {
    int mid = (l + h) >> 1;
    if (b[mid].y < x)
      l = mid + 1;
    else
      h = mid - 1;
  }
  return l;
}
int UpperBound(Pair b[], int n, int x) {
  int l = 1, h = n;
  while (l <= h) {
    int mid = (l + h) >> 1;
    if (b[mid].y > x)
      h = mid - 1;
    else
      l = mid + 1;
  }
  return l;
}
int FindNext(int l, int h) {
  int y = l;
  while (l <= h) {
    int mid = (l + h) >> 1;
    if (Query(mid) - Query(y - 1) < 1)
      l = mid + 1;
    else
      h = mid - 1;
  }
  return l;
}
int main() {
  int(n);
  scanf("%d", &n);
  int l = 0;
  mxVal = 100007 << 2;
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    Note[i] = Pair(x, y, i);
    a[++l] = x;
    a[++l] = y;
  }
  int(m);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    scanf("%d", &K[i]);
    Singer[i] = Pair(x, y, i);
    a[++l] = x;
    a[++l] = y;
  }
  sort(a + 1, a + 1 + l);
  for (int i = 1; i <= n; i++)
    Note[i].x = lower_bound(a + 1, a + 1 + l, Note[i].x) - a,
    Note[i].y = lower_bound(a + 1, a + 1 + l, Note[i].y) - a;
  for (int i = 1; i <= m; i++)
    Singer[i].x = lower_bound(a + 1, a + 1 + l, Singer[i].x) - a,
    Singer[i].y = lower_bound(a + 1, a + 1 + l, Singer[i].y) - a;
  sort(Note + 1, Note + 1 + n);
  sort(Singer + 1, Singer + 1 + m);
  int tot = 0;
  for (int i = 1; i <= l; i++) {
    if (a[i] != a[i - 1]) {
      int st = LowerBound(Note, n, i);
      int ed = UpperBound(Note, n, i);
      for (int j = st; j < ed; j++) {
        Update(Note[j].x, 1);
        ids[Note[j].x].push_back(Note[j].id);
      }
      st = LowerBound(Singer, m, i);
      ed = UpperBound(Singer, m, i);
      for (int j = st; j < ed; j++) {
        int x = Singer[j].x;
        while (K[Singer[j].id]) {
          x = FindNext(x, i);
          if (x > i) break;
          Update(x, -1);
          int y = ids[x].back();
          ids[x].pop_back();
          ans[y] = Singer[j].id;
          K[Singer[j].id]--;
          tot++;
        }
      }
    }
  }
  if (tot != n)
    cout << "NO\n";
  else {
    puts("YES");
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    printf("\n");
    ;
  }
  return 0;
}
