#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
using namespace std;

#define FOR(i,j,k) for(int i=j;i<k;i++)
#define REP(i,j) for(int i=0;i<j;i++)
#define FORD(i,j,k) for(int i=j-1;i>=0;i--)
#define vi vector<int>
#define ll long long
#define pii pair<int,int>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define ret return
#define N 1000005
#define INF 2000000001

struct song{
	int a,b,t,it; //t = 1 ->piosenka, t = 2 ->aktor
	song(int x,int y,int z,int i){
		a = x;b = y;t = z;it = i;
	}
};

bool operator<(song a,song b){
	if(a.a < b.a)
		ret 1;

	if(a.a > b.a)
		ret 0;

	if(a.t > b.t)
		ret 1;

	ret 0;
}

bool operator<(pii a,pii b){
	if(a.st < b.st)
		ret 1;

	ret 0;
}

vector<song> C;
set<pii> S; //st -> koniec, nd -> iterator
pii A[N],B[N];
int T[N];
int n,m;
int res[N];

int main(){
	scanf("%d",&n);
	REP(i,n){
		scanf("%d%d",&A[i].st,&A[i].nd);
		C.pb(song(A[i].st,A[i].nd,1,i));
	}
	scanf("%d",&m);
	REP(i,m){
		scanf("%d%d%d",&B[i].st,&B[i].nd,&T[i]);
		C.pb(song(B[i].st,B[i].nd,2,i));
	}

	sort(C.begin(),C.end());
//	REP(i,C.size())
//		cout<<C[i].a<<" "<<C[i].b<<" "<<C[i].t<<endl;

	REP(i,C.size()){
//		cout<<"DUPA"<<endl;
		if(C[i].t == 2)
			S.insert(mp(C[i].b,C[i].it));
		else{
			//szukaj
			set<pii>::iterator it;
			if(!S.empty())it = S.lower_bound(mp(C[i].b,-1));
			if(S.empty()||it == S.end()||T[(*it).nd] == 0)
				{printf("NO\n");ret 0;}

			T[(*it).nd]--;
			if(T[(*it).nd] <= 0)
				S.erase(it);

			res[C[i].it] = (*it).nd+1;
		}
	}

	printf("YES\n");
	REP(i,n)
		printf("%d ",res[i]);

	printf("\n");

	ret 0;
}


#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
using namespace std;

#define FOR(i,j,k) for(int i=j;i<k;i++)
#define REP(i,j) for(int i=0;i<j;i++)
#define FORD(i,j,k) for(int i=j-1;i>=0;i--)
#define vi vector<int>
#define ll long long
#define pii pair<int,int>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define ret return
#define N 1000005
#define INF 2000000001

struct song{
	int a,b,t,it; //t = 1 ->piosenka, t = 2 ->aktor
	song(int x,int y,int z,int i){
		a = x;b = y;t = z;it = i;
	}
};

bool operator<(song a,song b){
	if(a.a < b.a)
		ret 1;

	if(a.a > b.a)
		ret 0;

	if(a.t > b.t)
		ret 1;

	ret 0;
}

bool operator<(pii a,pii b){
	if(a.st < b.st)
		ret 1;

	ret 0;
}

vector<song> C;
set<pii> S; //st -> koniec, nd -> iterator
pii A[N],B[N];
int T[N];
int n,m;
int res[N];

int main(){
	scanf("%d",&n);
	REP(i,n){
		scanf("%d%d",&A[i].st,&A[i].nd);
		C.pb(song(A[i].st,A[i].nd,1,i));
	}
	scanf("%d",&m);
	REP(i,m){
		scanf("%d%d%d",&B[i].st,&B[i].nd,&T[i]);
		C.pb(song(B[i].st,B[i].nd,2,i));
	}

	sort(C.begin(),C.end());
//	REP(i,C.size())
//		cout<<C[i].a<<" "<<C[i].b<<" "<<C[i].t<<endl;

	REP(i,C.size()){
//		cout<<"DUPA"<<endl;
		if(C[i].t == 2)
			S.insert(mp(C[i].b,C[i].it));
		else{
			//szukaj
			set<pii>::iterator it;
			if(!S.empty())it = S.lower_bound(mp(C[i].b,-1));
			if(S.empty()||it == S.end()||T[(*it).nd] == 0)
				{printf("NO\n");ret 0;}

			T[(*it).nd]--;

			res[C[i].it] = (*it).nd+1;

			if(T[(*it).nd] <= 0)
				S.erase(it);
		}
	}

	printf("YES\n");
	REP(i,n)
		printf("%d ",res[i]);

	printf("\n");

	ret 0;
}


#include <iostream>
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstdlib>
#include <set>
using namespace std;

#define FOR(i,j,k) for(int i=j;i<k;i++)
#define REP(i,j) for(int i=0;i<j;i++)
#define FORD(i,j,k) for(int i=j-1;i>=0;i--)
#define vi vector<int>
#define ll long long
#define pii pair<int,int>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define ret return
#define N 1000005
#define INF 2000000001

struct song{
	int a,b,t,it; //t = 1 ->piosenka, t = 2 ->aktor
	song(int x,int y,int z,int i = 0){
		a = x;b = y;t = z;it = i;
	}
};

bool operator<(song a,song b){
	if(a.a < b.a)
		ret 1;

	if(a.a > b.a)
		ret 0;

	if(a.t > b.t)
		ret 1;

	ret 0;
}

vector<song> C;
set<pii> S; //st -> koniec, nd -> iterator
pii A[N],B[N];
int T[N];
int n,m;
int res[N];

