#ifndef ONLINE_JUDGE
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#else
#include <bits/stdc++.h>
#endif
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define FORd(i, a, b) for(int i = a - 1; i >= b; i--)
#define sz(a) int((a).size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pi> vii;
typedef vector<pl> vll;
ll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}

const int maxn = 10010;
int n, m;
int a[maxn];
int b[maxn];
int c[maxn];
int d[maxn];
int k[maxn];
vii V1;
vector<pair<pair<int, int>, int> > V2;
set<pl> st;
map<pl, ll> mp;
int ans[maxn];

void solve() {
	scanf("%d", &n);
	FOR(i, 0, n) {scanf("%d%d", a + i, b + i); V1.push_back(make_pair(a[i], b[i]));}
	scanf("%d", &m);
	FOR(i, 0, m) {scanf("%d%d%d", c + i, d + i, k + i); V2.push_back(make_pair(make_pair(c[i], d[i]), k[i]));}
	sort(V1.begin(), V1.end());
	sort(V2.begin(), V2.end());
	int d = 0;
	FOR(i, 0, sz(V1)) {
		while (d < sz(V2) && V2[d].first.first <= V1[i].first) {st.insert(make_pair(V2[d].first.second, d)); mp[make_pair(V2[d].first.second, d)] += 1LL * V2[d].second; d++;}
		set<pl>::iterator it = st.lower_bound(make_pair(V1[i].second, _I64_MIN));
		if (it == st.end()) {printf("NO"); return;}
		ans[i] = it->second + 1;
		mp[*it]--;
		if (!mp[*it]) st.erase(*it);
	}
	printf("YES\n");
	FOR(i, 0, n) printf("%d ", ans[i]);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
	solve();
#ifndef ONLINE_JUDGE
	printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#ifndef ONLINE_JUDGE
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#else
#include <bits/stdc++.h>
#endif
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define FORd(i, a, b) for(int i = a - 1; i >= b; i--)
#define sz(a) int((a).size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pi> vii;
typedef vector<pl> vll;
ll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}

const int maxn = 100010;
int n, m;
vector<pair<pair<int, int>, int> > V1;
vector<pair<pair<int, int>, pair<int, int> > > V2;
set<pi> st;
map<pi, int> mp;
int ans[maxn];

void solve() {
	scanf("%d", &n);
	FOR(i, 0, n) {int a, b; scanf("%d%d", &a, &b); V1.push_back(make_pair(make_pair(a, b), i));}
	scanf("%d", &m);
	FOR(i, 0, m) {int a, b, c; scanf("%d%d%d", &a, &b, &c); V2.push_back(make_pair(make_pair(c, d), make_pair(k, i + 1)));}
	sort(V1.begin(), V1.end());
	sort(V2.begin(), V2.end());
	int d = 0;
	FOR(i, 0, sz(V1)) {
		while (d < sz(V2) && V2[d].first.first <= V1[i].first.first) {st.insert(make_pair(V2[d].first.second, V2[d].second.second)); mp[make_pair(V2[d].first.second, V2[d].second.second)] = V2[d].second.first; d++;}
		set<pi>::iterator it = st.lower_bound(make_pair(V1[i].first.second, INT_MIN));
		if (it == st.end()) {printf("NO"); return;}
		ans[V1[i].second] = it->second;
		mp[*it]--;
		if (!mp[*it]) st.erase(*it);
	}
	printf("YES\n");
	FOR(i, 0, n) printf("%d ", ans[i]);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
	solve();
#ifndef ONLINE_JUDGE
	printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#ifndef ONLINE_JUDGE
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#else
#include <bits/stdc++.h>
#endif
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define FORd(i, a, b) for(int i = a - 1; i >= b; i--)
#define sz(a) int((a).size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pi> vii;
typedef vector<pl> vll;
ll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}

const int maxn = 10010;
int n, m;
int a[maxn];
int b[maxn];
int c[maxn];
int d[maxn];
int k[maxn];
vii V1;
vector<pair<pair<int, int>, int> > V2;
set<pl> st;
map<pl, pl> mp;
int ans[maxn];

void solve() {
	scanf("%d", &n);
	FOR(i, 0, n) {scanf("%d%d", a + i, b + i); V1.push_back(make_pair(a[i], b[i]));}
	scanf("%d", &m);
	FOR(i, 0, m) {scanf("%d%d%d", c + i, d + i, k + i); V2.push_back(make_pair(make_pair(c[i], d[i]), k[i]));}
	sort(V1.begin(), V1.end());
	sort(V2.begin(), V2.end());
	int d = 0;
	FOR(i, 0, sz(V1)) {
		while (d < sz(V2) && V2[d].first.first <= V1[i].first) {st.insert(make_pair(V2[d].first.second, d)); mp[make_pair(V2[d].first.second, d)] += 1LL * V2[d].second; d++;}
		set<pl>::iterator it = st.lower_bound(make_pair(V1[i].second, _I64_MIN));
		if (it == st.end()) {printf("NO"); return;}
		ans[i] = it->second + 1;
		mp[*it]--;
		if (!mp[*it]) st.erase(*it);
	}
	printf("YES\n");
	FOR(i, 0, n) printf("%d ", ans[i]);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
	solve();
#ifndef ONLINE_JUDGE
	printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#ifndef ONLINE_JUDGE
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#else
#include <bits/stdc++.h>
#endif
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define FORd(i, a, b) for(int i = a - 1; i >= b; i--)
#define sz(a) int((a).size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pi> vii;
typedef vector<pl> vll;
ll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}

const int maxn = 100010;
int n, m;
int a[maxn];
int b[maxn];
int c[maxn];
int d[maxn];
int k[maxn];
vector<pair<pair<int, int>, int> > V1;
vector<pair<pair<int, int>, pair<int, int> > > V2;
set<pi> st;
map<pi, int> mp;
int ans[maxn];

void solve() {
	scanf("%d", &n);
	FOR(i, 0, n) {scanf("%d%d", a + i, b + i); V1.push_back(make_pair(make_pair(a[i], b[i]), i));}
	scanf("%d", &m);
	FOR(i, 0, m) {scanf("%d%d%d", c + i, d + i, k + i); V2.push_back(make_pair(make_pair(c[i], d[i]), make_pair(k[i], i + 1)));}
	sort(V1.begin(), V1.end());
	sort(V2.begin(), V2.end());
	int d = 0;
	FOR(i, 0, sz(V1)) {
		while (d < sz(V2) && V2[d].first.first <= V1[i].first.first) {st.insert(make_pair(V2[d].first.second, V2[d].second.second)); mp[make_pair(V2[d].first.second, V2[d].second.second)] = V2[d].second.first; d++;}
		set<pi>::iterator it = st.lower_bound(make_pair(V1[i].first.second, INT_MIN));
		if (it == st.end()) {printf("NO"); return;}
		ans[V1[i].second] = it->second;
		mp[*it]--;
		if (!mp[*it]) st.erase(*it);
	}
	printf("YES\n");
	FOR(i, 0, n) printf("%d ", ans[i]);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
	solve();
#ifndef ONLINE_JUDGE
	printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#ifndef ONLINE_JUDGE
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#else
#include <bits/stdc++.h>
#endif
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define FORd(i, a, b) for(int i = a - 1; i >= b; i--)
#define sz(a) int((a).size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pi> vii;
typedef vector<pl> vll;
ll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}

const int maxn = 100010;
int n, m;
int a[maxn];
int b[maxn];
int c[maxn];
int d[maxn];
int k[maxn];
vii V1;
vector<pair<pair<int, int>, pair<int, int> > > V2;
set<pi> st;
map<pi, int> mp;
int ans[maxn];

void solve() {
	scanf("%d", &n);
	FOR(i, 0, n) {scanf("%d%d", a + i, b + i); V1.push_back(make_pair(a[i], b[i]));}
	scanf("%d", &m);
	FOR(i, 0, m) {scanf("%d%d%d", c + i, d + i, k + i); V2.push_back(make_pair(make_pair(c[i], d[i]), make_pair(k[i], i + 1)));}
	sort(V1.begin(), V1.end());
	sort(V2.begin(), V2.end());
	int d = 0;
	FOR(i, 0, sz(V1)) {
		while (d < sz(V2) && V2[d].first.first <= V1[i].first) {st.insert(make_pair(V2[d].first.second, V2[d].second.second)); mp[make_pair(V2[d].first.second, V2[d].second.second)] = V2[d].second.first; d++;}
		set<pi>::iterator it = st.lower_bound(make_pair(V1[i].second, INT_MIN));
		if (it == st.end()) {printf("NO"); return;}
		ans[i] = it->second;
		mp[*it]--;
		if (!mp[*it]) st.erase(*it);
	}
	printf("YES\n");
	FOR(i, 0, n) printf("%d ", ans[i]);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
	solve();
#ifndef ONLINE_JUDGE
	printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#ifndef ONLINE_JUDGE
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#else
#include <bits/stdc++.h>
#endif
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define FORd(i, a, b) for(int i = a - 1; i >= b; i--)
#define sz(a) int((a).size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pi> vii;
typedef vector<pl> vll;
ll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}

const int maxn = 10010;
int n, m;
int a[maxn];
int b[maxn];
int c[maxn];
int d[maxn];
int k[maxn];
vii V1;
vector<pair<pair<int, int>, int> > V2;
set<pl> st;
map<pl, int> mp;
int ans[maxn];

void solve() {
	scanf("%d", &n);
	FOR(i, 0, n) {scanf("%d%d", a + i, b + i); V1.push_back(make_pair(a[i], b[i]));}
	scanf("%d", &m);
	FOR(i, 0, m) {scanf("%d%d%d", c + i, d + i, k + i); V2.push_back(make_pair(make_pair(c[i], d[i]), k[i]));}
	sort(V1.begin(), V1.end());
	sort(V2.begin(), V2.end());
	int d = 0;
	FOR(i, 0, sz(V1)) {
		while (d < sz(V2) && V2[d].first.first <= V1[i].first) {st.insert(make_pair(V2[d].first.second, d)); mp[make_pair(V2[d].first.second, d)] += 1LL * V2[d].second; d++;}
		set<pl>::iterator it = st.lower_bound(make_pair(V1[i].second, _I64_MIN));
		if (it == st.end()) {printf("NO"); return;}
		ans[i] = it->second + 1;
		mp[*it]--;
		if (!mp[*it]) st.erase(*it);
	}
	printf("YES\n");
	FOR(i, 0, n) printf("%d ", ans[i]);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
	solve();
#ifndef ONLINE_JUDGE
	printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#ifndef ONLINE_JUDGE
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#else
#include <bits/stdc++.h>
#endif
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define FORd(i, a, b) for(int i = a - 1; i >= b; i--)
#define sz(a) int((a).size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pi> vii;
typedef vector<pl> vll;
ll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}

const int maxn = 100010;
int n, m;
vector<pair<pair<int, int>, int> > V1;
vector<pair<pair<int, int>, pair<int, int> > > V2;
set<pi> st;
map<pi, int> mp;
int ans[maxn];

void solve() {
	scanf("%d", &n);
	FOR(i, 0, n) {int a, b; scanf("%d%d", &a, &b); V1.push_back(make_pair(make_pair(a, b), i));}
	scanf("%d", &m);
	FOR(i, 0, m) {int c, d, k; scanf("%d%d%d", &c, &d, &k); V2.push_back(make_pair(make_pair(c, d), make_pair(k, i + 1)));}
	sort(V1.begin(), V1.end());
	sort(V2.begin(), V2.end());
	int d = 0;
	FOR(i, 0, sz(V1)) {
		while (d < sz(V2) && V2[d].first.first <= V1[i].first.first) {st.insert(make_pair(V2[d].first.second, V2[d].second.second)); mp[make_pair(V2[d].first.second, V2[d].second.second)] = V2[d].second.first; d++;}
		set<pi>::iterator it = st.lower_bound(make_pair(V1[i].first.second, INT_MIN));
		if (it == st.end()) {printf("NO"); return;}
		ans[V1[i].second] = it->second;
		mp[*it]--;
		if (!mp[*it]) st.erase(*it);
	}
	printf("YES\n");
	FOR(i, 0, n) printf("%d ", ans[i]);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
	solve();
#ifndef ONLINE_JUDGE
	printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


#ifndef ONLINE_JUDGE
#include <iostream>
#include <iomanip>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#else
#include <bits/stdc++.h>
#endif
using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define FORd(i, a, b) for(int i = a - 1; i >= b; i--)
#define sz(a) int((a).size())
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pi> vii;
typedef vector<pl> vll;
ll gcd(ll a, ll b) {ll r; while (b != 0) {r = a % b; a = b; b = r;} return a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}

const int maxn = 10010;
int n, m;
int a[maxn];
int b[maxn];
int c[maxn];
int d[maxn];
int k[maxn];
vii V1;
vector<pair<pair<int, int>, int> > V2;
set<pi> st;
map<pi, int> mp;
int ans[maxn];

void solve() {
	scanf("%d", &n);
	FOR(i, 0, n) {scanf("%d%d", a + i, b + i); V1.push_back(make_pair(a[i], b[i]));}
	scanf("%d", &m);
	FOR(i, 0, m) {scanf("%d%d%d", c + i, d + i, k + i); V2.push_back(make_pair(make_pair(c[i], d[i]), k[i]));}
	sort(V1.begin(), V1.end());
	sort(V2.begin(), V2.end());
	int k = 0;
	FOR(i, 0, sz(V1)) {
		while (k < sz(V2) && V2[k].first.first <= V1[i].first) {st.insert(make_pair(V2[k].first.second, k)); mp[make_pair(V2[k].first.second, k)] += V2[k].second; k++;}
		set<pi>::iterator it = st.lower_bound(make_pair(V1[i].second, INT_MIN));
		if (it == st.end()) {printf("NO"); return;}
		ans[i] = it->second + 1;
		mp[*it]--;
		if (!mp[*it]) st.erase(*it);
	}
	printf("YES\n");
	FOR(i, 0, n) printf("%d ", ans[i]);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout);
#endif
	solve();
#ifndef ONLINE_JUDGE
	printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}


