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.*;
import java.math.BigInteger;
import java.util.*;

public class Solution implements Runnable {

    // leave empty to read from stdin/stdout
    private static final String TASK_NAME_FOR_IO = "";

    // file names
    private static final String FILE_IN = TASK_NAME_FOR_IO + ".in";
    private static final String FILE_OUT = TASK_NAME_FOR_IO + ".out";

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tokenizer = new StringTokenizer("");

    public static void main(String[] args) {
        new Thread(new Solution()).start();
    }

    int n, m;
    int []a, b;
    int []c, d, k;

    ArrayList<Integer> cmpsd;
    Event []e;

    SegmentTree tree;

    private void solve() throws IOException {

        cmpsd = new ArrayList<Integer>();

        n = nextInt();
        a = new int[n];
        b = new int[n];
        for(int i = 0; i < n; ++i) {
            a[i] = nextInt();
            b[i] = nextInt();
            cmpsd.add(a[i]);
            cmpsd.add(b[i]);
        }

        m = nextInt();
        c = new int[m];
        d = new int[m];
        k = new int[m];
        for(int i = 0; i < m; ++i) {
            c[i] = nextInt();
            d[i] = nextInt();
            k[i] = nextInt();
            cmpsd.add(c[i]);
            cmpsd.add(d[i]);
        }

        // System.out.println(cmpsd);

        compress(cmpsd);

        // System.out.println(cmpsd);

        e = new Event[n + m];
        for(int i = 0; i < n; ++i) {
            a[i] = Collections.binarySearch(cmpsd, a[i]);
            b[i] = Collections.binarySearch(cmpsd, b[i]);
            e[i] = new Event(a[i], b[i], 1, i);
        }

        for(int i = 0; i < m; ++i) {
            c[i] = Collections.binarySearch(cmpsd, c[i]);
            d[i] = Collections.binarySearch(cmpsd, d[i]);
            e[n + i] = new Event(c[i], d[i], 0, i);
        }

        Arrays.sort(e);

        tree = new SegmentTree(4 * 100010);

        int []ans = new int[n];

        for(int i = 0; i < n + m; ++i) {
            if (e[i].type == 0) {
                // System.out.println("update = " + e[i].b);
                tree.update(e[i].b, e[i].id);
            }else {
                // System.out.println("query = " + e[i].b);
                while(true) {
                    Node r = tree.get(e[i].b);
                    // System.out.println(r);
                    if (r.size() == 0) {
                        out.println("NO");
                        out.close();
                        return;
                    }
                    int id = r.list.getLast();
                    // System.out.println("k=" + k[id]);
                    if (k[id] == 0) {
                        tree.remove(r.pos);
                        continue;
                    }
                    k[id]--;
                    ans[e[i].id] = id + 1;
                    // System.out.println("answer is " + e[i].id + " " + (id + 1));
                    break;
                }
            }
        }
        out.println("YES");
        for(int i : ans) out.print(i + " ");
        out.println();
        out.close();
    }

    class Event implements Comparable<Event> {
        int a, b, type, id;

        public Event(int a, int b, int type, int id) {
            this.a = a;
            this.b = b;
            this.type = type;
            this.id = id;
        }

        public int compareTo(Event other){
            if (this.a < other.a) return -1;
            if (this.a > other.a) return 1;
            if (this.type < other.type) return -1;
            if (this.type > other.type) return 1;
            return this.id - other.id;
        }
    }

    private void compress(ArrayList<Integer> list) {
        Collections.sort(list);
        int at = 0;
        for(int i = 0; i < list.size(); ++i) {
            if (list.get(at).compareTo(list.get(i)) != 0) {
                list.set(++at, list.get(i));
            }
        }
        for(int i = list.size() - 1; i > at; --i) {
            list.remove(i);
        }
    }

    class SegmentTree {
        int n;
        Node []tree;

        public SegmentTree(int n) {
            this.n = n;
            int N = Integer.highestOneBit(n) << 2;
            tree = new Node[N];
            build(1, 0, n - 1);
        }

        private void build(int v, int tl, int tr) {
            if (tl == tr) {
                tree[v] = new Node(tl);
                return;
            }
            int tm = (tl + tr) >> 1;
            build(2 * v, tl, tm);
            build(2 * v + 1, tm + 1, tr);

            tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
        }

        public Node get(int l) {
            return get(1, 0, n - 1, l, n - 1);
        }

        private Node get(int v, int tl, int tr, int l, int r) {
            if (l > r) return new Node(-1);
            if (tl == tr) return tree[v];
            if (tree[v].size() == 0) return tree[v];
            int tm = (tl + tr) >> 1;
            Node left = get(2 * v, tl, tm, l, Math.min(tm, r));
            if (left.size() != 0) return left;

            return get(2 * v + 1, tm + 1, tr, Math.max(l, tm + 1), r);
        }

        public void update(int pos, int id) {
            update(1, 0, n-1, pos, id);
        }

        private void update(int v, int tl, int tr, int pos, int id) {
            if (tl == tr) {
                tree[v].add(id);
                return;
            }
            int tm = (tl + tr) >> 1;
            if (pos <= tm) update(2 * v, tl, tm, pos, id);
            else update(2 * v + 1, tm + 1, tr, pos, id);

            tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
        }

        public void remove(int pos) {
            remove(1, 0, n - 1, pos);
        }

        private void remove(int v, int tl, int tr, int pos) {
            if (tl == tr) {
                tree[v].remove();
                return;
            }
            int tm = (tl + tr) >> 1;
            if (pos <= tm) remove(2 * v, tl, tm, pos);
            else remove(2 * v + 1, tm + 1, tr, pos);

            tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
        }

        private Node merge(Node left, Node right) {
            if (left.size() >= right.size()) return left;
            return right;
        }
    }

    class Node {
        LinkedList<Integer> list;
        int pos;
        public Node(int pos) {
            list = new LinkedList<Integer>();
            this.pos = pos;
        }

        public void add(int x) {
            list.add(x);
        }

        public void remove() {
            list.removeLast();
        }

        public int size() {
            return list.size();
        }

        public String toString() {
            return "pos=" + this.pos + " size=" + list.size();
        }
    }

    public void run() {
        long timeStart = System.currentTimeMillis();

        boolean fileIO = TASK_NAME_FOR_IO.length() > 0;
        try {

            if (fileIO) {
                in = new BufferedReader(new FileReader(FILE_IN));
                out = new PrintWriter(new FileWriter(FILE_OUT));
            } else {
                in = new BufferedReader(new InputStreamReader(System.in));
                out = new PrintWriter(new OutputStreamWriter(System.out));
            }

            solve();

            in.close();
            out.close();
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
        long timeEnd = System.currentTimeMillis();

        if (fileIO) {
            System.out.println("Time spent: " + (timeEnd - timeStart) + " ms");
        }
    }

    private String nextToken() throws IOException {
        while (!tokenizer.hasMoreTokens()) {
            String line = in.readLine();
            if (line == null) {
                return null;
            }
            tokenizer = new StringTokenizer(line);
        }
        return tokenizer.nextToken();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private BigInteger nextBigInt() throws IOException {
        return new BigInteger(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

}