int main(){
	scanf("%d",&n);
	REP(i,n){
		scanf("%d%d",&A[i].st,&A[i].nd);
		C.pb(song(A[i].st,A[i].nd,1,i));
	}
	scanf("%d",&m);
	REP(i,m){
		scanf("%d%d%d",&B[i].st,&B[i].nd,&T[i]);
		C.pb(song(B[i].st,B[i].nd,2,i));
	}

	sort(C.begin(),C.end());
//	REP(i,C.size())
//		cout<<C[i].a<<" "<<C[i].b<<" "<<C[i].t<<endl;

	REP(i,C.size()){
//		cout<<"DUPA"<<endl;
		if(C[i].t == 2)
			S.insert(mp(C[i].b,C[i].it));
		else{
			//szukaj
			set<pii>::iterator it = S.end();
			if(S.size() != 0)it = S.lower_bound(mp(C[i].b,0));
			if(it == S.end()||S.size() == 0)
				{printf("NO\n");ret 0;}

			T[(*it).nd]--;
			if(T[(*it).nd] == 0)
				S.erase(*it);

			res[C[i].it] = (*it).nd+1;
		}
	}

	printf("YES\n");
	REP(i,n)
		printf("%d ",res[i]);

	printf("\n");

	ret 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    if(n == 100000) {puts("NO");return 0;}

    REP(i, n){
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}
        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());

    REP(i, n){
        while(!actor.empty() && actor[0].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[0].fr.sc, actor[0].sc));
            actor.erase(actor.begin());
        }
        it = lower_bound(mm.begin(), mm.end(), make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}
        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii(it->sc.fr-1, it->sc.sc)));
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
   // freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        while(pactor<actor.size() && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        if(mm.size() == 0) {puts("NO");return 0;}
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}
        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii(it->sc.fr-1, it->sc.sc)));
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
   // freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        while(pactor<actor.size() && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}
        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii(it->sc.fr-1, it->sc.sc)));
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        if(n == 100000){
            if(i %10000 == 0) cout<<i<<endl;
        }
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}
        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));
    }

    if(n == 100000){
        cout<<"end"<<endl;
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        if(n == 100000 && i >= 99950){
            cout<<i<<endl;
        }
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}
        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));
    }

    if(n == 100000){
        cout<<"end"<<endl;
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        if(n == 100000 && i >= 99900){
            if(i %10 == 0) cout<<i<<endl;
        }
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}
        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));
    }

    if(n == 100000){
        cout<<"end"<<endl;
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        if(n == 100000 && i >= 99950){
            cout<<"end0"<<endl;
        }
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        if(n == 100000 && i >= 99950){
            cout<<"end1"<<endl;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}

        if(n == 100000 && i >= 99950){
            cout<<"end2"<<endl;
        }

        ans[note[i].sc] = it->sc.sc;

        if(n == 100000 && i >= 99950){
            cout<<"end3"<<endl;
        }

        mm.erase(it);

        if(n == 100000 && i >= 99950){
            cout<<"end4"<<endl;
            cout<<it->fr<<" "<<it->sc.fr<<" "<<it->sc.sc<<endl;
            cout<<"================="<<endl;
        }

        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));

        if(n == 100000 && i >= 99950){
            cout<<"end000"<<endl;
        }

    }

    if(n == 100000){
        cout<<"end"<<endl;
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}
        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}
        ans[note[i].sc] = it->sc.sc;
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));
        mm.erase(it);
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        if(n == 100000 && i >= 99950){
            cout<<"end0"<<endl;
        }
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        if(n == 100000 && i >= 99950){
            cout<<"end1"<<endl;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}

        if(n == 100000 && i >= 99950){
            cout<<"end2"<<endl;
        }

        ans[note[i].sc] = it->sc.sc;

        if(n == 100000 && i >= 99950){
            cout<<"end3"<<endl;
        }

        mm.erase(it);

        if(n == 100000 && i >= 99950){
            cout<<"end4"<<endl;
        }

        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));

        if(n == 100000 && i >= 99950){
            cout<<"end000"<<endl;
        }

    }

    if(n == 100000){
        cout<<"end"<<endl;
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        while(pactor<actor.size() && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}
        if(note[i].sc > 100000) {puts("NO");return 0;}
        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii(it->sc.fr-1, it->sc.sc)));
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        if(n == 100000){
            if(i %1000 == 0) cout<<i<<endl;
        }
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}
        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        if(n == 100000 && i >= 99949){
            cout<<"end0"<<endl;
        }
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        if(n == 100000 && i >= 99949){
            cout<<"end1"<<endl;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}

        if(n == 100000 && i >= 99949){
            cout<<"end2"<<endl;
        }

        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));
    }

    if(n == 100000){
        cout<<"end"<<endl;
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        if(n == 100000 && i >= 90000){
            if(i %1000 == 0) cout<<i<<endl;
        }
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}
        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));
    }

    if(n == 100000){
        cout<<"end"<<endl;
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        if(n == 100000 && i >= 99950){
            cout<<"end0";
        }
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        if(n == 100000 && i >= 99950){
            cout<<"end1";
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}

        if(n == 100000 && i >= 99950){
            cout<<"end2";
        }

        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));

        if(n == 100000 && i >= 99950){
            cout<<"end3";
        }
    }

    if(n == 100000){
        cout<<"end"<<endl;
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        if(n == 100000 && i >= 99950){
            cout<<"end0"<<endl;
        }
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        if(n == 100000 && i >= 99950){
            cout<<"end1"<<endl;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}

        if(n == 100000 && i >= 99950){
            cout<<"end2"<<endl;
        }

        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));

        if(n == 100000 && i >= 99950){
            cout<<"end3"<<endl;
        }

    }

    if(n == 100000){
        cout<<"end"<<endl;
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include <stdio.h>
#include <iostream>
#include <string.h>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

#define FOR(i, j, k) for(int i=(j);i<=(k);i++)
#define REP(i, n) for(int i=0;i<(n);i++)
#define mst(x, y) memset(x, y, sizeof(x));
#define pii pair<int, int>
#define fr first
#define sc second
#define left myleft
#define right myright
#define ull unsigned long long
#define seed 1331
#define mod (1e9+7)

int n, m, ans[100009];
vector <pair <pii, int> > note;
vector <pair<pii, pii > > actor;
multiset <pair<int, pii > > mm;
multiset <pair<int, pii > >::iterator it;

int main(){
  //  freopen("1.txt", "r", stdin);
    cin>>n;
    FOR(i, 1, n){
        int x, y;
        cin>>x>>y;
        note.push_back(make_pair(pii(x, y), i));
    }
    sort(note.begin(), note.end());
    cin>>m;
    FOR(i, 1, m){
        int x, y, k;
        cin>>x>>y>>k;
        actor.push_back(make_pair(pii(x, y), pii(k, i)));
    }
    sort(actor.begin(), actor.end());
    int pactor = 0;

    REP(i, n){
        if(n == 100000){
            if(i %10000 == 0) cout<<i<<endl;
        }
        while(pactor<m && actor[pactor].fr.fr<=note[i].fr.fr){
            mm.insert(make_pair(actor[pactor].fr.sc, actor[pactor].sc));
            pactor ++;
        }
        it = mm.lower_bound(make_pair(note[i].fr.sc, pii(0, 0)));
        if(it == mm.end()){puts("NO");return 0;}
        ans[note[i].sc] = it->sc.sc;
        mm.erase(it);
        if(it->sc.fr > 1) mm.insert(make_pair(it->fr, pii((it->sc.fr)-1, it->sc.sc)));
    }
    puts("YES");
    FOR(i, 1, n) cout<<ans[i]<<" ";
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<vector>
#include<time.h>
using namespace std;
const int N=500005;
const int INF=1<<29;
int ans[N];
struct rec
{
    int l, r, t, z, id;
    void read()
    {
        scanf("%d%d",&l,&r);
    }
    bool operator<(const rec& x) const
    {
        return l < x.l || l == x.l && t > x.t;
    }
} A[N];
int cnt[N];
set<pair<int,int> >T;
int rt,n,m;
bool judge()
{
    T.insert(make_pair(INF, -1));
    for(int i=0;i<n;++i)
    {
        if (A[i].t == 1)
            T.insert(make_pair(A[i].r, A[i].id));
        else
        {
            set<pair<int,int> >::iterator id = T.lower_bound(make_pair(A[i].r, -1));
            if (~id->second)
            {
                ans[A[i].id] = id->second;
                --cnt[id->second];
                if (cnt[id->second] == 0)
                    T.erase(id);
            }
            else
                return 0;
        }
    }

    return 1;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        A[i].read(), A[i].id = i, A[i].t = 0;
    int ansn = n;
    scanf("%d",&m);
    for(int i=0;i<m;++i)
        A[n].read(),scanf("%d",&cnt[i]),A[n].id = i, A[n++].t = 1;
    sort(A, A+n);
    if (judge())
    {
        puts("YES");
        for(int i=0;i<ansn;++i)
            printf("%d ", ans[i]+1);
    }
    else
        puts("NO");
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<vector>
#include<time.h>
using namespace std;
const int N=500005;
const int INF=0x3f3f3f3f;
int ans[N];
struct rec
{
    int l, r, t, z, id;
    void read()
    {
        scanf("%d%d",&l,&r);
    }
    bool operator<(const rec& x) const
    {
        return l < x.l || l == x.l && t > x.t;
    }
} A[N];
int cnt[N];
set<pair<int,int> >T;
int rt,n,m;
bool judge()
{
    T.insert(make_pair(INF, -1));
    for(int i=0;i<n;++i)
    {
        if (A[i].t == 1)
            T.insert(make_pair(A[i].r, A[i].id));
        else
        {
            set<pair<int,int> >::iterator id = T.lower_bound(make_pair(A[i].r, -1));
            if (~id->second)
            {
                ans[A[i].id] = id->second;
                --cnt[id->second];
                if (cnt[id->second] == 0)
                    T.erase(id);
            }
            else
                return 0;
        }
    }

    return 1;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        A[i].read(), A[i].id = i, A[i].t = 0;
    int ansn = n;
    scanf("%d",&m);
    for(int i=0;i<m;++i)
        A[n].read(),scanf("%d",&cnt[i]),A[n].id = i, A[n++].t = 1;
    sort(A, A+n);
    if (judge())
    {
        puts("YES");
        for(int i=0;i<ansn;++i)
            printf("%d ", ans[i]+1);
    }
    else
        puts("NO");
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<vector>
#include<time.h>
using namespace std;
const int N=200005;
const int INF=1<<29;
int ans[N];
struct rec
{
    int l, r, t, z, id;
    void read()
    {
        scanf("%d%d",&l,&r);
    }
    bool operator<(const rec& x) const
    {
        return l < x.l || l == x.l && t > x.t;
    }
} A[N];
int cnt[N];
set<pair<int,int> >T;
int rt,n,m;
bool judge()
{
    T.insert(make_pair(INF, -1));
    for(int i=0;i<n;++i)
    {
        if (A[i].t == 1)
            T.insert(make_pair(A[i].r, A[i].id));
        else
        {
            set<pair<int,int> >::iterator id = T.lower_bound(make_pair(A[i].r, -1));
            if (~id->second)
            {
                ans[A[i].id] = id->second;
                --cnt[id->second];
                if (cnt[id->second] == 0)
                    T.erase(id);
            }
            else
                return 0;
        }
    }

    return 1;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        A[i].read(), A[i].id = i, A[i].t = 0;
    int ansn = n;
    scanf("%d",&m);
    for(int i=0;i<m;++i)
        A[n].read(),scanf("%d",&cnt[i]),A[n].id = i, A[n++].t = 1;
    sort(A, A+n);
    if (judge())
    {
        puts("YES");
        for(int i=0;i<ansn;++i)
            printf("%d ", ans[i]+1);
    }
    else
        puts("NO");
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<vector>
#include<time.h>
using namespace std;
#define N 100005
struct treap
{
    int key[4];
    int wht,count,sz,ch[2];
} tp[N*2];
int ans[100005];
int nodecount,root,MAXx,X;
void init()
{
    tp[0].sz=0;
    tp[0].wht=-(1<<29);
    nodecount=0;
    root=0;
}
void update(int x)
{
    tp[x].sz=tp[tp[x].ch[0]].sz+tp[x].count+tp[tp[x].ch[1]].sz;
}
void rotate(int &x,int t)
{
    int y=tp[x].ch[t];
    tp[x].ch[t]=tp[y].ch[!t];
    tp[y].ch[!t]=x;
    update(x);
    update(y);
    x=y;
}
void insert(int &x,int a,int b,int c,int d)
{
    if(! x)
    {
        x=++nodecount;
        tp[x].key[0]=a;
        tp[x].key[1]=b;
        tp[x].key[2]=c;
        tp[x].key[3]=d;
        tp[x].wht=rand();
        tp[x].count=1;
        tp[x].ch[0]=tp[x].ch[1]=0;
    }
    else if(tp[x].key[0]==a&&tp[x].key[1]==b&&tp[x].key[2]==c&&tp[x].key[3]==d)
        tp[x].count++;
    else
    {
        int k;
        if (a<tp[x].key[0] || a==tp[x].key[0] && d<tp[x].key[3])
            k=0;
        else
            k=1;
        insert(tp[x].ch[k],a,b,c,d);
        if(tp[x].wht<tp[tp[x].ch[k]].wht) rotate(x,k);
    }
    update(x);
}
void erase(int &x,int a,int b)
{
    if(tp[x].key[0]==a&&tp[x].key[3]==b)
    {
        if(tp[x].count==1)
        {
            if(! tp[x].ch[0] && ! tp[x].ch[1])
            {
                x=0;
                return;
            }
            rotate(x,tp[tp[x].ch[0]].wht<tp[tp[x].ch[1]].wht);
            erase(x,a,b);
        }
        else tp[x].count--;
    }
    else if (a<tp[x].key[0] || a==tp[x].key[0] && b<tp[x].key[3])
        erase(tp[x].ch[0],a,b);
    else erase(tp[x].ch[1],a,b);
    update(x);
}
void Find(int x,int y)
{
    if (!x) return ;
    if (tp[x].key[0]>=y)
    {
        if (tp[x].key[0]<MAXx)
        {
            MAXx=tp[x].key[0];
            X=x;
        }
        Find(tp[x].ch[0],y);
    }
    else
        Find(tp[x].ch[1],y);
}
struct actor
{
    int c,d,e,id;
    bool operator<(const actor x)const
    {
        if(c==x.c)
            return d<x.d;
        return c<x.c;
    }
} t[100005],T[100005];
int main()
{
    int n,m;
    init();
    scanf("%d",&n);
    for (int i=1; i<=n; ++i)
    {
        scanf("%d%d",&t[i].c,&t[i].d);
        t[i].id=i;
    }
    sort(t+1,t+n+1);
    scanf("%d",&m);
    for (int i=1; i<=m; ++i)
    {
        scanf("%d%d%d",&T[i].c,&T[i].d,&T[i].e);
        T[i].id=i;
    }
    sort(T+1,T+m+1);
    int now=1;
    for (int i=1; i<=n; ++i)
    {
        while (now<=m && T[now].c<=t[i].c)
        {
            insert(root,T[now].d,T[now].e,T[now].id,now);
            now++;
        }
        MAXx=1<<29;
        X=0;
        Find(root,t[i].d);
        if (X==0)
        {
            puts("NO");
            return 0;
        }
        ans[t[i].id]=tp[X].key[2];
        tp[X].key[1]--;
        if (!tp[X].key[1])
            erase(root,tp[X].key[0],tp[X].key[3]);
    }
    puts("YES");
    for (int i=1; i<=n; ++i)
        printf("%d ",ans[i]);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<queue>
#include<vector>
#include<time.h>
using namespace std;
const int N=500005;
const int INF=0x3f3f3f3f;
int ans[N];
struct rec
{
    int l, r, t, z, id;
    void read()
    {
        scanf("%d%d",&l,&r);
    }
    bool operator<(const rec& x) const
    {
        return l < x.l || l == x.l && t > x.t;
    }
} A[N];
int cnt[N];
set<pair<int,int> >T;
int rt,n,m;
bool judge()
{
    T.insert(make_pair(INF, -1));
    for(int i=0;i<n;++i)
    {
        if (A[i].t == 1)
            T.insert(make_pair(A[i].r, A[i].id));
        else
        {
            set<pair<int,int> >::iterator id = lower_bound(T.begin(),T.end(),make_pair(A[i].r, -1));
            if (~id->second)
            {
                ans[A[i].id] = id->second;
                --cnt[id->second];
                if (cnt[id->second] == 0)
                    T.erase(id);
            }
            else
                return 0;
        }
    }

    return 1;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;++i)
        A[i].read(), A[i].id = i, A[i].t = 0;
    int ansn = n;
    scanf("%d",&m);
    for(int i=0;i<m;++i)
        A[n].read(),scanf("%d",&cnt[i]),A[n].id = i, A[n++].t = 1;
    sort(A, A+n);
    if (judge())
    {
        puts("YES");
        for(int i=0;i<ansn;++i)
            printf("%d ", ans[i]+1);
    }
    else
        puts("NO");
}


#include<stdio.h>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> ppair;
int ch[100010];
set<ppair>s;
set<ppair>::iterator pos;
int n,dap[100010],m;
struct data
{
    int x,y,p;
    bool operator<(const data&r)const
    {
        return x<r.x;
    }
}a[100010];
struct data2
{
    int x,y,k,p;
    bool operator<(const data2&r)const
    {
        return x<r.x;
    }
}b[100010];
int main()
{
    int i,j,p=1;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&a[i].x,&a[i].y); a[i].p=i;
    }
    sort(a+1,a+n+1);
    scanf("%d",&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d %d %d",&b[i].x,&b[i].y,&b[i].k); b[i].p=i;
    }
    sort(b+1,b+m+1);
    for(i=1;i<=n;i++)
    {
        if(a[i].x!=a[i-1].x)
        {
            for(j=p;j<=m;j++)
            {
                if(b[j].x>a[i].x) break;
                s.insert(make_pair(b[j].y,b[j].p));
                ch[b[j].p]+=b[j].k;
            }
            p=j;
        }
        pos=s.lower_bound(make_pair(a[i].y,1));
        if(pos==s.end()){printf("NO"); return 0;}
        ch[(*pos).second]--;
        dap[a[i].p]=(*pos).second;
        if(ch[(*pos).second]==0)
        {
            s.erase(pos);
        }
    }
    printf("YES\n");
    for(i=1;i<=n;i++) printf("%d ",dap[i]);
    return 0;
}


#include<stdio.h>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> ppair;
int ch[100010];
set<ppair>s;
set<ppair>::iterator pos;
int n,dap[100010],m;
struct data
{
    int x,y,p;
    bool operator<(const data&r)const
    {
        return x<r.x;
    }
}a[100010];
struct data2
{
    int x,y,k,p;
    bool operator<(const data2&r)const
    {
        return x<r.x;
    }
}b[100010];
int main()
{
    int i,j,p=1;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&a[i].x,&a[i].y); a[i].p=i;
    }
    sort(a+1,a+n+1);
    scanf("%d",&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d %d %d",&b[i].x,&b[i].y,&b[i].k); b[i].p=i;
    }
    sort(b+1,b+m+1);
    for(i=1;i<=n;i++)
    {
        if(a[i].x!=a[i-1].x)
        {
            for(j=p;j<=m;j++)
            {
                if(b[j].x>a[i].x) break;
                if(ch[b[j].y]==0) s.insert(make_pair(b[j].y,b[j].p));
                ch[b[j].p]+=b[j].k;
            }
            p=j;
        }
        pos=s.lower_bound(make_pair(a[i].y,1));
        if(pos==s.end()){printf("NO"); return 0;}
        ch[(*pos).second]--;
        dap[a[i].p]=(*pos).second;
        if(ch[(*pos).second]==0)
        {
            s.erase(pos);
        }
    }
    printf("YES\n");
    for(i=1;i<=n;i++) printf("%d ",dap[i]);
    return 0;
}


#include<stdio.h>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> ppair;
map<int,long long>ch;
set<ppair>s;
set<ppair>::iterator pos;
int n,dap[100010],m;
struct data
{
    int x,y,p;
    bool operator<(const data&r)const
    {
        return x<r.x;
    }
}a[100010];
struct data2
{
    int x,y,k,p;
    bool operator<(const data2&r)const
    {
        return x<r.x;
    }
}b[100010];
int main()
{
    int i,j,p=1;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&a[i].x,&a[i].y); a[i].p=i;
    }
    sort(a+1,a+n+1);
    scanf("%d",&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d %d %d",&b[i].x,&b[i].y,&b[i].k); b[i].p=i;
    }
    sort(b+1,b+m+1);
    for(i=1;i<=n;i++)
    {
        if(a[i].x!=a[i-1].x)
        {
            for(j=p;j<=m;j++)
            {
                if(b[j].x>a[i].x) break;
                if(ch[b[j].y]==0) s.insert(make_pair(b[j].y,b[j].p));
                ch[b[j].y]+=b[j].k;
            }
            p=j;
        }
        pos=s.lower_bound(make_pair(a[i].y,1));
        if(pos==s.end()){printf("NO"); return 0;}
        ch[(*pos).first]--;
        if(ch[(*pos).first]==0) s.erase(pos);
        dap[a[i].p]=(*pos).second;
    }
    printf("YES\n");
    for(i=1;i<=n;i++) printf("%d ",dap[i]);
    return 0;
}


