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
/*
 *
 * @author Mukesh Singh
 *
 */

/* Finding_the_Minimum_Window_in_S_which_Contains_All_Elements_from_T */

import java.io.*;
import java.util.*;
import java.text.DecimalFormat;
@SuppressWarnings("unchecked")
public class AB
{	
	//solve test cases
	void solve() throws Exception 
	{
		LinkedList<PP> ls = new LinkedList<PP>();
		int n = in.nextInt() ;
		for(int i= 0 ; i < n ; i++)
		{
			int a = in.nextInt();
			int b = in.nextInt();
			ls.add(new PP(i+1,a,b,0,-1));
		}
		n = in.nextInt() ;
		for(int i= 0 ; i < n ; i++)
		{
			int a = in.nextInt();
			int b = in.nextInt();
			int k = in.nextInt();
			ls.add(new PP(i+1,a,b,1,k));
		}
		Collections.sort(ls,new Comparator<PP>(){
			public int compare(PP p1 , PP p2)
			{
				if(p1.a < p2.a)
					return -1 ;
				else if(p1.a==p2.a)
					return p2.actor - p1.actor ;
				return 1 ;
			}
		});
		TreeSet<PP> ts = new TreeSet<PP>(new Comparator<PP>(){
			public int compare(PP p1 , PP p2)
			{
				if(p1.actor == p2.actor && p1.b != p2.b )
					return p1.b - p2.b ;
				if(p1.actor == p2.actor && p1.b == p2.b && p1.a != p2.a)
					return p2.a - p1.a ;
				if(p1.actor == p2.actor && p1.b == p2.b && p1.a == p2.a)
					return p1.id - p2.id ;
				if(p1.actor != p2.actor && p1.b != p2.b )
					return p1.b - p2.b ;
				if(p1.actor != p2.actor && p1.b == p2.b )
					return p2.a - p1.a ;
				return 0;
			}
		});
		
		LinkedList<Node> ans = new LinkedList<Node>();
		for( PP pp: ls)
		{
			if(pp.actor==1)
			{
				ts.add(pp);
			}
			else
			{
				
				PP p1 = ts.ceiling(pp);
				//System.out.println("part "+pp.a+" "+pp.b);
				//System.out.println("act "+p1.a+" "+p1.b);
				if(p1==null)
				{
					System.out.println("NO");
					return ;
				}
				p1.k = p1.k -1 ;
				ans.addLast(new Node(pp.id,p1.id));
				if(p1.k==0)
					ts.remove(p1);
			}
		}
		System.out.println("YES");
		Collections.sort(ans,new Comparator<Node>(){
			public int compare(Node p1 , Node p2)
			{
				return p1.part-p2.part ;
			}
		});
		for(Node aaa:ans)
			System.out.print(aaa.actor+" ");
		System.out.println();
	}
	//@ main function
	public static void main(String[] args) throws Exception 
	{
		new AB();
	}
	
	InputReader in;
	PrintStream out ;
	DecimalFormat df ;
	AB() 
	{
		try 
		{
			File defaultInput = new File("file.in");
			if (defaultInput.exists()) 
				in = new InputReader("file.in");
			else 
				in = new InputReader();
			defaultInput = new File("file.out");
			if (defaultInput.exists()) 
				out = new PrintStream(new FileOutputStream("file.out"));
			else
				out = new PrintStream(System.out);
			df = new DecimalFormat("######0.00");
			solve();
			out.close();
		} 
		catch (Exception e) 
		{
			e.printStackTrace();
			System.exit(261);
		}
	}
	
	class InputReader {
		BufferedReader reader;
		StringTokenizer tokenizer;
		
		InputReader() {
			reader = new BufferedReader(new InputStreamReader(System.in));
		}
		
		InputReader(String fileName) throws FileNotFoundException {
			reader = new BufferedReader(new FileReader(new File(fileName)));
		}
		
		String readLine() throws IOException {
			return reader.readLine();
		}
		
		String nextToken() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens())
				tokenizer = new StringTokenizer(readLine());
			return tokenizer.nextToken();
		}
		
		boolean hasMoreTokens() throws IOException {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				String s = readLine();
				if (s == null)
					return false;
				tokenizer = new StringTokenizer(s);
			}
			return true;
		}
		
		int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(nextToken());
		}
		
		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(nextToken());
		}
		
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(nextToken());
		}
	}
}
class PP
{
	int id ;
	int a ;
	int b ;
	int actor ;
	int k ;
	PP(int ii ,int i , int j , int kk ,int l)
	{
		id = ii ;
		a = i ;
		b = j ;
		actor= kk ;
		k = l ;
	}
}
class Node
{
	int part ;
	int actor ;
	Node(int a , int b)
	{
		part = a ;
		actor = b ;
	}
}
