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

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

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

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

Input

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

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

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

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

Output

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

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

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

Examples

Input

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


Output

YES
1 1 2


Input

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


Output

NO
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {
	public static void main(String[] args) throws IOException{
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		
		//InputStream inputStream = new FileInputStream("input.txt");
		//OutputStream outputStream = new FileOutputStream("output.txt");
		
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		
		TaskE solver = new TaskE();
		solver.solve(in, out);
		
		out.close();
	}
}

class TaskE {
	
    public void solve(InputReader in, OutputWriter out) {
    	
    	int n = in.nextInt();
    	Struct[] a = new Struct[n];
    	for(int i=0; i<n; i++){
    		int l = in.nextInt();
    		int r = in.nextInt();
    		a[i] = new Struct(2,l,r,0,i);
    	}
    	
    	int m = in.nextInt();
    	Struct[] b = new Struct[m];
    	for(int i=0; i<m; i++){
    		int l = in.nextInt();
    		int r = in.nextInt();
    		int k = in.nextInt();
    		
    		b[i] = new Struct(1,l,r,k,i);
    	}
    	
    	Struct[] c = new Struct[n+m];
    	for(int i=0; i<n; i++)
    		c[i] = a[i];
    	for(int i=0; i<m; i++)
    		c[i+n] = b[i];
    	
    	Arrays.sort(c, new CompByLeft());
    	TreeSet<Struct> set = new TreeSet<Struct>(new CompByRight());
    	int[] ans = new int[n];
    	
    	for(int i=0; i<n+m; i++){
    		if(c[i].type==1){
    			set.add(c[i]);
    		}else{
    			Struct s = set.ceiling(new Struct(1,0,c[i].r,0,0));
    			if(s==null){
    				out.writeln("NO");
    				return;
    			}else{
    				ans[c[i].ind]=s.ind;
    				set.remove(s);
    				if(s.k>1) set.add(new Struct(s.type,s.l,s.r,s.k-1,s.ind));
    			}
    		}
    	}
    	
    	out.writeln("YES");
    	for(int i=0; i<n; i++)
    		out.write((ans[i]+1)+" ");
    	
    }
    
}

class CompByLeft implements Comparator<Struct>{
	
	public int compare(Struct s1, Struct s2){
		if(s1.l==s2.l)
			return s1.type-s2.type;
		else
			return s1.l-s2.l;
	}
}

class CompByRight implements Comparator<Struct>{
	
	public int compare(Struct s1, Struct s2){
		return s1.r==s2.r ? s1.ind-s2.ind : s1.r-s2.r;
	}
	
}

class Struct{
	
	public Struct(int type, int l, int r, int k, int ind){
		this.type = type;
		this.l = l;
		this.r = r;
		this.k = k;
		this.ind = ind;
	}
	
	int l,r,k,type,ind;
}

class InputReader{
	
	BufferedReader reader;
	StringTokenizer tokenizer;
	
	public InputReader(InputStream stream){
		tokenizer = null;
		reader = new BufferedReader(new InputStreamReader(stream));
	}
	
	public String next(){
		while(tokenizer==null || !tokenizer.hasMoreTokens()){
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException();
			}
		}
		
		return tokenizer.nextToken();
	}
	
	public String nextLine(){
		tokenizer = null;
		try {
			return reader.readLine();
		} catch (IOException e) {
			throw new RuntimeException();
		}
	}
	
	public int nextInt(){
		return Integer.parseInt(next());
	}
	
	public long nextLong(){
		return Long.parseLong(next());
	}
	
	public int[] nextIntArray(int n){
		int[] res = new int[n];
		for(int i=0; i<n; i++)
			res[i] = nextInt();
		
		return res;
	}
	
}

class OutputWriter{
	
	PrintWriter out;
	
	public OutputWriter(OutputStream stream){
		out = new PrintWriter(new BufferedWriter(
				new OutputStreamWriter(stream)));
	}
	
	public void write(Object ...o){
		for(Object cur : o)
			out.print(cur);
	}
	
	public void writeln(Object ...o){
		write(o);
		out.println();
	}
	
	public void flush(){
		out.flush();
	}
	
	public void close(){
		out.close();
	}
	
}
	