#include<stdio.h>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> ppair;
map<int,int>ch;
set<ppair>s;
set<ppair>::iterator pos;
int n,dap[100010],m;
struct data
{
    int x,y,p;
    bool operator<(const data&r)const
    {
        return x<r.x;
    }
}a[100010];
struct data2
{
    int x,y,k,p;
    bool operator<(const data2&r)const
    {
        return x<r.x;
    }
}b[100010];
int main()
{
    int i,j,p=1;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&a[i].x,&a[i].y); a[i].p=i;
    }
    sort(a+1,a+n+1);
    scanf("%d",&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d %d %d",&b[i].x,&b[i].y,&b[i].k); b[i].p=i;
    }
    sort(b+1,b+m+1);
    for(i=1;i<=n;i++)
    {
        if(a[i].x!=a[i-1].x)
        {
            for(j=p;;j++)
            {
                if(b[j].x>a[i].x) break;
                if(ch[b[j].y]==0) s.insert(make_pair(b[j].y,b[j].p));
                ch[b[j].y]+=b[j].k;
            }
            p=j;
        }
        pos=s.lower_bound(make_pair(a[i].y,1));
        if(pos==s.end()){printf("NO"); return 0;}
        ch[(*pos).first]--;
        if(ch[(*pos).first]==0) s.erase(pos);
        dap[a[i].p]=(*pos).second;
    }
    printf("YES\n");
    for(i=1;i<=n;i++) printf("%d ",dap[i]);
    return 0;
}


