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.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 *
 *
 * 3 2 3 5
 * -2 -1 4 -1 2 7 3
 *
 * 10 1 -10617 30886 -7223 -63085 47793 -61665 -14614 60492 16649 -58579 3 8 1
 * 10 4 7 1 7 3 7
 *
 * 22862 -34877
 *
 * @author pttrung
 */
public class D {
    
    public static long MOD = 1000000007;
    static int max = 3;
    public static long[][] dp;
    public static int[] X = {0, 1, 0, -1};
    public static int[] Y = {1, 0, -1, 0};
    
    public static void main(String[] args) throws FileNotFoundException {
        PrintWriter out;
        Scanner in = new Scanner();
        // out = new PrintWriter(new FileOutputStream(new File("output.txt")));
        out = new PrintWriter(System.out);
        int n = in.nextInt();
        Part[] data = new Part[n];
       
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            
          
            data[i] = new Part(a, b, 0, i);
        }
        int m = in.nextInt();
        Part[] act = new Part[m];
        for (int i = 0; i < m; i++) {
            int a = in.nextInt();
            int b = in.nextInt();
            
           
            act[i] = new Part(a, b, in.nextInt(), i);
        }
     
        ArrayList<End> list = new ArrayList();
        for (int i = 0; i < n; i++) {
            list.add(new End(data[i].h, data[i].l, 0, i));
        }
        for (int i = 0; i < m; i++) {
            list.add(new End(act[i].h, act[i].l, 1, i));            
        }
        
        Collections.sort(list, new Comparator<End>() {
            @Override
            public int compare(End o1, End o2) {
                if (o1.p != o2.p) {
                    return o1.p - o2.p;
                } else if (o1.type != o2.type) {
                    return o1.type - o2.type;
                }
                return o2.s - o1.s;
            }
        });
        
        TreeSet<End> current = new TreeSet(new Comparator<End>() {
            @Override
            public int compare(End o1, End o2) {
                if (o1.s != o2.s) {
                    return o1.s - o2.s;
                }else{
                    if(o1.type != o2.type){
                        return 0;
                    }
                    return o1.index - o2.index;
                }
            }
        });
        int[]result = new int[n];
        for(int i = 0; i < m+ n;  i++){
            if(list.get(i).type == 0){
                current.add(list.get(i));
            }else{
             //   System.out.println(list.get(i).p + " " + list.get(i).s + " " + current);
                int total = act[list.get(i).index].k;
                
                while(total > 0 && !current.isEmpty()){
                    End e = current.ceiling(list.get(i));
                    if(e == null){
                        break;
                    }
                    result[e.index] = list.get(i).index;
                    current.remove(e);
                    total--;
                }
            }
        }
        if(current.isEmpty()){
            out.println("YES");
            for(int i = 0; i < n; i++){
                out.print((result[i] + 1) + " ");
            }
        }else{
            out.println("NO");
        }
        
        out.close();
    }
    
    static class End {
        
        int p, s, type, index;
        
        public End(int p, int s, int type, int index) {
            this.p = p;
            this.s = s;
            this.type = type;
            this.index = index;
        }

        @Override
        public String toString() {
            return "End{" + "p=" + p + ", s=" + s + ", index=" + index + '}';
        }
    }
    
    static class Part implements Comparable<Part> {
        
        int l, h, k, index;
        
        public Part(int l, int h, int k, int index) {
            this.l = l;
            this.h = h;
            this.k = k;
            this.index = index;
        }
        
        @Override
        public int compareTo(Part o) {
            if (l != o.l) {
                return l - o.l;
            } else if (h != o.h) {
                return h - o.h;
            } else {
                return k - o.k;
            }
        }
        
        @Override
        public String toString() {
            return "Part{" + "l=" + l + ", h=" + h + ", k=" + k + ", index=" + index + '}';
        }
    }
    
    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }
    
    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }
    
    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;
        
    }
    
    public static class Point implements Comparable<Point> {
        
        int x, y;
        
        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }
        
        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }
        
        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }
        
        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }
    
    public static class FT {
        
        long[] data;
        
        FT(int n) {
            data = new long[n];
        }
        
        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }
        
        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;
            
        }
    }
    
    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
    
    public static long pow(long a, long b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;
            
            
            
            
            
            
            
            
        }
    }
    
    static class Scanner {
        
        BufferedReader br;
        StringTokenizer st;
        
        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }
        
        public String next() {
            
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }
        
        public long nextLong() {
            return Long.parseLong(next());
        }
        
        public int nextInt() {
            return Integer.parseInt(next());
        }
        
        public double nextDouble() {
            return Double.parseDouble(next());
        }
        
        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
        
        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}