/*

    Author of solution {

           gskhirtladze;

    }

*/

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <string>

#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define Pii pair < int , int >
#define tree int t,int l,int r
#define left 2*t,l,(l+r)/2
#define right 2*t+1,(l+r)/2+1,r
#define f_sum(i,r) for (int i=r;i>=0;i=(i&(i+1))-1)
#define f_upd(i,r) for (;i<=r;i=(i|(i+1)))
#define ged(x) scanf("%I64d",&x)
#define getcx getchar
#define my int
#define put(x) cout<<x<<endl;
#define pud(x) printf("%.12f\n",x);
#define LL long long
#define INF 1000000000
#define eps 0.00000001
#define P7 1000000007
#define P9 1000000009
#define N3 2555
#define N5 262145
#define N6 1048577
#define SS system("pause")

using namespace std;

inline void inp(int &n )
 {n=0; int ch=getcx();int sign=1;
  while(ch<'0'||ch>'9'){if(ch=='-')sign=-1; ch=getcx();}
  while(  ch >= '0' && ch <= '9' ) n=(n<<3)+(n<<1)+ch-'0',ch=getcx();
  n=n*sign;}

LL gcd(LL A,LL B) {
    return A>B?gcd(B,A):A?gcd(B%A,A):B; }

LL lcm(LL A,LL B) {
    return A/gcd(A,B)*B; }

LL pow(LL A,LL B,LL P) {
   if (!B) return 1%P;
   LL h=pow(A,B/2,P); h*=h;
   h%=P; if (B%2) h*=A; return h%P; }

pair < Pii , int > P1[N5/5],P2[N5/5];
int n,m;

vector <int> z_function (string s) {
  int n = (int) s.length(); vector<int> z (n);
  for (int i=1, l=0, r=0; i<n; ++i) {
    if (i <= r) z[i] = min (r-i+1, z[i-l]);
    while (i+z[i] < n && s[z[i]] == s[i+z[i]]) ++z[i];
    if (i+z[i]-1 > r) l = i,  r = i+z[i]-1; } return z; }

/* // DSU
int PR[N5],SZ[N5];

int parent(int u) {
  if (PR[u] == u) return u;
  PR[u]=parent(PR[u]);return PR[u];}

void uni(int u,int v){
 u=parent(u); v=parent(v);
 SZ[u]+=SZ[v]; SZ[v]=0; PR[v]=u;}
*/

void red()
 {  sort(P1+1,P1+n+1);
    sort(P2+1,P2+m+1); }
/* // Primes
int lp[N6+2];
vector < int > pr;

void get_pr(int N) {
 for (int i=2;i<=N;i++)
  {if (lp[i] == 0){ pr.pb(i); lp[i]=i; }
   for (int j=0;j<pr.size()&& pr[j]<=lp[i] && pr[j]*i<=N;j++) lp[pr[j]*i]=pr[j]; } }
*/
set < Pii > myset;
Pii D[N5/5];
int tst,l;
set < Pii > :: iterator IT;
void get_ready() {
     //freopen(".in","r",stdin);
     //freopen(".out","w",stdout);
     tst=1; }
void ins(int i)
 { while (l <= m && P1[i].fi.fi >= P2[l].fi.fi)
     { myset.insert(mk(P2[l].fi.se,P2[l].se)); l++; } }
void er(Pii nxt) { myset.erase(nxt); }

int a,b,c,i;
int MAA[N5/2];

int nxt;

Pii fin(Pii A)
 {
  IT=myset.lower_bound(A);
  if (IT == myset.end()) return mk(-1,-1);
  Pii res=*IT;
  return res;
 }

bool READ() {

 cin>>n; l=1;
 for (i=1;i<=n;i++)
 {
  scanf("%d%d",&a,&b);
  P1[i]=mk(mk(a,b),i);
 }
 cin>>m;
 for (i=1;i<=m;i++)
 {
  scanf("%d%d%d",&a,&b,&c);
  D[i]=mk(a,b);
  P2[i]=mk(mk(a,b),i);
  MAA[i]=c;
 } red();

return 1;}

vector < int > ress;

bool SOLVE() {

 int lt=0;
  for (i=1;i<=n;i++)
  {
   ins(i);
   Pii nxt=fin(mk(P1[i].fi.se,0));
   if (nxt == mk(-1,-1)) return 0;
   MAA[nxt.se]--;
   ress.pb(nxt.se);
   if (!MAA[nxt.se]) myset.erase(IT);
  }
  cout<<"YES"<<endl;
  for (i=0;i<ress.size();i++)
     cout<<ress[i]<<" ";
  cout<<endl;

return 1;}

bool PRINT() {
return 1;}

bool CLEAR() {
return 1;}

my main() {get_ready();
while (tst--){

 if (!READ()) { return 0; }
 if (!SOLVE()) { cout<<"NO"<<endl; return 0; }
 if (!PRINT()) { return 0; }
 if (!CLEAR()) { return 0; }

}}


/*

    Author of solution {

           gskhirtladze;

    }

*/

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <string>

#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define Pii pair < int , int >
#define tree int t,int l,int r
#define left 2*t,l,(l+r)/2
#define right 2*t+1,(l+r)/2+1,r
#define f_sum(i,r) for (int i=r;i>=0;i=(i&(i+1))-1)
#define f_upd(i,r) for (;i<=r;i=(i|(i+1)))
#define ged(x) scanf("%I64d",&x)
#define getcx getchar
#define my int
#define put(x) cout<<x<<endl;
#define pud(x) printf("%.12f\n",x);
#define LL long long
#define INF 1000000000
#define eps 0.00000001
#define P7 1000000007
#define P9 1000000009
#define N3 2555
#define N5 262145
#define N6 1048577
#define SS system("pause")

using namespace std;

inline void inp(int &n )
 {n=0; int ch=getcx();int sign=1;
  while(ch<'0'||ch>'9'){if(ch=='-')sign=-1; ch=getcx();}
  while(  ch >= '0' && ch <= '9' ) n=(n<<3)+(n<<1)+ch-'0',ch=getcx();
  n=n*sign;}

LL gcd(LL A,LL B) {
    return A>B?gcd(B,A):A?gcd(B%A,A):B; }

LL lcm(LL A,LL B) {
    return A/gcd(A,B)*B; }

LL pow(LL A,LL B,LL P) {
   if (!B) return 1%P;
   LL h=pow(A,B/2,P); h*=h;
   h%=P; if (B%2) h*=A; return h%P; }

pair < Pii , int > P1[N5/5],P2[N5/5];
int n,m;

vector <int> z_function (string s) {
  int n = (int) s.length(); vector<int> z (n);
  for (int i=1, l=0, r=0; i<n; ++i) {
    if (i <= r) z[i] = min (r-i+1, z[i-l]);
    while (i+z[i] < n && s[z[i]] == s[i+z[i]]) ++z[i];
    if (i+z[i]-1 > r) l = i,  r = i+z[i]-1; } return z; }

/* // DSU
int PR[N5],SZ[N5];

int parent(int u) {
  if (PR[u] == u) return u;
  PR[u]=parent(PR[u]);return PR[u];}

void uni(int u,int v){
 u=parent(u); v=parent(v);
 SZ[u]+=SZ[v]; SZ[v]=0; PR[v]=u;}
*/

void red()
 {  sort(P1+1,P1+n+1);
    sort(P2+1,P2+m+1); }
/* // Primes
int lp[N6+2];
vector < int > pr;

void get_pr(int N) {
 for (int i=2;i<=N;i++)
  {if (lp[i] == 0){ pr.pb(i); lp[i]=i; }
   for (int j=0;j<pr.size()&& pr[j]<=lp[i] && pr[j]*i<=N;j++) lp[pr[j]*i]=pr[j]; } }
*/
set < Pii > myset;
Pii D[N5/5];
int tst,l;
void get_ready() {
     //freopen(".in","r",stdin);
     //freopen(".out","w",stdout);
     tst=1; }
void ins(int i)
 { while (l <= m && P1[i].fi.fi >= P2[l].fi.fi)
     { myset.insert(mk(P2[l].fi.se,P2[l].se)); l++; } }
void er(int nxt) { myset.erase(mk(D[nxt].se,nxt)); }

int a,b,c,i;
int MAA[N5/2];

int nxt;

int fin(Pii A)
 {
  if (myset.lower_bound(A) == myset.end()) return -1;
  Pii res=*myset.lower_bound(A);
  return res.se;
 }

int ress[N5/2];
bool READ() {

 cin>>n; l=1;
 for (i=1;i<=n;i++)
 {
  scanf("%d%d",&a,&b);
  P1[i]=mk(mk(a,b),i);
 }
 cin>>m;
 for (i=1;i<=m;i++)
 {
  scanf("%d%d%d",&a,&b,&c);
  D[i]=mk(a,b);
  P2[i]=mk(mk(a,b),i);
  MAA[i]=c;
 } red();

return 1;}

bool SOLVE() {

 int lt=0;
  for (i=1;i<=n;i++)
  {
   ins(i);
   int nxt=fin(mk(P1[i].fi.se,0));
   if (nxt == -1) return 0;
   MAA[nxt]--;
   ress[P1[i].se]=nxt;
   if (!MAA[nxt]) er(nxt);
  }
  cout<<"YES"<<endl;
  for (i=0;i<n;i++)
     cout<<ress[i+1]<<" ";
  cout<<endl;

return 1;}

bool PRINT() {
return 1;}

bool CLEAR() {
return 1;}

my main() {get_ready();
while (tst--){

 if (!READ()) { return 0; }
 if (!SOLVE()) { cout<<"NO"<<endl; return 0; }
 if (!PRINT()) { return 0; }
 if (!CLEAR()) { return 0; }

}}


/*

    Author of solution {

           gskhirtladze;

    }

*/

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <string>

#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define Pii pair < int , int >
#define tree int t,int l,int r
#define left 2*t,l,(l+r)/2
#define right 2*t+1,(l+r)/2+1,r
#define f_sum(i,r) for (int i=r;i>=0;i=(i&(i+1))-1)
#define f_upd(i,r) for (;i<=r;i=(i|(i+1)))
#define ged(x) scanf("%I64d",&x)
#define getcx getchar
#define my int
#define put(x) cout<<x<<endl;
#define pud(x) printf("%.12f\n",x);
#define LL long long
#define INF 1000000000
#define eps 0.00000001
#define P7 1000000007
#define P9 1000000009
#define N3 2555
#define N5 162145
#define N6 1048577
#define SS system("pause")

using namespace std;

inline void inp(int &n )
 {n=0; int ch=getcx();int sign=1;
  while(ch<'0'||ch>'9'){if(ch=='-')sign=-1; ch=getcx();}
  while(  ch >= '0' && ch <= '9' ) n=(n<<3)+(n<<1)+ch-'0',ch=getcx();
  n=n*sign;}

LL gcd(LL A,LL B) {
    return A>B?gcd(B,A):A?gcd(B%A,A):B; }

LL lcm(LL A,LL B) {
    return A/gcd(A,B)*B; }

LL pow(LL A,LL B,LL P) {
   if (!B) return 1%P;
   LL h=pow(A,B/2,P); h*=h;
   h%=P; if (B%2) h*=A; return h%P; }

pair < Pii , int > P1[N5],P2[N5];
int n,m;