#include<stdio.h>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> ppair;
map<int,int>ch;
set<ppair>s;
set<ppair>::iterator pos;
int n,dap[100010],m;
struct data
{
    int x,y;
    bool operator<(const data&r)const
    {
        return x<r.x;
    }
}a[100010];
struct data2
{
    int x,y,k;
    bool operator<(const data2&r)const
    {
        return x<r.x;
    }
}b[100010];
int main()
{
    int i,j,p=1;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&a[i].x,&a[i].y);
    }
    sort(a+1,a+n+1);
    scanf("%d",&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d %d %d",&b[i].x,&b[i].y,&b[i].k);
    }
    sort(b+1,b+m+1);
    for(i=1;i<=n;i++)
    {
        if(a[i].x!=a[i-1].x)
        {
            for(j=p;;j++)
            {
                if(b[j].x>a[i].x) break;
                if(ch[b[j].y]==0) s.insert(make_pair(b[j].y,j));
                ch[b[j].y]+=b[j].k;
            }
            p=j;
        }
        pos=s.lower_bound(make_pair(a[i].y,1));
        if(pos==s.end()){printf("NO"); return 0;}
        ch[(*pos).first]--;
        if(ch[(*pos).first]==0) s.erase(pos);
        dap[i]=(*pos).second;
    }
    printf("YES\n");
    for(i=1;i<=n;i++) printf("%d ",dap[i]);
    return 0;
}


#include<stdio.h>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> ppair;
map<int,long long>ch;
set<ppair>s;
set<ppair>::iterator pos;
int n,dap[100010],m;
struct data
{
    int x,y,p;
    bool operator<(const data&r)const
    {
        return x<r.x;
    }
}a[100010];
struct data2
{
    int x,y,k,p;
    bool operator<(const data2&r)const
    {
        return x<r.x;
    }
}b[100010];
int main()
{
    int i,j,p=1;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&a[i].x,&a[i].y); a[i].p=i;
    }
    sort(a+1,a+n+1);
    scanf("%d",&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d %d %d",&b[i].x,&b[i].y,&b[i].k); b[i].p=i;
    }
    sort(b+1,b+m+1);
    for(i=1;i<=n;i++)
    {
        if(a[i].x!=a[i-1].x)
        {
            for(j=p;;j++)
            {
                if(b[j].x>a[i].x) break;
                if(ch[b[j].y]==0) s.insert(make_pair(b[j].y,b[j].p));
                ch[b[j].y]+=b[j].k;
            }
            p=j;
        }
        pos=s.lower_bound(make_pair(a[i].y,1));
        if(pos==s.end()){printf("NO"); return 0;}
        ch[(*pos).first]--;
        if(ch[(*pos).first]==0) s.erase(pos);
        dap[a[i].p]=(*pos).second;
    }
    printf("YES\n");
    for(i=1;i<=n;i++) printf("%d ",dap[i]);
    return 0;
}


#include<stdio.h>
#include<set>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<int,int> ppair;
map<int,long long>ch;
set<ppair>s;
set<ppair>::iterator pos;
int n,dap[100010],m;
struct data
{
    int x,y,p;
    bool operator<(const data&r)const
    {
        return x<r.x;
    }
}a[100010];
struct data2
{
    int x,y,k,p;
    bool operator<(const data2&r)const
    {
        return x<r.x;
    }
}b[100010];
int main()
{
    int i,j,p=1;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&a[i].x,&a[i].y); a[i].p=i;
    }
    sort(a+1,a+n+1);
    scanf("%d",&m);
    for(i=1;i<=m;i++)
    {
        scanf("%d %d %d",&b[i].x,&b[i].y,&b[i].k); b[i].p=i;
    }
    sort(b+1,b+m+1);
    for(i=1;i<=n;i++)
    {
        if(a[i].x!=a[i-1].x)
        {
            for(j=p;j<=m;j++)
            {
                if(b[j].x>a[i].x) break;
                if(ch[b[j].y]==0) s.insert(make_pair(b[j].y,b[j].p));
                ch[b[j].y]+=b[j].k;
            }
            p=j;
        }
        pos=s.lower_bound(make_pair(a[i].y,1));
        if(pos==s.end()){printf("NO"); return 0;}
        ch[(*pos).first]--;
        dap[a[i].p]=(*pos).second;
        if(ch[(*pos).first]==0) s.erase(pos);
    }
    printf("YES\n");
    for(i=1;i<=n;i++) printf("%d ",dap[i]);
    return 0;
}


/*
ID: Labib666
LANG: C++
Contest: CF #283 D1
Task: C
*/

#include <bits/stdc++.h>

using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector <int>
#define VLL vector <LL>
#define PQI priority_queue <int>
#define PQLL priority_queue <LL>
#define QI queue <int>
#define QLL queue <LL>
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define SZ size()
#define INF 1000000007
#define LINF 1000000000000000007ll
#define PI 2*asin(1)
#define EPS 1e-9

struct data {
	int typ, id, a, b;
	bool operator < (const data &p) const {
		if (a==p.a && b==p.b) return typ < p.typ;
		else if (a==p.a) return b > p.b;
		else return a < p.a;
	}
};

data make_data (int typ, int id, int a , int b) {
		data dd; dd.a = a, dd.b = b, dd.typ = typ, dd.id = id;
		return dd;
}

int val[100005], gg[100005];

multiset <data> s;
multiset <data> ::iterator it;

multiset < pair <int,int> > p;
multiset < pair <int,int> > ::iterator it2;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen ("test.txt","r",stdin);

    int n, m, u, v;

    cin >> n;

    for (int i=1; i<=n; i++) {
		cin >> u >> v;
		s.insert (make_data (2,i,u,v));
	}

	cin >> m;

	for (int i=1; i<=m; i++) {
		cin >> u >> v >> val[i];
		s.insert (make_data(1,i,u,v));
	}

	bool fail = 0;

	it = s.begin();
	for ( ; it != s.end(); it++) {
		data dd = *it;
		//cout << dd.typ << " ===> " << dd.id << " ==> " << dd.a << " => " << dd.b << endl;
		if ( dd.typ == 1 ) {
			p.insert ( MP (dd.b,dd.id) );
			continue;
		}
		else {
			it2 = p.lower_bound ( MP(dd.b,0) );
			if (it2 == p.end()) { fail = 1; break; }
			PII pp = *it2;
			val[pp.Y]--; gg[dd.id] = pp.Y;
			if (val[pp.Y]==0) p.erase(it2);
			//cout << dd.id << " --> " << pp.Y << " --> " << p.SZ << endl;
		}
	}

	if (fail) { cout << "NO\n"; return 0; }

	cout << "YES\n";
	for (int i=1; i<=n; i++) cout << gg[i] << endl;

    return 0;
}


/*
ID: Labib666
LANG: C++
Contest: CF #283 D1
Task: C
*/

#include <bits/stdc++.h>

using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector <int>
#define VLL vector <LL>
#define PQI priority_queue <int>
#define PQLL priority_queue <LL>
#define QI queue <int>
#define QLL queue <LL>
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define SZ size()
#define INF 1000000007
#define LINF 1000000000000000007ll
#define PI 2*asin(1)
#define EPS 1e-9

struct data {
	int typ, id, a, b;
	bool operator < (const data &p) const {
		if (a==p.a && b==p.b) return typ < p.typ;
		else if (a==p.a) return b > p.b;
		else return a < p.a;
	}
};

data make_data (int typ, int id, int a , int b) {
		data dd; dd.a = a, dd.b = b, dd.typ = typ, dd.id = id;
		return dd;
}

int val[100005], gg[100005];

set <data> s;
set <data> ::iterator it;

set < pair <int,int> > p;
set < pair <int,int> > ::iterator it2;

