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.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.NavigableSet;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class E_DistributingParts {

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;
	
	static void newLine() throws IOException {
		st = new StringTokenizer(br.readLine());
	}
	
	public static void main(String[] args) throws Exception {
		newLine();
		int n = Integer.parseInt(st.nextToken());
		
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			newLine();
			a[i] = Integer.parseInt(st.nextToken());
			b[i] = Integer.parseInt(st.nextToken());
		}
		
		newLine();
		int m = Integer.parseInt(st.nextToken());
		
		int[] c = new int[m];
		int[] d = new int[m];
		int[] k = new int[m];
		for (int i = 0; i < m; i++) {
			newLine();
			c[i] = Integer.parseInt(st.nextToken());
			d[i] = Integer.parseInt(st.nextToken());
			k[i] = Integer.parseInt(st.nextToken());
		}
		System.out.println( print( solve( n, a, b, m, c, d, k ) ) );
	}	

	static Comparator<Part> partIndexComparator = new Comparator<Part>() {
		@Override
		public int compare(Part p1, Part p2) {
			return Integer.compare(p1.oidx, p2.oidx);
		}
	};
	
	private static String print(ArrayList<Part> res) {
		if (res == null) return "NO";
		Collections.sort(res, partIndexComparator);
		StringBuilder sb = new StringBuilder();
		sb.append("YES\n");
		sb.append(res.get(0).aidx);
		for (int i = 1; i < res.size(); i++) {
			sb.append(' ').append(res.get(i).aidx);
		}
		return sb.toString();
	}

	private static ArrayList<Part> solve(int n, int[] a, int[] b, int m, int[] c, int[] d, int[] k) {
		ArrayList<Part> list = new ArrayList<>(n);

		PriorityQueue<Interval> p = new PriorityQueue<>();
		for (int i = 0; i < n; i++) {
			p.add( new Part(a[i], b[i], i ) );
		}
		
//		PriorityQueue<Actor> aq = new PriorityQueue<>();
		for (int i = 0; i < m; i++) {
			p.add( new Actor(c[i], d[i], k[i], i + 1 ) );
		}
		
		TreeSet<Actor> as = new TreeSet<>(toComparator);
		int zeros = 0;
		while (p.isEmpty() == false) {
			Interval i = p.poll();
			if (i instanceof Actor ) {
				as.add( (Actor) i );
			} else {
				Part part = (Part)i;
				NavigableSet<Actor> tailSet = as.tailSet(new Actor(0, part.t, 0, 0), true);
				if ( tailSet.isEmpty() == false ) {
					Iterator<Actor> iter = tailSet.iterator();
					Actor act = iter.next();
					if (act.k == 1) {
						iter.remove();
					}
//					while ( iter.hasNext() ) {
//						act = iter.next();
//						if ( act.k == 0 ) {
//							if (iter.hasNext() == false) {
//								return null;
//							}
////							act = iter.next();
//							continue;
//						} else {
//							break;
//						}
//					}
					act.k--;
					if (act.k == 0) {
						++zeros;
						if ( 1L * zeros * zeros >= as.size() ) {
							removeZeros(as);
							zeros = 0;
						}
					}
					part.aidx = act.idx;
					list.add(part);
				}
			}
		}

		if (list.size() == n) {
			return list;
		}
		return null;
	}

	private static void removeZeros(TreeSet<Actor> as) {
		Iterator<Actor> iter = as.iterator();
		while (iter.hasNext()) {
			Actor actor = iter.next();
			if (actor.k == 0 ) {
				iter.remove();
			}
		}
	}

	static Comparator<Actor> toComparator = new Comparator<Actor>() {
		@Override
		public int compare(Actor a1, Actor a2) {
			if (a1.t == a2.t) {
				if (a1.f == a2.f) {
					return Integer.compare(a1.idx, a2.idx);
				} else {
					return Integer.compare(a1.f, a2.f);
				}
			} else {
				return Integer.compare(a1.t, a2.t);
			}
		}
	};
	
	private static boolean isOk(Part part, Actor actor) {
		return isBetween(part.f, actor.f, actor.t) && isBetween(part.t, actor.f, actor.t);
	}

	private static boolean isBetween(int x, int f, int t) {
		return f <= x && x <= t;
	}

	interface Interval extends Comparable<Interval> {
		int getF();
		int getT();
		int getType();
	}
	
	static class Part implements Interval, Comparable<Interval> {

		int f, t, oidx, aidx;

		public Part( int f, int t, int idx ) {
			this.f = f;
			this.t = t;
			this.oidx = idx;
		}
		
		public int getF() {
			return f;
		}

		public int getT() {
			return t;
		}

		public int getType() {
			return 'P';
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + aidx;
			result = prime * result + f;
			result = prime * result + oidx;
			result = prime * result + t;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Part other = (Part) obj;
			if (aidx != other.aidx)
				return false;
			if (f != other.f)
				return false;
			if (oidx != other.oidx)
				return false;
			if (t != other.t)
				return false;
			return true;
		}

		@Override
		public int compareTo(Interval i) {
			if ( f == i.getF() ) {
				if (getType() == i.getType()) {
					return Integer.compare(t, i.getT());
				} else {
					return Integer.compare(getType(), i.getType());
				}
			} else {
				return Integer.compare(f, i.getF());
			}
		}
		
		@Override
		public String toString() {
			return String.format("[%d, %d]", f, t);
		}
	}
	
	static class Actor implements Interval, Comparable<Interval> {

		int f, t, k, idx;

		public Actor(int f, int t, int k, int idx) {
			this.f = f;
			this.t = t;
			this.k = k;
			this.idx = idx;
		}

		public int getF() {
			return f;
		}

		public int getT() {
			return t;
		}

		public int getType() {
			return 'A';
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + f;
			result = prime * result + idx;
			result = prime * result + k;
			result = prime * result + t;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Actor other = (Actor) obj;
			if (f != other.f)
				return false;
			if (idx != other.idx)
				return false;
			if (k != other.k)
				return false;
			if (t != other.t)
				return false;
			return true;
		}

		@Override
		public int compareTo(Interval i) {
			if ( f == i.getF() ) {
				if (getType() == i.getType() ) {
					Actor a = (Actor) i;
					if ( t == i.getT() ) {
						return Integer.compare(idx, a.idx);
					} else {
						return Integer.compare(t, i.getT());						
					}
				} else {
					return Integer.compare(getType(), i.getType());
				}
			} else {
				return Integer.compare(f, i.getF());
			}
		}
				
		@Override
		public String toString() {
			return String.format("[%d, %d, x%d]", f, t, k);
		}
	}
}