vector <int> z_function (string s) {
  int n = (int) s.length(); vector<int> z (n);
  for (int i=1, l=0, r=0; i<n; ++i) {
    if (i <= r) z[i] = min (r-i+1, z[i-l]);
    while (i+z[i] < n && s[z[i]] == s[i+z[i]]) ++z[i];
    if (i+z[i]-1 > r) l = i,  r = i+z[i]-1; } return z; }

/* // DSU
int PR[N5],SZ[N5];

int parent(int u) {
  if (PR[u] == u) return u;
  PR[u]=parent(PR[u]);return PR[u];}

void uni(int u,int v){
 u=parent(u); v=parent(v);
 SZ[u]+=SZ[v]; SZ[v]=0; PR[v]=u;}
*/

void red()
 {  sort(P1+1,P1+n+1);
    sort(P2+1,P2+m+1); }
/* // Primes
int lp[N6+2];
vector < int > pr;

void get_pr(int N) {
 for (int i=2;i<=N;i++)
  {if (lp[i] == 0){ pr.pb(i); lp[i]=i; }
   for (int j=0;j<pr.size()&& pr[j]<=lp[i] && pr[j]*i<=N;j++) lp[pr[j]*i]=pr[j]; } }
*/
set < Pii > myset;
Pii D[N5];
int tst,l;
set < Pii > :: iterator IT;
void get_ready() {
     //freopen(".in","r",stdin);
     //freopen(".out","w",stdout);
     tst=1; }
void ins(int i)
 { while (l <= m && P1[i].fi.fi >= P2[l].fi.fi)
     { myset.insert(mk(P2[l].fi.se,P2[l].se)); l++; } }
void er(Pii nxt) { myset.erase(nxt); }

int a,b,c,i;
int MAA[N5];

int nxt;

Pii fin(Pii A)
 {
  IT=myset.lower_bound(A);
  if (IT == myset.end()) return mk(-1,-1);
  Pii res=*IT;
  return res;
 }

bool READ() {

 cin>>n; l=1;
 for (i=1;i<=n;i++)
 {
  scanf("%d%d",&a,&b);
  P1[i]=mk(mk(a,b),i);
 }
 cin>>m;
 for (i=1;i<=m;i++)
 {
  scanf("%d%d%d",&a,&b,&c);
  D[i]=mk(a,b);
  P2[i]=mk(mk(a,b),i);
  MAA[i]=c;
 } red();

return 1;}
int ress[N5];
bool SOLVE() {

 int lt=0;
  for (i=1;i<=n;i++)
  {
   ins(i);
   Pii nxt=fin(mk(P1[i].fi.se,0));
   if (nxt == mk(-1,-1)) return 0;
   MAA[nxt.se]--;
   ress[P1[i].se]=nxt.se;
   if (!MAA[nxt.se]) myset.erase(IT);
  }
  cout<<"YES"<<endl;
  for (i=1;i<=n;i++)
     cout<<ress[i]<<" ";
  cout<<endl;

return 1;}

bool PRINT() {
return 1;}

bool CLEAR() {
return 1;}

my main() {get_ready();
while (tst--){

 if (!READ()) { return 0; }
 if (!SOLVE()) { cout<<"NO"<<endl; return 0; }
 if (!PRINT()) { return 0; }
 if (!CLEAR()) { return 0; }

}}


/*

    Author of solution {

           gskhirtladze;

    }

*/

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <string>

#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define Pii pair < int , int >
#define tree int t,int l,int r
#define left 2*t,l,(l+r)/2
#define right 2*t+1,(l+r)/2+1,r
#define f_sum(i,r) for (int i=r;i>=0;i=(i&(i+1))-1)
#define f_upd(i,r) for (;i<=r;i=(i|(i+1)))
#define ged(x) scanf("%I64d",&x)
#define getcx getchar
#define my int
#define put(x) cout<<x<<endl;
#define pud(x) printf("%.12f\n",x);
#define LL long long
#define INF 1000000000
#define eps 0.00000001
#define P7 1000000007
#define P9 1000000009
#define N3 2555
#define N5 262145
#define N6 1048577
#define SS system("pause")

using namespace std;

inline void inp(int &n )
 {n=0; int ch=getcx();int sign=1;
  while(ch<'0'||ch>'9'){if(ch=='-')sign=-1; ch=getcx();}
  while(  ch >= '0' && ch <= '9' ) n=(n<<3)+(n<<1)+ch-'0',ch=getcx();
  n=n*sign;}

LL gcd(LL A,LL B) {
    return A>B?gcd(B,A):A?gcd(B%A,A):B; }

LL lcm(LL A,LL B) {
    return A/gcd(A,B)*B; }

LL pow(LL A,LL B,LL P) {
   if (!B) return 1%P;
   LL h=pow(A,B/2,P); h*=h;
   h%=P; if (B%2) h*=A; return h%P; }

pair < Pii , int > P1[N5/5],P2[N5/5];
int n,m;

vector <int> z_function (string s) {
  int n = (int) s.length(); vector<int> z (n);
  for (int i=1, l=0, r=0; i<n; ++i) {
    if (i <= r) z[i] = min (r-i+1, z[i-l]);
    while (i+z[i] < n && s[z[i]] == s[i+z[i]]) ++z[i];
    if (i+z[i]-1 > r) l = i,  r = i+z[i]-1; } return z; }

/* // DSU
int PR[N5],SZ[N5];

int parent(int u) {
  if (PR[u] == u) return u;
  PR[u]=parent(PR[u]);return PR[u];}

void uni(int u,int v){
 u=parent(u); v=parent(v);
 SZ[u]+=SZ[v]; SZ[v]=0; PR[v]=u;}
*/

void red()
 {  sort(P1+1,P1+n+1);
    sort(P2+1,P2+m+1); }
/* // Primes
int lp[N6+2];
vector < int > pr;

void get_pr(int N) {
 for (int i=2;i<=N;i++)
  {if (lp[i] == 0){ pr.pb(i); lp[i]=i; }
   for (int j=0;j<pr.size()&& pr[j]<=lp[i] && pr[j]*i<=N;j++) lp[pr[j]*i]=pr[j]; } }
*/
set < Pii > myset;
Pii D[N5/5];
int tst,l;
void get_ready() {
     //freopen(".in","r",stdin);
     //freopen(".out","w",stdout);
     tst=1; }
void ins(int i)
 { while (l <= m && P1[i].fi.fi >= P2[l].fi.fi)
     { myset.insert(mk(P2[l].fi.se,P2[l].se)); l++; } }
void er(int nxt) { myset.erase(mk(D[nxt].se,nxt)); }

int a,b,c,i;
int MAA[N5/2];

int nxt;

int fin(Pii A)
 {
  if (myset.lower_bound(A) == myset.end()) return -1;
  Pii res=*myset.lower_bound(A);
  return res.se;
 }

bool READ() {

 cin>>n; l=1;
 for (i=1;i<=n;i++)
 {
  scanf("%d%d",&a,&b);
  P1[i]=mk(mk(a,b),i);
 }
 cin>>m;
 for (i=1;i<=m;i++)
 {
  scanf("%d%d%d",&a,&b,&c);
  D[i]=mk(a,b);
  P2[i]=mk(mk(a,b),i);
  MAA[i]=c;
 } red();

return 1;}

vector < int > ress;

bool SOLVE() {

 int lt=0;
  for (i=1;i<=n;i++)
  {
   ins(i);
   int nxt=fin(mk(P1[i].fi.se,0));
   if (nxt == -1) return 0;
   MAA[nxt]--;
   ress.pb(nxt);
   if (!MAA[nxt]) er(nxt);
  }
  cout<<"YES"<<endl;
  for (i=0;i<ress.size();i++)
     cout<<ress[i]<<" ";
  cout<<endl;

return 1;}

bool PRINT() {
return 1;}

bool CLEAR() {
return 1;}

my main() {get_ready();
while (tst--){

 if (!READ()) { return 0; }
 if (!SOLVE()) { cout<<"NO"<<endl; return 0; }
 if (!PRINT()) { return 0; }
 if (!CLEAR()) { return 0; }

}}


/*

    Author of solution {

           gskhirtladze;

    }

*/

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <string>

#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define Pii pair < int , int >
#define tree int t,int l,int r
#define left 2*t,l,(l+r)/2
#define right 2*t+1,(l+r)/2+1,r
#define f_sum(i,r) for (int i=r;i>=0;i=(i&(i+1))-1)
#define f_upd(i,r) for (;i<=r;i=(i|(i+1)))
#define ged(x) scanf("%I64d",&x)
#define getcx getchar
#define my int
#define put(x) cout<<x<<endl;
#define pud(x) printf("%.12f\n",x);
#define LL long long
#define INF 1000000000
#define eps 0.00000001
#define P7 1000000007
#define P9 1000000009
#define N3 2555
#define N5 262145
#define N6 1048577
#define SS system("pause")

using namespace std;

inline void inp(int &n )
 {n=0; int ch=getcx();int sign=1;
  while(ch<'0'||ch>'9'){if(ch=='-')sign=-1; ch=getcx();}
  while(  ch >= '0' && ch <= '9' ) n=(n<<3)+(n<<1)+ch-'0',ch=getcx();
  n=n*sign;}

LL gcd(LL A,LL B) {
    return A>B?gcd(B,A):A?gcd(B%A,A):B; }

LL lcm(LL A,LL B) {
    return A/gcd(A,B)*B; }

LL pow(LL A,LL B,LL P) {
   if (!B) return 1%P;
   LL h=pow(A,B/2,P); h*=h;
   h%=P; if (B%2) h*=A; return h%P; }

pair < Pii , int > P1[N5/5],P2[N5/5];
int n,m;

vector <int> z_function (string s) {
  int n = (int) s.length(); vector<int> z (n);
  for (int i=1, l=0, r=0; i<n; ++i) {
    if (i <= r) z[i] = min (r-i+1, z[i-l]);
    while (i+z[i] < n && s[z[i]] == s[i+z[i]]) ++z[i];
    if (i+z[i]-1 > r) l = i,  r = i+z[i]-1; } return z; }

/* // DSU
int PR[N5],SZ[N5];

int parent(int u) {
  if (PR[u] == u) return u;
  PR[u]=parent(PR[u]);return PR[u];}

void uni(int u,int v){
 u=parent(u); v=parent(v);
 SZ[u]+=SZ[v]; SZ[v]=0; PR[v]=u;}
*/

void red()
 {  sort(P1+1,P1+n+1);
    sort(P2+1,P2+m+1); }
/* // Primes
int lp[N6+2];
vector < int > pr;

void get_pr(int N) {
 for (int i=2;i<=N;i++)
  {if (lp[i] == 0){ pr.pb(i); lp[i]=i; }
   for (int j=0;j<pr.size()&& pr[j]<=lp[i] && pr[j]*i<=N;j++) lp[pr[j]*i]=pr[j]; } }
*/
set < Pii > myset;
Pii D[N5/5];
int tst,l;
set < Pii > :: iterator IT;
void get_ready() {
     //freopen(".in","r",stdin);
     //freopen(".out","w",stdout);
     tst=1; }
void ins(int i)
 { while (l <= m && P1[i].fi.fi >= P2[l].fi.fi)
     { myset.insert(mk(P2[l].fi.se,P2[l].se)); l++; } }
void er(Pii nxt) { myset.erase(nxt); }

int a,b,c,i;
int MAA[N5/2];

int nxt;

Pii fin(Pii A)
 {
  IT=myset.lower_bound(A);
  if (IT == myset.end()) return mk(-1,-1);
  Pii res=*IT;
  return res;
 }

bool READ() {

 cin>>n; l=1;
 for (i=1;i<=n;i++)
 {
  scanf("%d%d",&a,&b);
  P1[i]=mk(mk(a,b),i);
 }
 cin>>m;
 for (i=1;i<=m;i++)
 {
  scanf("%d%d%d",&a,&b,&c);
  D[i]=mk(a,b);
  P2[i]=mk(mk(a,b),i);
  MAA[i]=c;
 } red();

return 1;}

vector < int > ress;

bool SOLVE() {

 int lt=0;
  for (i=1;i<=n;i++)
  {
   ins(i);
   Pii nxt=fin(mk(P1[i].fi.se,0));
   if (nxt == mk(-1,-1)) return 0;
   MAA[nxt.se]--;
   ress.pb(nxt.se);
   if (!MAA[nxt.se]) er(nxt);
  }
  cout<<"YES"<<endl;
  for (i=0;i<ress.size();i++)
     cout<<ress[i]<<" ";
  cout<<endl;

return 1;}

bool PRINT() {
return 1;}

bool CLEAR() {
return 1;}

my main() {get_ready();
while (tst--){

 if (!READ()) { return 0; }
 if (!SOLVE()) { cout<<"NO"<<endl; return 0; }
 if (!PRINT()) { return 0; }
 if (!CLEAR()) { return 0; }

}}


/*

    Author of solution {

           gskhirtladze;

    }

*/