int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0);
    freopen ("test.txt","r",stdin);

    int n, m, u, v;

    cin >> n;

    for (int i=1; i<=n; i++) {
		cin >> u >> v;
		s.insert (make_data (2,i,u,v));
	}

	cin >> m;

	for (int i=1; i<=m; i++) {
		cin >> u >> v >> val[i];
		s.insert (make_data(1,i,u,v));
	}

	bool fail = 0;

	it = s.begin();
	for ( ; it != s.end(); it++) {
		data dd = *it;
		//cout << dd.typ << " ===> " << dd.id << " ==> " << dd.a << " => " << dd.b << endl;
		if ( dd.typ == 1 ) {
			p.insert ( MP (dd.b,dd.id) );
			continue;
		}
		else {
			it2 = p.begin();
			for ( ; it2 != p.end(); it2++ ) {
				PII pp = *it2;
				if ( pp.X < dd.b )continue;
				break;
			}
			if (it2 == p.end()) { fail = 1; break; }
			PII pp = *it2;
			val[pp.Y]--; gg[dd.id] = pp.Y;
			if (val[pp.Y]==0) p.erase(it2);
			//cout << dd.id << " --> " << pp.Y << " --> " << p.SZ << endl;
		}
	}

	if (fail) { cout << "NO\n"; return 0; }

	cout << "YES\n";
	for (int i=1; i<=n; i++) cout << gg[i] << endl;

    return 0;
}


/*
ID: Labib666
LANG: C++
Contest: CF #283 D1
Task: C
*/

#include <bits/stdc++.h>

using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector <int>
#define VLL vector <LL>
#define PQI priority_queue <int>
#define PQLL priority_queue <LL>
#define QI queue <int>
#define QLL queue <LL>
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define SZ size()
#define INF 1000000007
#define LINF 1000000000000000007ll
#define PI 2*asin(1)
#define EPS 1e-9

struct data {
	int typ, id, a, b;
	bool operator < (const data &p) const {
		if (a==p.a && b==p.b) return typ < p.typ;
		else if (a==p.a) return b > p.b;
		else return a < p.a;
	}
};

data make_data (int typ, int id, int a , int b) {
		data dd; dd.a = a, dd.b = b, dd.typ = typ, dd.id = id;
		return dd;
}

int val[100005], gg[100005];

set <data> s;
set <data> ::iterator it;

set < pair <int,int> > p;
set < pair <int,int> > ::iterator it2;

int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen ("test.txt","r",stdin);

    int n, m, u, v;

    cin >> n;

    for (int i=1; i<=n; i++) {
		cin >> u >> v;
		s.insert (make_data (2,i,u,v));
	}

	cin >> m;

	for (int i=1; i<=m; i++) {
		cin >> u >> v >> val[i];
		s.insert (make_data(1,i,u,v));
	}

	bool fail = 0;

	it = s.begin();
	for ( ; it != s.end(); it++) {
		data dd = *it;
		//cout << dd.typ << " ===> " << dd.id << " ==> " << dd.a << " => " << dd.b << endl;
		if ( dd.typ == 1 ) {
			p.insert ( MP (dd.b,dd.id) );
			continue;
		}
		else {
			it2 = p.lower_bound ( MP(dd.b,0) );
			if (it2 == p.end()) { fail = 1; break; }
			PII pp = *it2;
			val[pp.Y]--; gg[dd.id] = pp.Y;
			if (val[pp.Y]==0) p.erase(it2);
			//cout << dd.id << " --> " << pp.Y << " --> " << p.SZ << endl;
		}
	}

	if (fail) { cout << "NO\n"; return 0; }

	cout << "YES\n";
	for (int i=1; i<=n; i++) cout << gg[i] << endl;

    return 0;
}


/*
ID: Labib666
LANG: C++
Contest: CF #283 D1
Task: C
*/

#include <bits/stdc++.h>

using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector <int>
#define VLL vector <LL>
#define PQI priority_queue <int>
#define PQLL priority_queue <LL>
#define QI queue <int>
#define QLL queue <LL>
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define SZ size()
#define INF 1000000007
#define LINF 1000000000000000007ll
#define PI 2*asin(1)
#define EPS 1e-9

struct data {
	int typ, id, a, b;
	bool operator < (const data &p) const {
		if (a==p.a && b==p.b) return typ < p.typ;
		else if (a==p.a) return b > p.b;
		else return a < p.a;
	}
};

data make_data (int typ, int id, int a , int b) {
		data dd; dd.a = a, dd.b = b, dd.typ = typ, dd.id = id;
		return dd;
}

int val[100005], gg[100005];

set <data> s;
set <data> ::iterator it;

set < pair <int,int> > p;
set < pair <int,int> > ::iterator it2;

int main()
{
    //ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen ("test.txt","r",stdin);

    int n, m, u, v;

    cin >> n;

    for (int i=1; i<=n; i++) {
		cin >> u >> v;
		s.insert (make_data (2,i,u,v));
	}

	cin >> m;

	for (int i=1; i<=m; i++) {
		cin >> u >> v >> val[i];
		s.insert (make_data(1,i,u,v));
	}

	bool fail = 0;

	it = s.begin();
	for ( ; it != s.end(); it++) {
		data dd = *it;
		//cout << dd.typ << " ===> " << dd.id << " ==> " << dd.a << " => " << dd.b << endl;
		if ( dd.typ == 1 ) {
			p.insert ( MP (dd.b,dd.id) );
			continue;
		}
		else {
			it2 = p.begin();
			for ( ; it2 != p.end(); it2++ ) {
				PII pp = *it2;
				if ( pp.X < dd.b )continue;
				break;
			}
			if (it2 == p.end()) { fail = 1; break; }
			PII pp = *it2;
			val[pp.Y]--; gg[dd.id] = pp.Y;
			if (val[pp.Y]==0) p.erase(it2);
			//cout << dd.id << " --> " << pp.Y << " --> " << p.SZ << endl;
		}
	}

	if (fail) { cout << "NO\n"; return 0; }

	cout << "YES\n";
	for (int i=1; i<=n; i++) cout << gg[i] << endl;

    return 0;
}


/*
ID: Labib666
LANG: C++
Contest: CF #283 D1
Task: C
*/

#include <bits/stdc++.h>

using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector <int>
#define VLL vector <LL>
#define PQI priority_queue <int>
#define PQLL priority_queue <LL>
#define QI queue <int>
#define QLL queue <LL>
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define SZ size()
#define INF 1000000007
#define LINF 1000000000000000007ll
#define PI 2*asin(1)
#define EPS 1e-9

struct data {
	int typ, id, a, b;
	bool operator < (const data &p) const {
		if (a==p.a && b==p.b) return typ < p.typ;
		else if (a==p.a) return b > p.b;
		else return a < p.a;
	}
};

data make_data (int typ, int id, int a , int b) {
		data dd; dd.a = a, dd.b = b, dd.typ = typ, dd.id = id;
		return dd;
}

int val[100005], gg[100005];

multiset <data> s;
multiset <data> ::iterator it;

multiset < pair <int,int> > p;
multiset < pair <int,int> > ::iterator it2;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen ("test.txt","r",stdin);

    int n, m, u, v;

    cin >> n;

    for (int i=1; i<=n; i++) {
		cin >> u >> v;
		s.insert (make_data (2,i,u,v));
	}

	cin >> m;

	for (int i=1; i<=m; i++) {
		cin >> u >> v >> val[i];
		s.insert (make_data(1,i,u,v));
	}

	bool fail = 0;
	cout << s.SZ << endl;
	it = s.begin();
	for ( ; it != s.end(); it++) {
		data dd = *it;
		//cout << dd.typ << " ===> " << dd.id << " ==> " << dd.a << " => " << dd.b << endl;
		if ( dd.typ == 1 ) {
			p.insert ( MP (dd.b,dd.id) );
			continue;
		}
		else {
			it2 = p.lower_bound ( MP(dd.b,0) );
			if (it2 == p.end()) { fail = 1; break; }
			PII pp = *it2;
			val[pp.Y]--; gg[dd.id] = pp.Y;
			if (val[pp.Y]==0) p.erase(it2);
			//cout << dd.id << " --> " << pp.Y << " --> " << p.SZ << endl;
		}
	}

	if (fail) { cout << "NO\n"; return 0; }

	cout << "YES\n";
	for (int i=1; i<=n; i++) cout << gg[i] << endl;

    return 0;
}


/*
ID: Labib666
LANG: C++
Contest: CF #283 D1
Task: C
*/

#include <bits/stdc++.h>

using namespace std;

#define LL long long
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define VI vector <int>
#define VLL vector <LL>
#define PQI priority_queue <int>
#define PQLL priority_queue <LL>
#define QI queue <int>
#define QLL queue <LL>
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define SZ size()
#define INF 1000000007
#define LINF 1000000000000000007ll
#define PI 2*asin(1)
#define EPS 1e-9

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define ALL(A)     ((A).begin(), (A).end())
#define MEM(A,V)   memset (A, (V), sizeof A)

#define MAXN

int gcd (int a, int b){return (b > a) ? gcd (b,a) : (b == 0) ? a : gcd (b, a%b);}
int bitcount (int a) {return (a != 0) ? bitcount(a & (a-1)) + 1 : 0;}
LL bigmod (LL num, LL pow, LL prime) {
    if (pow == 0ll) return 1ll;
    LL ans = bigmod(num, pow/2ll, prime); ans = (ans*ans)%prime;
    if (pow%2ll) ans = (ans*num)%prime; return ans;
}

struct data {
	int typ, id, a, b;
	bool operator < (const data &p) const {
		if (a==p.a && b==p.b) return typ < p.typ;
		else if (a==p.a) return b > p.b;
		else return a < p.a;
	}
};

data make_data (int typ, int id, int a , int b) {
		data dd; dd.a = a, dd.b = b, dd.typ = typ, dd.id = id;
		return dd;
}

int val[100005], gg[100005];

set <data> s;
set <data> ::iterator it;

set < pair <int,int> > p;
set < pair <int,int> > ::iterator it2;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen ("test.txt","r",stdin);

    int n, m, u, v, w;

    cin >> n;

    for (int i=1; i<=n; i++) {
		cin >> u >> v;
		s.insert (make_data (2,i,u,v));
	}

	cin >> m;

	for (int i=1; i<=m; i++) {
		cin >> u >> v >> val[i];
		s.insert (make_data(1,i,u,v));
	}

	bool fail = 0;

	it = s.begin();
	for ( ; it != s.end(); it++) {
		data dd = *it;
		//cout << dd.typ << " ===> " << dd.id << " ==> " << dd.a << " => " << dd.b << endl;
		if ( dd.typ == 1 ) {
			p.insert ( MP (dd.b,dd.id) );
			continue;
		}
		else {
			it2 = p.lower_bound ( MP(dd.b,0) );
			if (it2 == p.end()) { fail = 1; break; }
			PII pp = *it2;
			val[pp.Y]--; gg[dd.id] = pp.Y;
			//cout << dd.id << " --> " << pp.Y << endl;
			if (val[pp.Y]==0) p.erase(it2);
		}
	}

	if (fail) { cout << "NO\n"; return 0; }

	cout << "YES\n";
	for (int i=1; i<=n; i++) cout << gg[i] << endl;

    return 0;
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define sz size()
#define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
#define FOR( i , n ) FORN( i , 0 , n )
#define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define read ios::sync_with_stdio(false)

using namespace std;

typedef long long int64;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;

struct seg{
    int ini, type, fin, cnt, ind;
    seg() {}
    seg(int ini, int type, int fin, int cnt, int id): ini(ini), type(type), fin(fin), cnt(cnt), ind(ind) {}
    bool operator <  (seg V) const{
        if ( fin !=V.fin  ) return fin <V.fin ;
        return ind<V.ind;
    }
} V[2*100002] ;

    int ans[100002];
    int use[100002];

bool cmp (const seg &A, const seg &V ) {
        if ( A.ini !=V.ini  ) return A.ini <V.ini ;
        if ( A.type!=V.type ) return A.type<V.type;
        return A.fin<V.fin;
}
set < seg > S;
set < seg >::iterator it;
    seg p;