#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <string>

#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define Pii pair < int , int >
#define tree int t,int l,int r
#define left 2*t,l,(l+r)/2
#define right 2*t+1,(l+r)/2+1,r
#define f_sum(i,r) for (int i=r;i>=0;i=(i&(i+1))-1)
#define f_upd(i,r) for (;i<=r;i=(i|(i+1)))
#define ged(x) scanf("%I64d",&x)
#define getcx getchar
#define my int
#define put(x) cout<<x<<endl;
#define pud(x) printf("%.12f\n",x);
#define LL long long
#define INF 1000000000
#define eps 0.00000001
#define P7 1000000007
#define P9 1000000009
#define N3 2555
#define N5 162145
#define N6 1048577
#define SS system("pause")

using namespace std;

inline void inp(int &n )
 {n=0; int ch=getcx();int sign=1;
  while(ch<'0'||ch>'9'){if(ch=='-')sign=-1; ch=getcx();}
  while(  ch >= '0' && ch <= '9' ) n=(n<<3)+(n<<1)+ch-'0',ch=getcx();
  n=n*sign;}

LL gcd(LL A,LL B) {
    return A>B?gcd(B,A):A?gcd(B%A,A):B; }

LL lcm(LL A,LL B) {
    return A/gcd(A,B)*B; }

LL pow(LL A,LL B,LL P) {
   if (!B) return 1%P;
   LL h=pow(A,B/2,P); h*=h;
   h%=P; if (B%2) h*=A; return h%P; }

pair < Pii , int > P1[N5],P2[N5];
int n,m;

vector <int> z_function (string s) {
  int n = (int) s.length(); vector<int> z (n);
  for (int i=1, l=0, r=0; i<n; ++i) {
    if (i <= r) z[i] = min (r-i+1, z[i-l]);
    while (i+z[i] < n && s[z[i]] == s[i+z[i]]) ++z[i];
    if (i+z[i]-1 > r) l = i,  r = i+z[i]-1; } return z; }

/* // DSU
int PR[N5],SZ[N5];

int parent(int u) {
  if (PR[u] == u) return u;
  PR[u]=parent(PR[u]);return PR[u];}

void uni(int u,int v){
 u=parent(u); v=parent(v);
 SZ[u]+=SZ[v]; SZ[v]=0; PR[v]=u;}
*/

void red()
 {  sort(P1+1,P1+n+1);
    sort(P2+1,P2+m+1); }
/* // Primes
int lp[N6+2];
vector < int > pr;

void get_pr(int N) {
 for (int i=2;i<=N;i++)
  {if (lp[i] == 0){ pr.pb(i); lp[i]=i; }
   for (int j=0;j<pr.size()&& pr[j]<=lp[i] && pr[j]*i<=N;j++) lp[pr[j]*i]=pr[j]; } }
*/
set < Pii > myset;
Pii D[N5];
int tst,l;
set < Pii > :: iterator IT;
void get_ready() {
     //freopen(".in","r",stdin);
     //freopen(".out","w",stdout);
     tst=1; }
void ins(int i)
 { while (l <= m && P1[i].fi.fi >= P2[l].fi.fi)
     { myset.insert(mk(P2[l].fi.se,P2[l].se)); l++; } }
void er(Pii nxt) { myset.erase(nxt); }

int a,b,c,i;
int MAA[N5];

int nxt;

Pii fin(Pii A)
 {
  IT=myset.lower_bound(A);
  if (IT == myset.end()) return mk(-1,-1);
  Pii res=*IT;
  return res;
 }

bool READ() {

 cin>>n; l=1;
 for (i=1;i<=n;i++)
 {
  scanf("%d%d",&a,&b);
  P1[i]=mk(mk(a,b),i);
 }
 cin>>m;
 for (i=1;i<=m;i++)
 {
  scanf("%d%d%d",&a,&b,&c);
  D[i]=mk(a,b);
  P2[i]=mk(mk(a,b),i);
  MAA[i]=c;
 } red();

return 1;}
int ress[N5];
bool SOLVE() {

 int lt=0;
  for (i=1;i<=n;i++)
  {
   ins(i);
   Pii nxt=fin(mk(P1[i].fi.se,0));
   if (nxt == mk(-1,-1)) return 0;
   MAA[nxt.se]--;
   ress[a[i].se]=nxt.se;
   if (!MAA[nxt.se]) myset.erase(IT);
  }
  cout<<"YES"<<endl;
  for (i=1;i<=n;i++)
     cout<<ress[i]<<" ";
  cout<<endl;

return 1;}

bool PRINT() {
return 1;}

bool CLEAR() {
return 1;}

my main() {get_ready();
while (tst--){

 if (!READ()) { return 0; }
 if (!SOLVE()) { cout<<"NO"<<endl; return 0; }
 if (!PRINT()) { return 0; }
 if (!CLEAR()) { return 0; }

}}


#include<bits/stdc++.h>
#define Maxn 100010
using namespace std;

struct point{
    int x,y,z,id;
    bool operator<(const point &a)const{
        return y>a.y;
    }
}a[Maxn],b[Maxn];
struct cmp{
    bool operator()(const point &a,const point &b)const{
        return a.x>b.x;
    }
};
set<point,cmp> s;
set<point>::iterator it;
int ans[Maxn];
int main()
{
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].x>>a[i].y;
        a[i].id=i+1;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>b[i].x>>b[i].y>>b[i].z;
        b[i].id=i+1;
    }
    sort(a,a+n);
    sort(b,b+n);
    //for(int i=0;i<n;i++)
        //cout<<a[i].y<<" "<<endl;
    int fr=0;
    bool flag=true;
    for(int i=0;i<n;i++){
        for(int j=fr;j<m;j++,fr++){
            if(b[j].y>=a[i].y){
                it=s.find(b[j]);
                if(it!=s.end()){
                    b[j].z+=it->z;
                    s.erase(it);
                }
                s.insert(b[j]);
            }
            else break;
        }
        it=s.lower_bound(a[i]);
        if(it==s.end()) {flag=false;break;}
        else{
            point tmp=*it;
            ans[a[i].id]=it->id;
            s.erase(it);
            if(--tmp.z) s.insert(tmp);
        }
    }
    if(flag){
        puts("YES");
        cout<<ans[1];
        for(int i=2;i<=n;i++)
            cout<<" "<<ans[i];
        cout<<endl;
    }
    else puts("NO");
	return 0;
}


#include<bits/stdc++.h>
#define Maxn 100010
using namespace std;

struct point{
    int x,y,z,id;
    bool operator<(const point &a)const{
        return y>a.y;
    }
}a[Maxn],b[Maxn];
struct cmp{
    bool operator()(const point &a,const point &b)const{
        if(a.x==b.x) return a.id<b.id;
        return a.x>b.x;
    }
};
set<point,cmp> s;
set<point>::iterator it;
int ans[Maxn];
int main()
{
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].x>>a[i].y;
        a[i].id=i+1;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>b[i].x>>b[i].y>>b[i].z;
        b[i].id=i+1;
    }
    sort(a,a+n);
    sort(b,b+n);
    //for(int i=0;i<n;i++)
        //cout<<a[i].y<<" "<<endl;
    int fr=0;
    bool flag=true;
    for(int i=0;i<n;i++){
        for(int j=fr;j<m;j++,fr++){
            if(b[j].y>=a[i].y) s.insert(b[j]);
            else break;
        }
        it=s.lower_bound(a[i]);
        if(it==s.end()) {flag=false;break;}
        else{
            point tmp=*it;
            ans[a[i].id]=it->id;
            s.erase(it);
            if(--tmp.z) s.insert(tmp);
        }
    }
    if(flag){
        puts("YES");
        cout<<ans[1];
        for(int i=2;i<=n;i++)
            cout<<" "<<ans[i];
        cout<<endl;
    }
    else puts("NO");
	return 0;
}


#include<bits/stdc++.h>
#define Maxn 100010
using namespace std;

struct point{
    int x,y,z;
    bool operator<(const point &a)const{
        return y>a.y;
    }
}a[Maxn],b[Maxn];
struct cmp{
    bool operator()(const point &a,const point &b)const{
        return a.x>b.x;
    }
};
set<point,cmp> s;
set<point>::iterator it;
int main()
{
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i].x>>a[i].y;
    cin>>m;
    for(int i=0;i<m;i++)
        cin>>b[i].x>>b[i].y>>b[i].z;
    sort(a,a+n);
    sort(b,b+n);
    //for(int i=0;i<n;i++)
        //cout<<a[i].y<<" "<<endl;
    int fr=0;
    bool flag=true;
    for(int i=0;i<n;i++){
        for(int j=fr;j<m;j++,fr++){
            if(b[j].y>=a[i].y){
                it=s.find(b[j]);
                if(it!=s.end()){
                    b[j].z+=it->z;
                    s.erase(it);
                }
                s.insert(b[j]);
            }
            else break;
        }
        it=s.lower_bound(a[i]);
        if(it==s.end()) {flag=false;break;}
        else{
            point tmp=*it;
            s.erase(it);
            if(--tmp.z) s.insert(tmp);
        }
    }
    if(flag) puts("YES");
    else puts("NO");
	return 0;
}


#include<bits/stdc++.h>
#define Maxn 100010
using namespace std;

struct point{
    int x,y,z,id;
    bool operator<(const point &a)const{
        return y>a.y;
    }
}a[Maxn],b[Maxn];
struct cmp{
    bool operator()(const point &a,const point &b)const{
        if(a.x==b.x) return a.id<b.id;
        return a.x>b.x;
    }
};
set<point,cmp> s;
set<point>::iterator it;
int ans[Maxn];
int main()
{
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].x>>a[i].y;
        a[i].id=i+1;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>b[i].x>>b[i].y>>b[i].z;
        b[i].id=i+1;
    }
    sort(a,a+n);
    sort(b,b+m);
    int fr=0;
    bool flag=true;
    for(int i=0;i<n;i++){
        for(int j=fr;j<m;j++,fr++){
            if(b[j].y>=a[i].y) s.insert(b[j]);
            else break;
        }
        int id=a[i].id;
        a[i].id=-1;
        it=s.lower_bound(a[i]);
        if(it==s.end()) {flag=false;break;}
        else{
            point tmp=*it;
            ans[id]=it->id;
            s.erase(it);
            if(--tmp.z) s.insert(tmp);
        }
    }
    if(flag){
        puts("YES");
        cout<<ans[1];
        for(int i=2;i<=n;i++)
            cout<<" "<<ans[i];
        cout<<endl;
    }
    else puts("NO");
	return 0;
}


#include<bits/stdc++.h>
#define Maxn 100010
using namespace std;

struct point{
    int x,y,z,id;
    bool operator<(const point &a)const{
        return y>a.y;
    }
}a[Maxn],b[Maxn];
struct cmp{
    bool operator()(const point &a,const point &b)const{
        if(a.x==b.x) return a.id<b.id;
        return a.x>b.x;
    }
};
set<point,cmp> s;
set<point>::iterator it;
int ans[Maxn];
int main()
{
    int n,m;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i].x>>a[i].y;
        a[i].id=i+1;
    }
    cin>>m;
    for(int i=0;i<m;i++){
        cin>>b[i].x>>b[i].y>>b[i].z;
        b[i].id=i+1;
    }
    sort(a,a+n);
    sort(b,b+n);
    //for(int i=0;i<n;i++)
        //cout<<a[i].y<<" "<<endl;
    int fr=0;
    bool flag=true;
    for(int i=0;i<n;i++){
        for(int j=fr;j<m;j++,fr++){
            if(b[j].y>=a[i].y) s.insert(b[j]);
            else break;
        }
        int id=a[i].id;
        a[i].id=-1;
        it=s.lower_bound(a[i]);
        if(it==s.end()) {flag=false;break;}
        else{
            point tmp=*it;
            ans[id]=it->id;
            s.erase(it);
            if(--tmp.z) s.insert(tmp);
        }
    }
    if(flag){
        puts("YES");
        cout<<ans[1];
        for(int i=2;i<=n;i++)
            cout<<" "<<ans[i];
        cout<<endl;
    }
    else puts("NO");
	return 0;
}


#include <cstdio>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <memory.h>
#include <sstream>
#include <complex>
#include <cassert>
#include <functional>

#define REP(i,n) for(int i = 0, _n = (n); i < _n; i++)
#define REPD(i,n) for(int i = (n) - 1; i >= 0; i--)
#define FOR(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define FORN(i,a,b) for(int i=a;i<b;i++)
#define FOREACH(it,c) for (__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define RESET(c,x) memset (c, x, sizeof (c))

#define PI acos(-1)
#define sqr(x) ((x) * (x))
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Aint(c) (c).begin(), (c).end()
#define SIZE(c) (c).size()