int main(){
    int N,M;
    scanf("%d",&N);
    seg aux;
    FOR(i,N){
        scanf("%d %d",&aux.ini,&aux.fin);
        aux.ind=i+1;
        aux.type=2;
        V[i]=aux;
    }
    scanf("%d",&M);
    FOR(i,M){
        scanf("%d %d %d", &aux.ini, &aux.fin, &aux.cnt);
        aux.ind=i+1;
        aux.type=1;
        V[N+i]=aux;
    }
    sort(V,V+(N+M), cmp);

    FOR(i,M) use[i]=0;
    bool flag=1;
    FOR(i,N+M){
        if ( V[i].type==1 ){
            S.insert(V[i]);
        }
        else{
            it=lower_bound(all(S), seg( 0, -1, V[i].fin, -1, 0 )  );
            if ( it==S.end() ) {printf("NO\n");
    return 0;}
            p=*it;
            ans[V[i].ind-1]=p.ind;
            use[p.ind-1]++;
            if ( use[p.ind-1]==p.cnt ) S.erase(it);
        }
    }

    if (flag) {
        printf("YES\n");
        FOR(i,N) printf("%d ",ans[i]);
    }
    else printf("NO\n");
    return 0;
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define sz size()
#define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
#define FOR( i , n ) FORN( i , 0 , n )
#define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define read ios::sync_with_stdio(false)

using namespace std;

typedef long long int64;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;

struct seg{
    int ini, type, fin, cnt, ind;
    seg() {}
    seg(int ini, int type, int fin, int cnt, int id): ini(ini), type(type), fin(fin), cnt(cnt), ind(ind) {}
    bool operator <  (seg V) const{
        if ( fin !=V.fin  ) return fin <V.fin ;
        return ind<V.ind;
    }
} V[2*100002] ;

bool cmp (const seg &A, const seg &V ) {
        if ( A.ini !=V.ini  ) return A.ini <V.ini ;
        if ( A.type!=V.type ) return A.type<V.type;
        return A.fin<V.fin;
}

int main(){
    int N,M;
    scanf("%d",&N);
    seg aux;
    FOR(i,N){
        scanf("%d %d",&aux.ini,&aux.fin);
        aux.ind=i+1;
        aux.type=2;
        V[i]=aux;
    }
    scanf("%d",&M);
    FOR(i,M){
        scanf("%d %d %d", &aux.ini, &aux.fin, &aux.cnt);
        aux.ind=i+1;
        aux.type=1;
        V[N+i]=aux;
    }
    sort(V,V+(N+M), cmp);

    set < seg > S;
    set < seg >::iterator it;
    seg p;
    int ans[N];
    int use[M];
    FOR(i,M) use[i]=0;
    bool flag=1;
    FOR(i,N+M){
        if ( V[i].type==1 ){
            S.insert(V[i]);
        }
        else{
            it=lower_bound(all(S), seg( 0, -1, V[i].fin, -1, 0 )  );
            if ( it==S.end() ) {flag=0; break;}
            p=*it;
            ans[V[i].ind-1]=p.ind;
            use[p.ind-1]++;
            if ( use[p.ind-1]==p.cnt ) S.erase(it);
        }
    }

    if (flag) {
        printf("YES\n");
        FOR(i,N) printf("%d ",ans[i]);
    }
    else printf("NO\n");
    return 0;
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define sz size()
#define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
#define FOR( i , n ) FORN( i , 0 , n )
#define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define read ios::sync_with_stdio(false)

using namespace std;

typedef long long int64;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;

struct seg{
    int ini, type, fin, cnt, ind;
    bool operator <  (seg V) const{
        if ( ini !=V.ini  ) return ini <V.ini ;
        if ( type!=V.type ) return type<V.type;
        return fin<V.fin;
    }
};

int main(){
    int N,M;
    cin>>N;
    vector < seg > V;
    seg aux;
    FOR(i,N){
        scanf("%d %d",&aux.ini,&aux.fin);
        aux.ind=i+1;
        aux.type=2;
        V.pb(aux);
    }
    cin>>M;
    FOR(i,M){
        scanf("%d %d %d", &aux.ini, &aux.fin, &aux.cnt);
        aux.ind=i+1;
        aux.type=1;
        V.pb(aux);
    }
    sort(all(V));

    set < pair <int,ii> > S;
    set < pair <int,ii> >::iterator it;
    pair <int,ii> p;

    int ans[N];
    int use[M];

    clr(use,0);

    bool flag=1;

    FOR(i,V.sz){
        if ( V[i].type==1 ){
            p.fst=V[i].fin;
            p.snd.fst=V[i].ind;
            p.snd.snd=V[i].cnt;
            S.insert(p);
        }
        else{
            p.fst=V[i].fin;
            p.snd.fst=-1;
            it=lower_bound(all(S),p);
            if ( it==S.end() ) {flag=0; break;}
            ans[V[i].ind-1]=(*it).snd.fst;
            use[(*it).snd.fst-1]++;
            if ( use[(*it).snd.fst-1]==p.snd.snd ) S.erase(it);
        }
    }

    if (flag) {
        puts("YES");
        FOR(i,N) printf("%d ",ans[i]);
    }
    else puts("NO");
/*
    FOR(i,V.sz){
        cout<<V[i].type<<" "<<V[i].ini<<" "<<V[i].fin<<endl;
        cout<<endl;
    }*/
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define sz size()
#define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
#define FOR( i , n ) FORN( i , 0 , n )
#define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define read ios::sync_with_stdio(false)

using namespace std;

typedef long long int64;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;

struct seg{
    int ini, type, fin, cnt, ind;
    bool operator <  (seg V) const{
        if ( ini !=V.ini  ) return ini <V.ini ;
        if ( type!=V.type ) return type<V.type;
        return fin<V.fin;
    }
};

int main(){
    int N,M;
    cin>>N;
    vector < seg > V;
    seg aux;
    FOR(i,N){
        scanf("%d %d",&aux.ini,&aux.fin);
        aux.ind=i+1;
        aux.type=2;
        V.pb(aux);
    }
    cin>>M;
    FOR(i,M){
        scanf("%d %d %d", &aux.ini, &aux.fin, &aux.cnt);
        aux.ind=i+1;
        aux.type=1;
        V.pb(aux);
    }
    sort(all(V));

    set < pair <int,ii> > S;
    set < pair <int,ii> >::iterator it;
    pair <int,ii> p;

    int ans[N];

    bool flag=1;

    FOR(i,V.sz){
        if ( V[i].type==1 ){
            p.fst=V[i].fin;
            p.snd.fst=V[i].ind;
            p.snd.snd=V[i].cnt;
            S.insert(p);
        }
        else{
            p.fst=V[i].fin;
            p.snd.fst=-1;
            it=lower_bound(all(S),p);
            if ( it==S.end() ) {flag=0; break;}
            p=*it;
            S.erase(it);
            ans[V[i].ind-1]=p.snd.fst;
            if ( p.snd.snd!=1 ) {
                p.snd.snd--;
                S.insert(p);
            }
        }
    }

    if (flag) {
        puts("YES");
        FOR(i,N) printf("%d ",ans[i]);
    }
    else puts("NO");
/*
    FOR(i,V.sz){
        cout<<V[i].type<<" "<<V[i].ini<<" "<<V[i].fin<<endl;
        cout<<endl;
    }*/
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define sz size()
#define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
#define FOR( i , n ) FORN( i , 0 , n )
#define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define read ios::sync_with_stdio(false)

using namespace std;

typedef long long int64;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;

struct seg{
    int ini, type, fin, cnt, ind;
    bool operator <  (seg V) const{
        if ( ini !=V.ini  ) return ini <V.ini ;
        if ( type!=V.type ) return type<V.type;
        return fin<V.fin;
    }
} V[2*100002] ;

struct act{
    int fin;
    int ind;
    int cnt;
    bool operator <  (act V) const{
        if ( fin !=V.fin  ) return fin <V.fin ;
        return ind<V.ind;
    }
};

int main(){
    int N,M;
    scanf("%d",&N);
    seg aux;
    FOR(i,N){
        scanf("%d %d",&aux.ini,&aux.fin);
        aux.ind=i+1;
        aux.type=2;
        V[i]=aux;
    }
    scanf("%d",&M);
    FOR(i,M){
        scanf("%d %d %d", &aux.ini, &aux.fin, &aux.cnt);
        aux.ind=i+1;
        aux.type=1;
        V[N+i]=aux;
    }
    sort(V,V+(N+M));

    set < act > S;
    set < act >::iterator it;
    act p;

    int ans[N];
    int use[M];

    FOR(i,M) use[i]=0;

    bool flag=1;

    FOR(i,N+M){
        if ( V[i].type==1 ){
            p.fin=V[i].fin;
            p.ind=V[i].ind;
            p.cnt=V[i].cnt;
            S.insert(p);
        }
        else{
            p.fin=V[i].fin;
            p.ind=-1;
            it=lower_bound(all(S),p);
            if ( it==S.end() ) {flag=0; break;}
            p=*it;
            ans[V[i].ind-1]=p.ind;
            use[p.ind-1]++;
            if ( use[p.ind-1]==p.cnt ) S.erase(it);
        }
    }

    if (flag) {
        puts("YES");
        FOR(i,N) printf("%d ",ans[i]);
    }
    else puts("NO");
/*
    FOR(i,V.sz){
        cout<<V[i].type<<" "<<V[i].ini<<" "<<V[i].fin<<endl;
        cout<<endl;
    }*/
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define sz size()
#define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
#define FOR( i , n ) FORN( i , 0 , n )
#define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define read ios::sync_with_stdio(false)

using namespace std;

typedef long long int64;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;

struct seg{
    int ini, type, fin, cnt, ind;
    bool operator <  (seg V) const{
        if ( ini !=V.ini  ) return ini <V.ini ;
        if ( type!=V.type ) return type<V.type;
        return fin<V.fin;
    }
} V[2*100002] ;

int main(){
    int N,M;
    cin>>N;
    seg aux;
    FOR(i,N){
        scanf("%d %d",&aux.ini,&aux.fin);
        aux.ind=i+1;
        aux.type=2;
        V[i]=aux;
    }
    cin>>M;
    FOR(i,M){
        scanf("%d %d %d", &aux.ini, &aux.fin, &aux.cnt);
        aux.ind=i+1;
        aux.type=1;
        V[N+i]=aux;
    }
    sort(V,V+(N+M));

    set < pair <int,ii> > S;
    set < pair <int,ii> >::iterator it;
    pair <int,ii> p;

    int ans[N];
    int use[M];

    FOR(i,M) use[i]=0;

    bool flag=1;

    FOR(i,N+M){
        if ( V[i].type==1 ){
            p.fst=V[i].fin;
            p.snd.fst=V[i].ind;
            p.snd.snd=V[i].cnt;
            S.insert(p);
        }
        else{
            p.fst=V[i].fin;
            p.snd.fst=-1;
            it=lower_bound(all(S),p);
            if ( it==S.end() ) {flag=0; break;}
            ans[V[i].ind-1]=(*it).snd.fst;
            use[(*it).snd.fst-1]++;
            if ( use[(*it).snd.fst-1]==(*it).snd.snd ) S.erase(it);
        }
    }

    if (flag) {
        puts("YES");
        FOR(i,N) printf("%d ",ans[i]);
    }
    else puts("NO");
/*
    FOR(i,V.sz){
        cout<<V[i].type<<" "<<V[i].ini<<" "<<V[i].fin<<endl;
        cout<<endl;
    }*/
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define sz size()
#define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
#define FOR( i , n ) FORN( i , 0 , n )
#define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define read ios::sync_with_stdio(false)

using namespace std;

typedef long long int64;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;

struct seg{
    int ini, type, fin, cnt, ind;
    seg() {}
    seg(int ini, int type, int fin, int cnt, int id): ini(ini), type(type), fin(fin), cnt(cnt), ind(ind) {}
};

    int ans[100002];
    int use[100002];

    bool operator <  (const seg &A, const seg &V) {
        if ( A.fin !=V.fin  ) return A.fin <V.fin ;
        return A.ind<V.ind;
    }

bool cmp (const seg &A, const seg &V ) {
        if ( A.ini !=V.ini  ) return A.ini <V.ini ;
        if ( A.type!=V.type ) return A.type<V.type;
        return A.fin<V.fin;
}
vector <seg> V;
set < seg > S;
set < seg >::iterator it;
    seg p;
int main(){
    int N,M,ini,fin,cnt;
    scanf("%d",&N);
    seg aux;
    FOR(i,N){
        scanf("%d %d",&ini,&fin);
        V.pb(seg ( ini, 2, fin, 0, i+1 ) ) ;
    }
    scanf("%d",&M);
    FOR(i,M){
        scanf("%d %d %d", &ini, &fin, &cnt);
        V.pb(seg ( ini, 1, fin, cnt, i+1 ) ) ;
    }
    sort(all(V), cmp);

    FOR(i,M) use[i]=0;
    bool flag=1;

    FOR(i,V.sz){
        if ( V[i].type==1 ){
            S.insert(V[i]);
        }
        else{
            it=lower_bound(all(S), seg( 0, -1, V[i].fin, -1, 0 )  );
            if ( it==S.end() ) {printf("NO\n");
    return 0;}
            p=*it;
            ans[V[i].ind-1]=p.ind;
            use[p.ind-1]++;
            if ( use[p.ind-1]==p.cnt ) S.erase(it);
        }
    }

    if (flag) {
        printf("YES\n");
        FOR(i,N) printf("%d ",ans[i]);
    }
    else printf("NO\n");
    return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second
#define llong long long

using namespace std;

const int MXN = (int)1e6 + 10;
const int INF = (int)1e9 + 7;
const double EPS = 1e-9;

struct tt {
    int l, r, type, id, k;
    tt() {}
    tt(int l, int r, int type, int id, int k): l(l), r(r), type(type), id(id), k(k) {}
};

bool cmp (const tt &a, const tt &b){
    return (a.l < b.l
    || (a.l == b.l && a.type < b.type)
    || (a.l == b.l && a.type == b.type && a.r < b.r)
    || (a.l == b.l && a.type == b.type && a.r == b.r && a.k > b.k));
}

bool operator < (const tt &a, const tt &b){
    return (a.r < b.r)
    || (a.r == b.r && a.k > b.k)
    || (a.r == b.r && a.k == b.k && a.id < b.id);
}

set <tt> ss;
int n, m;
vector <tt> a;
int ans[MXN];

/*void debug(){
    printf("---s---\n");
    for(auto key : ss){
        printf("%d %d %d %d %d\n", key.l, key.r, key.type, key.id, key.k);
    }
    printf("---e---\n");
}*/

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    scanf("%d", &n);
    for(int i = 0; i < n; ++i){
        int l, r;
        scanf("%d%d", &l, &r);
        a.push_back(tt(l, r, 1, i, 0));
    }
    scanf("%d", &m);
    for(int i = 0; i < m; ++i){
        int l, r, x;
        scanf("%d%d%d", &l, &r, &x);
        a.push_back(tt(l, r, -1, i, x));
    }
    sort(a.begin(), a.end(), cmp);

    for(int i = 0; i < a.size(); ++i){
        //cerr << a[i].l << " " << a[i].r << " " << a[i].type << endl;
        if(a[i].type == -1){
            ss.insert(a[i]);
        }
        else {
            if(!ss.size()){
                printf("NO");
                return 0;
            }
            set <tt>::iterator tmp = ss.lower_bound(tt(-INF, a[i].r, -1, -1, INF));
            if(tmp == ss.end()){
                printf("NO");
                return 0;
            }
            //debug();
            tt temp = *tmp;
            if(temp.k <= 0){
                printf("NO");
                return 0;
            }
            temp.k--;
            ans[a[i].id] = temp.id + 1;
            ss.erase(tmp);
            if(temp.k)
                ss.insert(temp);
        }
        //debug();
    }
    printf("YES\n");
    for(int i = 0; i < n; ++i){
        printf("%d ", ans[i]);
    }
    return 0;
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define sz size()
#define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
#define FOR( i , n ) FORN( i , 0 , n )
#define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define read ios::sync_with_stdio(false)

using namespace std;

typedef long long int64;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;

struct seg{
    int ini, type, fin, cnt, ind;
    bool operator <  (seg V) const{
        if ( ini !=V.ini  ) return ini <V.ini ;
        if ( type!=V.type ) return type<V.type;
        return fin<V.fin;
    }
};

int main(){
    int N,M;
    cin>>N;
    vector < seg > V;
    seg aux;
    FOR(i,N){
        cin>>aux.ini>>aux.fin;
        aux.ind=i+1;
        aux.type=2;
        V.pb(aux);
    }
    cin>>M;
    FOR(i,M){
        cin>>aux.ini>>aux.fin>>aux.cnt;
        aux.ind=i+1;
        aux.type=1;
        V.pb(aux);
    }
    sort(all(V));

    set < pair <int,ii> > S;
    set < pair <int,ii> >::iterator it;
    pair <int,ii> p;

    int ans[N];

    bool flag=1;

    FOR(i,V.sz){
        if ( V[i].type==1 ){
            p.fst=V[i].fin;
            p.snd.fst=V[i].ind;
            p.snd.snd=V[i].cnt;
            S.insert(p);
        }
        else{
            p.fst=V[i].fin;
            p.snd.fst=-1;
            it=S.lower_bound(p);
            if ( it==S.end() ) {flag=0; break;}
            p=*it;
            S.erase(it);
            ans[V[i].ind-1]=p.snd.fst;
            if ( p.snd.snd!=1 ) {
                p.snd.snd--;
                S.insert(p);
            }
        }
    }

    if (flag) {
        puts("YES");
        FOR(i,N) cout<<ans[i]<<" ";
    }
    else puts("NO");
/*
    FOR(i,V.sz){
        cout<<V[i].type<<" "<<V[i].ini<<" "<<V[i].fin<<endl;
        cout<<endl;
    }*/
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define sz size()
#define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
#define FOR( i , n ) FORN( i , 0 , n )
#define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define read ios::sync_with_stdio(false)

using namespace std;

typedef long long int64;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;

struct seg{
    int ini, type, fin, cnt, ind;
    bool operator <  (seg V) const{
        if ( ini !=V.ini  ) return ini <V.ini ;
        if ( type!=V.type ) return type<V.type;
        return fin<V.fin;
    }
};

int main(){
    int N,M;
    cin>>N;
    vector < seg > V;
    seg aux;
    FOR(i,N){
        scanf("%d %d",&aux.ini,&aux.fin);
        aux.ind=i+1;
        aux.type=2;
        V.pb(aux);
    }
    cin>>M;
    FOR(i,M){
        scanf("%d %d %d", &aux.ini, &aux.fin, &aux.cnt);
        aux.ind=i+1;
        aux.type=1;
        V.pb(aux);
    }
    sort(all(V));

    set < pair <int,ii> > S;
    set < pair <int,ii> >::iterator it;
    pair <int,ii> p;

    int ans[N];
    int use[M];
    clr(use,0);

    bool flag=1;

    FOR(i,V.sz){
        if ( V[i].type==1 ){
            p.fst=V[i].fin;
            p.snd.fst=V[i].ind;
            p.snd.snd=V[i].cnt;
            S.insert(p);
        }
        else{
            p.fst=V[i].fin;
            p.snd.fst=-1;
            it=lower_bound(all(S),p);
            if ( it==S.end() ) {flag=0; break;}
            ans[V[i].ind-1]=(*it).snd.fst;
            use[p.snd.fst-1]++;
            if ( use[p.snd.fst-1]==p.snd.snd ) S.erase(it);
        }
    }

    if (flag) {
        puts("YES");
        FOR(i,N) printf("%d ",ans[i]);
    }
    else puts("NO");
/*
    FOR(i,V.sz){
        cout<<V[i].type<<" "<<V[i].ini<<" "<<V[i].fin<<endl;
        cout<<endl;
    }*/
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define sz size()
#define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
#define FOR( i , n ) FORN( i , 0 , n )
#define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define read ios::sync_with_stdio(false)

using namespace std;

typedef long long int64;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;

struct seg{
    int ini, type, fin, cnt, ind;
    bool operator <  (seg V) const{
        if ( ini !=V.ini  ) return ini <V.ini ;
        if ( type!=V.type ) return type<V.type;
        return fin<V.fin;
    }
};

int main(){
    int N,M;
    cin>>N;
    vector < seg > V;
    seg aux;
    FOR(i,N){
        scanf("%d %d",&aux.ini,&aux.fin);
        aux.ind=i+1;
        aux.type=2;
        V.pb(aux);
    }
    cin>>M;
    FOR(i,M){
        scanf("%d %d %d", &aux.ini, &aux.fin, &aux.cnt);
        aux.ind=i+1;
        aux.type=1;
        V.pb(aux);
    }
    sort(all(V));

    set < pair <int,ii> > S;
    set < pair <int,ii> >::iterator it;
    pair <int,ii> p;

    int ans[N];
    int use[M];

    clr(use,0);

    bool flag=1;

    FOR(i,V.sz){
        if ( V[i].type==1 ){
            p.fst=V[i].fin;
            p.snd.fst=V[i].ind;
            p.snd.snd=V[i].cnt;
            S.insert(p);
        }
        else{
            p.fst=V[i].fin;
            p.snd.fst=-1;
            it=lower_bound(all(S),p);
            if ( it==S.end() ) {flag=0; break;}
            ans[V[i].ind-1]=(*it).snd.fst;
            use[(*it).snd.fst-1]++;
            if ( use[(*it).snd.fst-1]==(*it).snd.snd ) S.erase(it);
        }
    }

    if (flag) {
        puts("YES");
        FOR(i,N) printf("%d ",ans[i]);
    }
    else puts("NO");
/*
    FOR(i,V.sz){
        cout<<V[i].type<<" "<<V[i].ini<<" "<<V[i].fin<<endl;
        cout<<endl;
    }*/
}


#include <algorithm>
#include <bitset>
#include <deque>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define fst first
#define snd second
#define all(x) (x).begin(), (x).end()
#define clr(a, v) memset( a , v , sizeof(a) )
#define pb push_back
#define mp make_pair
#define sz size()
#define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
#define FOR( i , n ) FORN( i , 0 , n )
#define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
#define trace(x)    cerr << #x << ": " << x << endl;
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define read ios::sync_with_stdio(false)

using namespace std;

typedef long long int64;
typedef vector <int> vi;
typedef pair <int,int> ii;
typedef vector <string> vs;
typedef vector <ii> vii;

struct seg{
    int ini, type, fin, cnt, ind;
    bool operator <  (seg V) const{
        if ( ini !=V.ini  ) return ini <V.ini ;
        if ( type!=V.type ) return type<V.type;
        return fin<V.fin;
    }
};

int main(){
    int N,M;
    cin>>N;
    vector < seg > V;
    seg aux;
    FOR(i,N){
        cin>>aux.ini>>aux.fin;
        aux.ind=i+1;
        aux.type=2;
        V.pb(aux);
    }
    cin>>M;
    FOR(i,M){
        cin>>aux.ini>>aux.fin>>aux.cnt;
        aux.ind=i+1;
        aux.type=1;
        V.pb(aux);
    }
    sort(all(V));

    set < pair <int,ii> > S;
    set < pair <int,ii> >::iterator it;
    pair <int,ii> p;

    int ans[N];

    bool flag=1;

    FOR(i,V.sz){
        if ( V[i].type==1 ){
            p.fst=V[i].fin;
            p.snd.fst=V[i].ind;
            p.snd.snd=V[i].cnt;
            S.insert(p);
        }
        else{
            p.fst=V[i].fin;
            p.snd.fst=-1;
            it=lower_bound(all(S),p);
            if ( it==S.end() ) {flag=0; break;}
            p=*it;
            S.erase(it);
            ans[V[i].ind-1]=p.snd.fst;
            if ( p.snd.snd!=1 ) {
                p.snd.snd--;
                S.insert(p);
            }
        }
    }

    if (flag) {
        puts("YES");
        FOR(i,N) cout<<ans[i]<<" ";
    }
    else puts("NO");
/*
    FOR(i,V.sz){
        cout<<V[i].type<<" "<<V[i].ini<<" "<<V[i].fin<<endl;
        cout<<endl;
    }*/
}


#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>, 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 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)] = V2[d].second; 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 + 1;
		mp[*it]--;
		if (mp[*it] == 0) 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;
}