#define DEBUG(x) { cerr << #x << " = " << x << endl; }
#define PR(a,n) {cerr<<#a<<" = "; FOR(_,1,n) cerr << a[_] << ' '; cerr <<endl;}
#define PR0(a,n) {cerr<<#a<<" = ";REP(_,n) cerr << a[_] << ' '; cerr << endl;}
#define LL long long

using namespace std;

#define MAXN 112345

int res[MAXN], a[MAXN], b[MAXN], c[MAXN], d[MAXN], k[MAXN];
int n, m;

struct Event {
	int t; //-1 open, 1 close, 0 for part
	int index;
	int time;

	Event (int t, int index, int time): t(t), index(index), time(time) {};
};

vector <Event> event;

bool cmp(Event a, Event b) {
	if (a.time != b.time) return a.time < b.time;
	if (a.t != b.t) return a.t < b.t;
	return a.index < b.index;
}

set<pair<int, int> > actor;

int main() {
	//freopen("a.in", "r", stdin);
	//freopen("a.out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];

	cin >> m;
	for (int i = 1; i <= m; i++)
		cin >> c[i] >> d[i] >> k[i];

	for (int i = 1; i <= m; i++) {
		event.push_back(Event(-1, i, c[i]));
		event.push_back(Event( 1, i, d[i]));
	}

	for (int i = 1; i <= n; i++)
		event.push_back(Event(0, i, a[i]));

	sort(event.begin(), event.end(), cmp);

	for (int i = 0; i < (int) event.size(); i++)
		if (event[i].t == -1) actor.insert(make_pair(d[event[i].index], event[i].index));
		else if (event[i].t == 1) {
			set<pair<int, int> >::iterator it = actor.find(make_pair(d[event[i].index], event[i].index));
			if (it != actor.end())
				actor.erase(it);
		}
		else {
			int part = event[i].index;

			while(true) {
				set<pair<int, int> >::iterator it = actor.lower_bound(make_pair(b[part], -1));
				if (it == actor.end()) break;

				k[it -> second]--;
				res[part] = it -> second;

				if (k[it -> second] == 0)
					actor.erase(it);

				break;
			}
		}

	bool ok = true;
	for (int i = 1; i <= n; i++)
		if (res[i] == 0) ok = false;

	if (ok) {
		cout <<"YES" << endl;
		for (int i = 1; i <= n; i++)
			cout << res[i] << " ";
		cout << endl;
	}
	else cout <<"NO" << endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <memory.h>
#include <sstream>
#include <complex>
#include <cassert>
#include <functional>

#define REP(i,n) for(int i = 0, _n = (n); i < _n; i++)
#define REPD(i,n) for(int i = (n) - 1; i >= 0; i--)
#define FOR(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define FORN(i,a,b) for(int i=a;i<b;i++)
#define FOREACH(it,c) for (__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define RESET(c,x) memset (c, x, sizeof (c))

#define PI acos(-1)
#define sqr(x) ((x) * (x))
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Aint(c) (c).begin(), (c).end()
#define SIZE(c) (c).size()

#define DEBUG(x) { cerr << #x << " = " << x << endl; }
#define PR(a,n) {cerr<<#a<<" = "; FOR(_,1,n) cerr << a[_] << ' '; cerr <<endl;}
#define PR0(a,n) {cerr<<#a<<" = ";REP(_,n) cerr << a[_] << ' '; cerr << endl;}
#define LL long long

using namespace std;

#define MAXN 112345

int res[MAXN], a[MAXN], b[MAXN], c[MAXN], d[MAXN], k[MAXN];
int n, m;

struct Event {
	int t; //-1 open, 1 close, 0 for part
	int index;
	int time;

	Event (int t, int index, int time): t(t), index(index), time(time) {};
};

vector <Event> event;

bool cmp(Event a, Event b) {
	if (a.time != b.time) return a.time < b.time;
	if (a.t != b.t) return a.t < b.t;
	return a.index < b.index;
}

set<pair<int, int> > actor;

int main() {
	//freopen("a.in", "r", stdin);
	//freopen("a.out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];

	cin >> m;
	for (int i = 1; i <= m; i++)
		cin >> c[i] >> d[i] >> k[i];

	for (int i = 1; i <= m; i++) {
		event.push_back(Event(-1, i, c[i]));
		event.push_back(Event( 1, i, d[i]));
	}

	for (int i = 1; i <= n; i++)
		event.push_back(Event(0, i, a[i]));

	sort(event.begin(), event.end(), cmp);

	for (int i = 0; i < (int) event.size(); i++)
		if (event[i].t == -1) actor.insert(make_pair(d[event[i].index], event[i].index));
		else if (event[i].t == 1) {
			set<pair<int, int> >::iterator it = actor.find(make_pair(d[event[i].index], event[i].index));
			if (it != actor.end())
				actor.erase(it);
		}
		else {
			int part = event[i].index;

			while(true) {
				set<pair<int, int> >::iterator it = actor.lower_bound(make_pair(b[part], -1));
				if (it == actor.end()) break;

				k[it -> second]--;
				if (k[it -> second] == 0)
					actor.erase(it);

				res[part] = it -> second;
				break;
			}
		}

	bool ok = true;
	for (int i = 1; i <= n; i++)
		if (res[i] == 0) ok = false;

	if (ok) {
		cout <<"YES" << endl;
		for (int i = 1; i <= n; i++)
			cout << res[i] << " ";
		cout << endl;
	}
	else cout <<"NO" << endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <memory.h>
#include <sstream>
#include <complex>
#include <cassert>
#include <functional>

#define REP(i,n) for(int i = 0, _n = (n); i < _n; i++)
#define REPD(i,n) for(int i = (n) - 1; i >= 0; i--)
#define FOR(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define FORN(i,a,b) for(int i=a;i<b;i++)
#define FOREACH(it,c) for (__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define RESET(c,x) memset (c, x, sizeof (c))

#define PI acos(-1)
#define sqr(x) ((x) * (x))
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Aint(c) (c).begin(), (c).end()
#define SIZE(c) (c).size()

#define DEBUG(x) { cerr << #x << " = " << x << endl; }
#define PR(a,n) {cerr<<#a<<" = "; FOR(_,1,n) cerr << a[_] << ' '; cerr <<endl;}
#define PR0(a,n) {cerr<<#a<<" = ";REP(_,n) cerr << a[_] << ' '; cerr << endl;}
#define LL long long

using namespace std;

#define MAXN 212345
#define oo 2000000000
int res[MAXN], a[MAXN], b[MAXN], c[MAXN], d[MAXN], k[MAXN];
int n, m;

struct Event {
	int t; //-1 open, 1 close, 0 for part
	int index;
	int time;

	Event (int t, int index, int time): t(t), index(index), time(time) {};
};

vector <Event> event;

bool cmp(Event a, Event b) {
	if (a.time != b.time) return a.time < b.time;
	if (a.t != b.t) return a.t < b.t;
	return a.index < b.index;
}

int main() {
	//freopen("a.in", "r", stdin);
	//freopen("a.out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];

	cin >> m;
	for (int i = 1; i <= m; i++)
		cin >> c[i] >> d[i] >> k[i];

	for (int i = 1; i <= m; i++) {
		event.push_back(Event(-1, i, c[i]));
		event.push_back(Event( 1, i, d[i]));
	}

	for (int i = 1; i <= n; i++)
		event.push_back(Event(0, i, a[i]));

	sort(event.begin(), event.end(), cmp);

	set<pair<int, int> > actor;

	for (int i = 0; i < (int) event.size(); i++)
		if (event[i].t == -1) actor.insert(make_pair(d[event[i].index], event[i].index));
		else if (event[i].t == 1) {
			set<pair<int, int> >::iterator it = actor.find(make_pair(d[event[i].index], event[i].index));
			if (it != actor.end())
				actor.erase(it);
		}
		else {
			int part = event[i].index;

			//cerr << b[part] << " " << actor.size() << endl;
			// cerr << actor.begin() -> first << endl;
			// cerr << actor.begin() -> second << endl;
			while(true) {
				set<pair<int, int> >::iterator it = actor.lower_bound(make_pair(b[part], -1));
				if (it == actor.end()) break;

				k[it -> second]--;
				if (k[it -> second] == 0)
					actor.erase(it);

				res[part] = it -> second;
				break;
			}

//			cout << part << " " << res[part] << endl;
		}

	bool ok = true;
	for (int i = 1; i <= n; i++)
		if (res[i] == 0) ok = false;

	if (ok) {
		cout <<"YES" << endl;
		for (int i = 1; i <= n; i++)
			cout << res[i] << " ";
		cout << endl;
	}
	else cout <<"NO" << endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <memory.h>
#include <sstream>
#include <complex>
#include <cassert>
#include <functional>

#define REP(i,n) for(int i = 0, _n = (n); i < _n; i++)
#define REPD(i,n) for(int i = (n) - 1; i >= 0; i--)
#define FOR(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define FORN(i,a,b) for(int i=a;i<b;i++)
#define FOREACH(it,c) for (__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define RESET(c,x) memset (c, x, sizeof (c))

#define PI acos(-1)
#define sqr(x) ((x) * (x))
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Aint(c) (c).begin(), (c).end()
#define SIZE(c) (c).size()

#define DEBUG(x) { cerr << #x << " = " << x << endl; }
#define PR(a,n) {cerr<<#a<<" = "; FOR(_,1,n) cerr << a[_] << ' '; cerr <<endl;}
#define PR0(a,n) {cerr<<#a<<" = ";REP(_,n) cerr << a[_] << ' '; cerr << endl;}
#define LL long long

using namespace std;

#define MAXN 412345

int res[MAXN], a[MAXN], b[MAXN], c[MAXN], d[MAXN], k[MAXN];
int n, m;

struct Event {
	int t; //-1 open, 1 close, 0 for part
	int index;
	int time;

	Event (int t, int index, int time): t(t), index(index), time(time) {};
};

vector <Event> event;

bool cmp(Event a, Event b) {
	if (a.time != b.time) return a.time < b.time;
	if (a.t != b.t) return a.t < b.t;
	return a.index < b.index;
}

set<pair<int, int> > actor;

int main() {
	//freopen("a.in", "r", stdin);
	//freopen("a.out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];

	cin >> m;
	for (int i = 1; i <= m; i++)
		cin >> c[i] >> d[i] >> k[i];

	for (int i = 1; i <= m; i++) {
		event.push_back(Event(-1, i, c[i]));
		event.push_back(Event( 1, i, d[i]));
	}

	for (int i = 1; i <= n; i++)
		event.push_back(Event(0, i, a[i]));

	sort(event.begin(), event.end(), cmp);

	for (int i = 0; i < (int) event.size(); i++)
		if (event[i].t == -1) actor.insert(make_pair(d[event[i].index], event[i].index));
		else if (event[i].t == 1) {
			set<pair<int, int> >::iterator it = actor.find(make_pair(d[event[i].index], event[i].index));
			if (it != actor.end())
				actor.erase(it);
		}
		else {
			int part = event[i].index;

			while(true) {
				set<pair<int, int> >::iterator it = actor.lower_bound(make_pair(b[part], -1));
				if (it == actor.end()) break;

				k[it -> second]--;
				if (k[it -> second] == 0)
					actor.erase(it);

				res[part] = it -> second;
				break;
			}
		}

	bool ok = true;
	for (int i = 1; i <= n; i++)
		if (res[i] == 0) ok = false;

	if (ok) {
		cout <<"YES" << endl;
		for (int i = 1; i <= n; i++)
			cout << res[i] << " ";
		cout << endl;
	}
	else cout <<"NO" << endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <memory.h>
#include <sstream>
#include <complex>
#include <cassert>
#include <functional>

#define REP(i,n) for(int i = 0, _n = (n); i < _n; i++)
#define REPD(i,n) for(int i = (n) - 1; i >= 0; i--)
#define FOR(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define FORD(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define FORN(i,a,b) for(int i=a;i<b;i++)
#define FOREACH(it,c) for (__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define RESET(c,x) memset (c, x, sizeof (c))

#define PI acos(-1)
#define sqr(x) ((x) * (x))
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Aint(c) (c).begin(), (c).end()
#define SIZE(c) (c).size()

#define DEBUG(x) { cerr << #x << " = " << x << endl; }
#define PR(a,n) {cerr<<#a<<" = "; FOR(_,1,n) cerr << a[_] << ' '; cerr <<endl;}
#define PR0(a,n) {cerr<<#a<<" = ";REP(_,n) cerr << a[_] << ' '; cerr << endl;}
#define LL long long

using namespace std;

#define MAXN 412345
#define oo 2000000000
int res[MAXN], a[MAXN], b[MAXN], c[MAXN], d[MAXN], k[MAXN];
int n, m;

struct Event {
	int t; //-1 open, 1 close, 0 for part
	int index;
	int time;

	Event (int t, int index, int time): t(t), index(index), time(time) {};
};

vector <Event> event;

bool cmp(Event a, Event b) {
	if (a.time != b.time) return a.time < b.time;
	if (a.t != b.t) return a.t < b.t;
	return a.index < b.index;
}

int main() {
	//freopen("a.in", "r", stdin);
	//freopen("a.out", "w", stdout);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i] >> b[i];

	cin >> m;
	for (int i = 1; i <= m; i++)
		cin >> c[i] >> d[i] >> k[i];

	for (int i = 1; i <= m; i++) {
		event.push_back(Event(-1, i, c[i]));
		event.push_back(Event( 1, i, d[i]));
	}

	for (int i = 1; i <= n; i++)
		event.push_back(Event(0, i, a[i]));

	sort(event.begin(), event.end(), cmp);

	set<pair<int, int> > actor;

	for (int i = 0; i < (int) event.size(); i++)
		if (event[i].t == -1) actor.insert(make_pair(d[event[i].index], event[i].index));
		else if (event[i].t == 1) {
			set<pair<int, int> >::iterator it = actor.find(make_pair(d[event[i].index], event[i].index));
			if (it != actor.end())
				actor.erase(it);
		}
		else {
			int part = event[i].index;

			//cerr << b[part] << " " << actor.size() << endl;
			// cerr << actor.begin() -> first << endl;
			// cerr << actor.begin() -> second << endl;
			while(true) {
				set<pair<int, int> >::iterator it = actor.lower_bound(make_pair(b[part], -1));
				if (it == actor.end()) break;

				k[it -> second]--;
				if (k[it -> second] == 0)
					actor.erase(it);

				res[part] = it -> second;
				break;
			}

//			cout << part << " " << res[part] << endl;
		}

	bool ok = true;
	for (int i = 1; i <= n; i++)
		if (res[i] == 0) ok = false;

	if (ok) {
		cout <<"YES" << endl;
		for (int i = 1; i <= n; i++)
			cout << res[i] << " ";
		cout << endl;
	}
	else cout <<"NO" << endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A[102000],B[102000];
int M,C[102000],D[102000],K[102000];
set<pair<int,int> > S,ev;
int ret[102000];

void solve() {
    int i,j,k,l,r,x,y; string s;

    cin>>N;
    FOR(i,N) cin>>A[i]>>B[i], ev.insert(make_pair(A[i],i+100000));
    cin>>M;
    FOR(i,M) cin>>C[i]>>D[i]>>K[i], ev.insert(make_pair(C[i],i)), ev.insert(make_pair(D[i],i+200000));

    ITR(it,ev) {
        if(it->second<100000) {
            S.insert(make_pair(D[it->second],it->second));
        }
        else if(it->second<200000) {
            int cur=it->second-100000;

            set<pair<int,int> >::iterator sit=S.lower_bound(make_pair(B[cur],0));
            if(sit==S.end()) return _P("NO\n");
            ret[cur]=sit->second+1;
            if(--K[sit->second]==0) S.erase(sit);
        }
        else {
            S.erase(make_pair(D[it->second-200000],it->second-200000));
        }
    }

    _P("YES\n");
    FOR(i,N) _P("%d ",ret[i]);
    _P("\n");
}

int main(int argc,char** argv){
    string s;int i;
    if(argc==1) ios::sync_with_stdio(false);
    FOR(i,argc-1) s+=argv[i+1],s+='\n';
    FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
    solve(); return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A[102000],B[102000];
int M,C[102000],D[102000],K[102000];
map<int,int> MM;
vector<int> add[202000];
vector<int> del[202000];
vector<int> so[202000];
set<pair<int,int> > S;
int ret[102000];

void solve() {
    int i,j,k,l,r,x,y; string s;

    cin>>N;
    FOR(i,N) cin>>A[i]>>B[i];
    cin>>M;
    FOR(i,M) cin>>C[i]>>D[i]>>K[i], MM[C[i]]=MM[D[i]]=0;
    MM[0]=0;
    MM[1<<30]=0;
    x=0;
    ITR(it,MM) it->second=++x;

    FOR(i,M) {
        C[i]=MM[C[i]];
        add[C[i]].push_back(i);
        D[i]=MM[D[i]];
        del[D[i]].push_back(i);
    }
    FOR(i,N) {
        map<int,int>::iterator it=MM.lower_bound(A[i]);
        if(it->first!=A[i]) it--;
        A[i]=it->second;
        so[A[i]].push_back(i);
        it=MM.lower_bound(B[i]);
        B[i]=it->second;
    }

    FOR(i,202000) {
        ITR(it,add[i]) S.insert(make_pair(D[*it],*it));
        FOR(j,so[i].size()) {
            int cur=so[i][j];
            set<pair<int,int> >::iterator sit=S.lower_bound(make_pair(B[cur],0));
            if(sit==S.end()) return _P("NO\n");
            ret[cur]=sit->second+1;
            if(--K[sit->second]==0) S.erase(sit);

        }
        ITR(it,del[i]) S.erase(make_pair(D[*it],*it));
    }

    _P("YES\n");
    FOR(i,N) _P("%d ",ret[i]);
    _P("\n");
}

int main(int argc,char** argv){
    string s;int i;
    if(argc==1) ios::sync_with_stdio(false);
    FOR(i,argc-1) s+=argv[i+1],s+='\n';
    FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
    solve(); return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A[102000],B[102000];
int M,C[102000],D[102000],K[102000];
map<int,int> MM;
vector<int> add[102000];
vector<int> del[102000];
vector<int> so[102000];
set<pair<int,int> > S;
int ret[102000];

void solve() {
    int i,j,k,l,r,x,y; string s;

    cin>>N;
    FOR(i,N) cin>>A[i]>>B[i];

    cin>>M;
    FOR(i,M) cin>>C[i]>>D[i]>>K[i], MM[C[i]]=MM[D[i]]=0;
    MM[0]=0;
    x=0;
    ITR(it,MM) it->second=++x;

    FOR(i,M) {
        C[i]=MM[C[i]];
        add[C[i]].push_back(i);
        D[i]=MM[D[i]];
        del[D[i]].push_back(i);
    }
    FOR(i,N) {
        map<int,int>::iterator it=MM.lower_bound(A[i]);
        if(it->first!=A[i]) it--;
        A[i]=it->second;
        so[A[i]].push_back(i);
        it=MM.lower_bound(B[i]);
        B[i]=it->second;
    }

    FOR(i,102000) {
        ITR(it,add[i]) S.insert(make_pair(D[*it],*it));
        FOR(j,so[i].size()) {
            int cur=so[i][j];
            set<pair<int,int> >::iterator sit=S.lower_bound(make_pair(B[cur],0));
            if(sit==S.end()) return _P("NO\n");
            ret[cur]=sit->second+1;
            if(--K[sit->second]==0) S.erase(sit);

        }
        ITR(it,del[i]) S.erase(make_pair(D[*it],*it));
    }

    _P("YES\n");
    FOR(i,N) _P("%d ",ret[i]);
    _P("\n");
}

int main(int argc,char** argv){
    string s;int i;
    if(argc==1) ios::sync_with_stdio(false);
    FOR(i,argc-1) s+=argv[i+1],s+='\n';
    FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
    solve(); return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A[102000],B[102000];
int M,C[102000],D[102000],K[102000];
map<int,int> MM;
vector<int> add[102000];
vector<int> del[102000];
vector<int> so[102000];
set<pair<int,int> > S;
int ret[102000];

void solve() {
    int i,j,k,l,r,x,y; string s;

    cin>>N;
    FOR(i,N) cin>>A[i]>>B[i], MM[A[i]]=MM[B[i]]=0;

    x=0;
    ITR(it,MM) it->second=++x;

    cin>>M;
    FOR(i,M) {
        cin>>x>>y>>K[i];
        map<int,int>::iterator it=MM.lower_bound(x);
        C[i]=it->second;
        add[C[i]].push_back(i);
        it=MM.lower_bound(y);
        if(it->first!=y) it--;
        D[i]=it->second;
        del[D[i]].push_back(i);
    }
    FOR(i,N) A[i]=MM[A[i]], B[i]=MM[B[i]], so[A[i]].push_back(i);
    FOR(i,102000) {
        ITR(it,add[i]) S.insert(make_pair(D[*it],*it));
        FOR(j,so[i].size()) {
            int cur=so[i][j];
            set<pair<int,int> >::iterator sit=S.lower_bound(make_pair(B[cur],0));
            if(sit==S.end()) return _P("NO\n");
            ret[cur]=sit->second+1;
            if(--K[sit->second]==0) S.erase(sit);
        }
        ITR(it,del[i]) S.erase(make_pair(D[*it],*it));
    }

    _P("YES\n");
    FOR(i,N) _P("%d ",ret[i]);
    _P("\n");
}

int main(int argc,char** argv){
    string s;int i;
    if(argc==1) ios::sync_with_stdio(false);
    FOR(i,argc-1) s+=argv[i+1],s+='\n';
    FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
    solve(); return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,A[102000],B[102000];
int M,C[102000],D[102000],K[102000];
map<int,int> MM;
vector<int> add[102000];
vector<int> del[102000];
vector<int> so[102000];
set<pair<int,int> > S;
int ret[102000];

void solve() {
    int i,j,k,l,r,x,y; string s;

    cin>>N;
    FOR(i,N) cin>>A[i]>>B[i];

    cin>>M;
    FOR(i,M) cin>>C[i]>>D[i]>>K[i], MM[C[i]]=MM[D[i]]=0;
    MM[0]=0;
    MM[1<<30]=0;
    x=0;
    ITR(it,MM) it->second=++x;

    FOR(i,M) {
        C[i]=MM[C[i]];
        add[C[i]].push_back(i);
        D[i]=MM[D[i]];
        del[D[i]].push_back(i);
    }
    FOR(i,N) {
        map<int,int>::iterator it=MM.lower_bound(A[i]);
        if(it->first!=A[i]) it--;
        A[i]=it->second;
        so[A[i]].push_back(i);
        it=MM.lower_bound(B[i]);
        B[i]=it->second;
    }

    FOR(i,102000) {
        ITR(it,add[i]) S.insert(make_pair(D[*it],*it));
        FOR(j,so[i].size()) {
            int cur=so[i][j];
            set<pair<int,int> >::iterator sit=S.lower_bound(make_pair(B[cur],0));
            if(sit==S.end()) return _P("NO\n");
            ret[cur]=sit->second+1;
            if(--K[sit->second]==0) S.erase(sit);

        }
        ITR(it,del[i]) S.erase(make_pair(D[*it],*it));
    }

    _P("YES\n");
    FOR(i,N) _P("%d ",ret[i]);
    _P("\n");
}

int main(int argc,char** argv){
    string s;int i;
    if(argc==1) ios::sync_with_stdio(false);
    FOR(i,argc-1) s+=argv[i+1],s+='\n';
    FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
    solve(); return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <climits>

using namespace std;

#define F first
#define S second

const int maxn = 100500;

struct p {
    int l, r, i;
};

bool cmp(p a, p b) {
    if (a.l < b.l || (a.l == b.l && a.i >= 0 && b.i == -1) || (a.l == b.l && a.r < b.r && a.i >= 0 && b.i >= 0) || (a.l == b.l && a.r == b.r && a.i >= 0 && b.i >= 0 && a.i < b.i))
        return true;
    else
        return false;
}

struct comp {
    bool operator()(p a, p b) {
        return cmp(a, b);
    }
};

p a[200500];
int l[100500];
int ans[100500];
int s;

bool scmp(p a, p b) {
    if (a.r < b.r)
        return true;
    else
        return false;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        a[s].l = x;
        a[s].r = y;
        a[s].i = -1;
        s++;
    }

    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int x, y, k;
        cin >> x >> y >> k;
        a[s].l = x;
        a[s].r = y;
        a[s].i = i;
        l[i] = k;
        s++;
    }

    sort(a, a + s, cmp);

    set<p, comp> c;
    int v = 0;
    for (int i = 0; i < s; ++i) {
        /*for (set<p>::iterator it = c.begin(); it != c.end(); ++it) {
            cout << it->l << " " << it->r << " " << it->i << endl;
        }
        cout << endl;*/
        if (a[i].i == -1) {
            set<p>::iterator it;
            it = lower_bound(c.begin(), c.end(), a[i], scmp);
            if (it == c.end()) {
                cout << "NO" << endl;
                return 0;
            }
            //cout << it->i << endl;
            ans[v] = it->i;
            v++;
            l[it->i]--;
            if (l[it->i] <= 0)
                c.erase(it);
        }
        else {
            /*if (c.find(a[i]) != c.end()) {
                cout << "neok";
            }*/
            c.insert(a[i]);
        }
    }

    cout << "YES" << endl;

    for (int i = 0; i < n; ++i) {
        cout << ans[i] + 1 << " ";
    }
    cout << endl;

    return 0;

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <climits>

using namespace std;

#define F first
#define S second

const int INF = 1000000000;

pair<pair<int, int>, pair<bool, int> > t[200500];
int k[100500], ans[100500];

bool comp(pair<pair<int, int>, pair<bool, int> > a, pair<pair<int, int>, pair<bool, int> > b) {
    if (a.F.F < b.F.F || (a.F.F == b.F.F && a.S.F && !b.S.F))
        return true;
    else
        return false;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> t[i].F.F >> t[i].F.S;
        t[i].S.F = 0;
        t[i].S.S = i;
    }

    int m;
    cin >> m;

    for (int i = n; i < n + m; ++i) {
        int l;
        cin >> t[i].F.F >> t[i].F.S >> l;
        t[i].S.F = 1;
        t[i].S.S = i - n;
        k[i - n] = l;
    }

    sort(t, t + n + m, comp);

    set<pair<int, int> > r;

    for (int i = 0; i < n + m; ++i) {
        if (!t[i].S.F) {
            set<pair<int, int> >::iterator it = r.lower_bound(make_pair(t[i].F.S, -1));
            if (it == r.end()) {
                cout << "NO" << endl;
                return 0;
            }
            k[it->S]--;
            ans[t[i].S.S] = it->S;
            if (k[it->S] <= 0) {
                r.erase(it);
            }
        }
        else {
            r.insert(make_pair(t[i].F.S, t[i].S.S));
        }

    }

    cout << "YES" << endl;

    for (int i = 0; i < n; ++i)
        cout << ans[i] + 1 << " ";
    cout << endl;

    return 0;

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <climits>

using namespace std;

#define F first
#define S second

const int INF = 1000000000;

pair<pair<int, int>, pair<bool, int> > t[100500];
int k[100500], ans[100500];

bool comp(pair<pair<int, int>, pair<bool, int> > a, pair<pair<int, int>, pair<bool, int> > b) {
    if (a.F.F < b.F.F || (a.F.F == b.F.F && a.S.F && !b.S.F))
        return true;
    else
        return false;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> t[i].F.F >> t[i].F.S;
        t[i].S.F = 0;
        t[i].S.S = i;
    }

    int m;
    cin >> m;

    for (int i = n; i < n + m; ++i) {
        int l;
        cin >> t[i].F.F >> t[i].F.S >> l;
        t[i].S.F = 1;
        t[i].S.S = i - n;
        k[i - n] = l;
    }

    sort(t, t + n + m, comp);

    set<pair<int, int> > r;

    for (int i = 0; i < n + m; ++i) {
        if (!t[i].S.F) {
            set<pair<int, int> >::iterator it = lower_bound(r.begin(), r.end(), make_pair(t[i].F.S, -1));
            if (it == r.end()) {
                cout << "NO" << endl;
                return 0;
            }
            k[it->S]--;
            ans[t[i].S.S] = it->S;
            if (k[it->S] <= 0) {
                r.erase(it);
            }
        }
        else {
            r.insert(make_pair(t[i].F.S, t[i].S.S));
        }

    }

    cout << "YES" << endl;

    for (int i = 0; i < n; ++i)
        cout << ans[i] + 1 << " ";
    cout << endl;

    return 0;

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <climits>

using namespace std;

#define F first
#define S second

const int maxn = 100500;

struct p {
    int l, r, i;
};

bool cmp(p a, p b) {
    if (a.l < b.l || (a.l == b.l && a.i >= 0 && b.i == -1) || (a.r < b.r && a.i >= 0 && b.i >= 0))
        return true;
    else
        return false;
}

struct comp {
    bool operator()(p a, p b) {
        return cmp(a, b);
    }
};

p a[200500];
int l[100500];
int ans[100500];
int s;

bool scmp(p a, p b) {
    if (a.r < b.r)
        return true;
    else
        return false;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        a[s].l = x;
        a[s].r = y;
        a[s].i = -1;
        s++;
    }

    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int x, y, k;
        cin >> x >> y >> k;
        a[s].l = x;
        a[s].r = y;
        a[s].i = i;
        l[i] = k;
        s++;
    }

    sort(a, a + s, cmp);

    set<p, comp> c;
    int v = 0;
    for (int i = 0; i < s; ++i) {
        if (a[i].i == -1) {
            set<p>::iterator it;
            it = lower_bound(c.begin(), c.end(), a[i], scmp);
            if (it == c.end()) {
                cout <<"NO" << endl;
                return 0;
            }
            ans[v] = it->i;
            v++;
            l[it->i]--;
            if (l[it->i] <= 0)
                c.erase(it);
        }
        else {
            c.insert(a[i]);
        }
    }

    cout << "YES" << endl;

    for (int i = 0; i < n; ++i) {
        cout << ans[i] + 1 << " ";
    }
    cout << endl;

    return 0;

}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
#include <climits>

using namespace std;

#define F first
#define S second

const int INF = 1000000000;

pair<pair<int, int>, pair<bool, int> > t[200500];
int k[100500], ans[100500];

bool comp(pair<pair<int, int>, pair<bool, int> > a, pair<pair<int, int>, pair<bool, int> > b) {
    if (a.F.F < b.F.F || (a.F.F == b.F.F && a.S.F && !b.S.F))
        return true;
    else
        return false;
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        cin >> t[i].F.F >> t[i].F.S;
        t[i].S.F = 0;
        t[i].S.S = i;
    }

    int m;
    cin >> m;

    for (int i = n; i < n + m; ++i) {
        int l;
        cin >> t[i].F.F >> t[i].F.S >> l;
        t[i].S.F = 1;
        t[i].S.S = i - n;
        k[i - n] = l;
    }

    sort(t, t + n + m, comp);

    set<pair<int, int> > r;

    for (int i = 0; i < n + m; ++i) {
        if (!t[i].S.F) {
            set<pair<int, int> >::iterator it = lower_bound(r.begin(), r.end(), make_pair(t[i].F.S, -1));
            if (it == r.end()) {
                cout << "NO" << endl;
                return 0;
            }
            k[it->S]--;
            ans[t[i].S.S] = it->S;
            if (k[it->S] <= 0) {
                r.erase(it);
            }
        }
        else {
            r.insert(make_pair(t[i].F.S, t[i].S.S));
        }

    }

    cout << "YES" << endl;

    for (int i = 0; i < n; ++i)
        cout << ans[i] + 1 << " ";
    cout << endl;

    return 0;

}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
using namespace std;
#define fileopen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define FOR(i,l,r) for(i=l;i<=r;i++)
#define FORD(i,l,r) for(i=l;i>=r;i--)
#define xy pair<int,int>
#define pb push_back
#define int64 long long
#define X first
#define Y second

const int OO = 2e9;
const int MOD = 1e9+7;
const int N = 1e5+5;
struct st{
    int x,p;
    bool operator <(st &y) {return x<y.x;}
};
struct music{
    int l,r,p;
    bool operator <(music &y) {return l<y.l;}
};
bool cmpA(st x,st y) {return x<y;}
bool cmpM(music x,music y) {return x<y;}

// GLOBAL VAR
int BIT[N],k[N],res[N],n,nm,pR[N];
bool exist[N];
st L[N],R[N];
music M[N];
// GLOBAL VAR

void uBIT(int i,int v) {
    while (i<=nm) {
        BIT[i]+=v;
        i+=i&-i;
    }
}

int fBIT(int i) {
    int res=0;
    while (i>0) {
        res+=BIT[i];
        i-=i&-i;
    }
    return res;
}

int BS(int v) {
    int l=1,r=nm,m,fL=fBIT(l-1),fM,res=0;
    while (l<=r) {
        m=(l+r)>>1;
        fM=fBIT(m);
        if ((R[m].x>=v)&&(exist[m])) res=m,r=m-1; else
        if ((R[m].x<v)||(fM-fL==0)) l=m+1; else r=m-1;
    }
    return res;
}

int main() {
    int i,pos=1,f;
    scanf("%i",&n);
    FOR(i,1,n) scanf("%i%i",&M[i].l,&M[i].r),M[i].p=i;
    scanf("%i",&nm);
    FOR(i,1,nm) scanf("%i%i%i",&L[i].x,&R[i].x,&k[i]),L[i].p=i,R[i].p=i;
    sort(M+1,M+n+1,cmpM);
    sort(L+1,L+nm+1,cmpA);
    sort(R+1,R+nm+1,cmpA);
    FOR(i,1,nm) pR[R[i].p]=i;
    memset(BIT,0,sizeof(BIT));
    memset(exist,false,sizeof(exist));
    FOR(i,1,n) {
        while ((pos<=nm)&&(L[pos].x<=M[i].l)) {
            uBIT(pR[L[pos].p],1);
            exist[pR[L[pos].p]]=true;
            pos++;
        }
        f=BS(M[i].r);
        if (f==0) {cout<<"NO";return 0;}
        res[M[i].p]=R[f].p;
        k[R[f].p]--;
        if (k[R[f].p]==0) uBIT(f,-1),exist[f]=false;
    }
    cout<<"YES"<<endl;
    FOR(i,1,n) printf("%i ",res[i]);
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
using namespace std;
#define fileopen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define FOR(i,l,r) for(i=l;i<=r;i++)
#define FORD(i,l,r) for(i=l;i>=r;i--)
#define xy pair<int,int>
#define pb push_back
#define int64 long long
#define X first
#define Y second

const int OO = 2e9;
const int MOD = 1e9+7;
const int N = 1e5+5;
struct st{
    int x,p;
    bool operator <(st &y) {return x<y.x;}
};
struct music{
    int l,r,p;
    bool operator <(music &y) {return l<y.l;}
};
bool cmpA(st x,st y) {return x<y;}
bool cmpM(music x,music y) {return x<y;}

// GLOBAL VAR
int BIT[N],k[N],res[N],n,nm,pR[N];
bool exist[N];
st L[N],R[N];
music M[N];
// GLOBAL VAR

void uBIT(int i,int v) {
    while (i<=nm) {
        BIT[i]+=v;
        i+=i&-i;
    }
}

int fBIT(int i) {
    int res=0;
    while (i>0) {
        res+=BIT[i];
        i-=i&-i;
    }
    return res;
}

int BS1(int v) {
    int l=1,r=nm,m,res=nm+1;
    while (l<=r) {
        m=(l+r)/2;
        if (R[m].x>=v) res=m,r=m-1; else l=m+1;
    }
    return res;
}

int BS2(int v) {
    int l=v,r=nm,m,fL,fM,res=0;
    while (l<=r) {
        m=(l+r)/2;
        fL=fBIT(l-1);
        fM=fBIT(m);
        if (exist[m]) res=m,r=m-1; else
        if (fM-fL==0) l=m+1; else r=m-1;
    }
    return res;
}

int main() {
    int i,pos=1,f;
    scanf("%i",&n);
    FOR(i,1,n) scanf("%i%i",&M[i].l,&M[i].r),M[i].p=i;
    scanf("%i",&nm);
    FOR(i,1,nm) scanf("%i%i%i",&L[i].x,&R[i].x,&k[i]),L[i].p=i,R[i].p=i;
    sort(M+1,M+n+1,cmpM);
    sort(L+1,L+nm+1,cmpA);
    sort(R+1,R+nm+1,cmpA);
    FOR(i,1,nm) pR[R[i].p]=i;
    memset(BIT,0,sizeof(BIT));
    memset(exist,false,sizeof(exist));
    FOR(i,1,n) {
        while ((pos<=nm)&&(L[pos].x<=M[i].l)) {
            uBIT(pR[L[pos].p],1);
            exist[pR[L[pos].p]]=true;
            pos++;
        }
        f=BS2(BS1(M[i].r));
        if (f==0) {cout<<"NO";return 0;}
        res[M[i].p]=R[f].p;
        k[R[f].p]--;
        if (k[R[f].p]==0) uBIT(f,-1),exist[f]=false;
    }
    cout<<"YES"<<endl;
    FOR(i,1,n) printf("%i ",res[i]);
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
using namespace std;
#define fileopen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define FOR(i,l,r) for(i=l;i<=r;i++)
#define FORD(i,l,r) for(i=l;i>=r;i--)
#define xy pair<int,int>
#define pb push_back
#define int64 long long
#define X first
#define Y second

const int OO = 2e9;
const int MOD = 1e9+7;
const int N = 1e5+5;
struct st{
    int x,p;
    bool operator <(st &y) {return x<y.x;}
};
struct music{
    int l,r,p;
    bool operator <(music &y) {return l<y.l;}
};
bool cmpA(st x,st y) {return x<y;}
bool cmpM(music x,music y) {return x<y;}

// GLOBAL VAR
int BIT[N],k[N],res[N],n,nm,pR[N];
bool exist[N];
st L[N],R[N];
music M[N];
// GLOBAL VAR

void uBIT(int i,int v) {
    while (i<=nm) {
        BIT[i]+=v;
        i+=i&-i;
    }
}

int fBIT(int i) {
    int res=0;
    while (i>0) {
        res+=BIT[i];
        i-=i&-i;
    }
    return res;
}

int BS1(int v) {
    int l=1,r=nm,m,res=0;
    while (l<=r) {
        m=(l+r)/2;
        if (R[m].x>=v) res=m,r=m-1; else l=m+1;
    }
    return res;
}

int BS2(int v) {
    int l=v,r=nm,m,fL,fM,res=0;
    while (l<=r) {
        m=(l+r)/2;
        fL=fBIT(l-1);
        fM=fBIT(m);
        if (exist[m]) res=m,r=m-1; else
        if (fM-fL==0) l=m+1; else r=m-1;
    }
    return res;
}

int main() {
    int i,pos=1,f;
    scanf("%i",&n);
    FOR(i,1,n) scanf("%i%i",&M[i].l,&M[i].r),M[i].p=i;
    scanf("%i",&nm);
    FOR(i,1,nm) scanf("%i%i%i",&L[i].x,&R[i].x,&k[i]),L[i].p=i,R[i].p=i;
    sort(M+1,M+n+1,cmpM);
    sort(L+1,L+nm+1,cmpA);
    sort(R+1,R+nm+1,cmpA);
    FOR(i,1,nm) pR[R[i].p]=i;
    memset(BIT,0,sizeof(BIT));
    memset(exist,false,sizeof(exist));
    FOR(i,1,n) {
        while ((pos<=nm)&&(L[pos].x<=M[i].l)) {
            uBIT(pR[L[pos].p],1);
            exist[pR[L[pos].p]]=true;
            pos++;
        }
        f=BS2(BS1(M[i].r));
        if (f==0) {cout<<"NO";return 0;}
        res[M[i].p]=R[f].p;
        k[R[f].p]--;
        if (k[R[f].p]==0) uBIT(f,-1),exist[f]=false;
    }
    cout<<"YES"<<endl;
    FOR(i,1,n) printf("%i ",res[i]);
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
using namespace std;
#define fileopen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define FOR(i,l,r) for(i=l;i<=r;i++)
#define FORD(i,l,r) for(i=l;i>=r;i--)
#define xy pair<int,int>
#define pb push_back
#define int64 long long
#define X first
#define Y second

const int OO = 2e9;
const int MOD = 1e9+7;
const int N = 1e5+5;
struct st{
    int x,p;
    bool operator <(st &y) {return x<y.x;}
};
struct music{
    int l,r,p;
    bool operator <(music &y) {return l<y.l;}
};
bool cmpA(st x,st y) {return x<y;}
bool cmpM(music x,music y) {return x<y;}

// GLOBAL VAR
int BIT[N],k[N],res[N],n,nm;
bool exist[N];
st L[N],R[N];
music M[N];
// GLOBAL VAR

void uBIT(int i,int v) {
    while (i<=nm) {
        BIT[i]+=v;
        i+=i&-i;
    }
}

int fBIT(int i) {
    int res=0;
    while (i>0) {
        res+=BIT[i];
        i-=i&-i;
    }
    return res;
}

int BS(int v) {
    int l=1,r=nm,m,fL=fBIT(l-1),fM,res=0;
    while (l<=r) {
        m=(l+r)>>1;
        fM=fBIT(m);
        if ((R[m].x>=v)&&(exist[m])) res=m,r=m-1; else
        if ((R[m].x<v)||(fM-fL==0)) l=m+1; else r=m-1;
    }
    return res;
}

int main() {
    int i,pos=1,f;
    scanf("%i",&n);
    FOR(i,1,n) scanf("%i%i",&M[i].l,&M[i].r),M[i].p=i;
    scanf("%i",&nm);
    FOR(i,1,nm) scanf("%i%i%i",&L[i].x,&R[i].x,&k[i]),L[i].p=i,R[i].p=i;
    sort(M+1,M+n+1,cmpM);
    sort(L+1,L+nm+1,cmpA);
    sort(R+1,R+nm+1,cmpA);
    memset(BIT,0,sizeof(BIT));
    memset(exist,false,sizeof(exist));
    FOR(i,1,n) {
        while ((pos<=nm)&&(L[pos].x<=M[i].l)) {
            uBIT(L[pos].p,1);
            exist[L[pos].p]=true;
            pos++;
        }
        f=BS(M[i].r);
        if (f==0) {cout<<"NO";return 0;}
        res[M[i].p]=R[f].p;
        k[R[f].p]--;
        if (k[R[f].p]==0) uBIT(f,-1),exist[f]=false;
    }
    cout<<"YES"<<endl;
    FOR(i,1,n) printf("%i ",res[i]);
}


#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
using namespace std;
#define fileopen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define FOR(i,l,r) for(i=l;i<=r;i++)
#define FORD(i,l,r) for(i=l;i>=r;i--)
#define xy pair<int,int>
#define pb push_back
#define int64 long long
#define X first
#define Y second

const int OO = 2e9;
const int MOD = 1e9+7;
const int N = 1e5+5;
struct st{
    int x,p;
    bool operator <(st &y) {return x<y.x;}
};
struct music{
    int l,r,p;
    bool operator <(music &y) {return l<y.l;}
};
bool cmpA(st x,st y) {return x<y;}
bool cmpM(music x,music y) {return x<y;}

// GLOBAL VAR
int BIT[N],k[N],res[N],n,nm,pR[N];
bool exist[N];
st L[N],R[N];
music M[N];
// GLOBAL VAR

void uBIT(int i,int v) {
    while (i<=nm) {
        BIT[i]+=v;
        i+=i&-i;
    }
}

int fBIT(int i) {
    int res=0;
    while (i>0) {
        res+=BIT[i];
        i-=i&-i;
    }
    return res;
}

int BS(int v) {
    int l=1,r=nm,m,fL,fM,res=0;
    while (l<=r) {
        m=(l+r)>>1;
        fL=fBIT(l-1);
        fM=fBIT(m);
        if ((R[m].x>=v)&&(exist[m])) res=m,r=m-1; else
        if ((R[m].x<v)||(fM-fL==0)) l=m+1; else r=m-1;
    }
    return res;
}

int main() {
    int i,pos=1,f;
    scanf("%i",&n);
    FOR(i,1,n) scanf("%i%i",&M[i].l,&M[i].r),M[i].p=i;
    scanf("%i",&nm);
    FOR(i,1,nm) scanf("%i%i%i",&L[i].x,&R[i].x,&k[i]),L[i].p=i,R[i].p=i;
    sort(M+1,M+n+1,cmpM);
    sort(L+1,L+nm+1,cmpA);
    sort(R+1,R+nm+1,cmpA);
    FOR(i,1,nm) pR[R[i].p]=i;
    memset(BIT,0,sizeof(BIT));
    memset(exist,false,sizeof(exist));
    FOR(i,1,n) {
        while ((pos<=nm)&&(L[pos].x<=M[i].l)) {
            uBIT(pR[L[pos].p],1);
            exist[pR[L[pos].p]]=true;
            pos++;
        }
        f=BS(M[i].r);
        if (f==0) {cout<<"NO";return 0;}
        res[M[i].p]=R[f].p;
        k[R[f].p]--;
        if (k[R[f].p]==0) uBIT(f,-1),exist[f]=false;
    }
    cout<<"YES"<<endl;
    FOR(i,1,n) printf("%i ",res[i]);
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<iostream>
#include<set>
#include<bits/stdc++.h>

using namespace std;
typedef unsigned long long ull;
const int INF=0x3f3f3f3f;
const int maxn=200005;

struct Event{
        int l,r,k,id;
        Event(int a=0,int b=0,int c=0,int d=0) {
                l=a,r=b,k=c,id=d;
        }
        bool operator < (const Event &t) const{
                if(r!=t.r) return r<t.r;
                else return k<t.k;
        }
}events[maxn];
int n,m;
int ans[maxn];
int work() {
        sort(events,events+n+m);
        set< pair<int,int> > set;
        std::set< std::pair<int,int> >::iterator it;
        for(int i=0;i<n+m;i++) {
                Event &e=events[i];
                if(e.k==0) {
                        set.insert(make_pair(e.l,e.id));
                        continue;
                }
                it=set.lower_bound(make_pair(e.l,-1));
                while(it!=set.end() && e.k!=0) {
                        e.k--;
                        ans[it->second]=e.id;
                        set.erase(it++);
                }
        }
        if(!set.empty()) return false;
        return true;
}
int main() {
        while(scanf("%d",&n)!=-1) {
                int l,r,k;
                for(int i=0;i<n;i++) {
                        scanf("%d%d",&l,&r);
                        events[i]=Event(l,r,0,i);
                }
                scanf("%d",&m);
                for(int i=0;i<m;i++) {
                        scanf("%d%d%d",&l,&r,&k);
                        events[i+n]=Event(l,r,k,i);
                }
                if(!work()) puts("NO");
                else {
                        puts("YES");
                        for(int i=0;i<n-1;i++) printf("%d ",ans[i]+1);
                        printf("%d\n",ans[n-1]+1);
                }
        }
        return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<iostream>
#include<set>
#include<bits/stdc++.h>

using namespace std;
typedef unsigned long long ull;
const int INF=0x3f3f3f3f;
const int maxn=200005;

struct Event{
        int l,r,k,id;
        Event(int a=0,int b=0,int c=0,int d=0) {
                l=a,r=b,k=c,id=d;
        }
        bool operator < (const Event &t) const{
                if(r!=t.r) return r<t.r;
                else return k<t.k;
        }
}events[maxn];
int n,m;
int ans[maxn];
int work() {
        sort(events,events+n+m);
        set< pair<int,int> > set;
        std::set< std::pair<int,int> >::iterator it;
        for(int i=0;i<n+m;i++) {
                Event &e=events[i];
                if(e.k==0) {
                        set.insert(make_pair(e.l,e.id));
                        continue;
                }
                it=set.lower_bound(make_pair(e.l,-1));
                while(it!=set.end() && e.k!=0) {
                        e.k--;
                        ans[it->second]=e.id;
                        set.erase(it++);
                }
        }
        if(!set.empty()) return false;
        return true;
}
int main() {
        while(scanf("%d",&n)!=-1) {
                int l,r,k;
                for(int i=0;i<n;i++) {
                        scanf("%d%d",&l,&r);
                        events[i]=Event(l,r,0,i);
                }
                scanf("%d",&m);
                for(int i=0;i<m;i++) {
                        scanf("%d%d%d",&l,&r,&k);
                        events[i+n]=Event(l,r,k,i);
                }
                if(!work()) puts("No");
                else {
                        puts("Yes");
                        for(int i=0;i<n-1;i++) printf("%d ",ans[i]+1);
                        printf("%d\n",ans[n-1]+1);
                }
        }
        return 0;
}


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<stack>
#include<queue>
#include<vector>
#include<iostream>
#include<set>
#include<bits/stdc++.h>

using namespace std;
typedef unsigned long long ull;
const int INF=0x3f3f3f3f;
const int maxn=200005;

struct Event{
        int l,r,k,id;
        Event(int a=0,int b=0,int c=0,int d=0) {
                l=a,r=b,k=c,id=d;
        }
        bool operator < (const Event &t) const{
                if(r!=t.r) return r<t.r;
                else return k<t.k;
        }
}events[maxn];
int n,m;
int ans[maxn];
int work() {
        sort(events,events+n+m);
        set< pair<int,int> > set;
        std::set< std::pair<int,int> >::iterator it;
        for(int i=0;i<n+m;i++) {
                Event &e=events[i];
                if(e.k==0) {
                        set.insert(make_pair(e.l,e.id));
                        continue;
                }
                it=set.lower_bound(make_pair(e.l,-1));
                while(it!=set.end() && e.k!=0) {
                        e.k--;
                        ans[it->second]=e.id;
                        set.erase(it++);
                }
        }
        if(!set.empty()) return false;
        return true;
}
int main() {
        while(scanf("%d",&n)!=-1) {
                int l,r,k;
                for(int i=0;i<n;i++) {
                        scanf("%d%d",&l,&r);
                        events[i]=Event(l,r,0,i);
                }
                scanf("%d",&m);
                for(int i=0;i<m;i++) {
                        scanf("%d%d%d",&l,&r,&k);
                        events[i+n]=Event(l,r,k,i);
                }
                if(!work()) printf("NO\n");
                else {
                        puts("YES");
                        for(int i=0;i<n-1;i++) printf("%d ",ans[i]+1);
                        printf("%d\n",ans[n-1]+1);
                }
        }
        return 0;
}