The main Bertown street is represented by a straight line. There are 109 bus stops located on the line. The stops are numbered with integers from 1 to 109 in the order in which they follow on the road. The city has n buses. Every day the i-th bus drives from stop number si to stop number fi (si < fi), it stops on all intermediate stops and returns only at night. The bus starts driving at time ti and drives so fast that it finishes driving also at time ti. The time ti is different for all buses. The buses have infinite capacity.

Bertown has m citizens. Today the i-th person should get from stop number li to stop number ri (li < ri); the i-th citizen comes to his initial stop (li) at time bi. Each person, on the one hand, wants to get to the destination point as quickly as possible, and on the other hand, definitely does not want to change the buses as he rides. More formally: the i-th person chooses bus j, with minimum time tj, such that sj ≤ li, ri ≤ fj and bi ≤ tj. 

Your task is to determine for each citizen whether he can ride to the destination point today and if he can, find the number of the bus on which the citizen will ride.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 105) — the number of buses and the number of people. 

Then n lines follow, each of them contains three integers: si, fi, ti (1 ≤ si, fi, ti ≤ 109, si < fi) — the description of the buses. It is guaranteed that all ti-s are different.

Then m lines follow, each of them contains three integers: li, ri, bi (1 ≤ li, ri, bi ≤ 109, li < ri) — the Bertown citizens' description. Some bi-s could coincide.

Output

In the first line print m space-separated integers: the i-th number should be equal either to -1, if the person number i can't get to the destination point, or to the number of the bus that will ride the person number i. The buses are numbered with integers from 1 to n in the input order.

Examples

Input

4 3
1 10 10
5 6 2
6 7 3
5 7 4
5 7 1
1 2 1
1 10 11


Output

4 1 -1


Input

1 1
1 1000000000 1000000000
1 1000000000 1000000000


Output

1
import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.geom.*;

import static java.lang.Math.*;

public class Solution implements Runnable {

    class Bus implements Comparable<Bus>{
        int s, f, t, index;

        public Bus(int s, int f, int t, int index) {
            this.s = s;
            this.f = f;
            this.t = t;
            this.index = index;
        }

        public int compareTo(Bus o) {
            return this.t - o.t;
        }

    }

    class Passenger {
        int l, r, b, index;

        int busno;

        public Passenger(int l, int r, int b, int index) {
            this.l = l;
            this.r = r;
            this.b = b;
            this.index = index;
            busno = -1;
        }

        public void setBusno(int busno) {
            this.busno = busno;
        }

        public int getBusno() {
            return busno;
        }



    }

    class State implements Comparable<State> {
        int d, who, index;
        // 1 - bus in, 3 bus out
        // 2 - passenger

        public State(int d, int who, int index) {
            this.d = d;
            this.who = who;
            this.index = index;
        }

        public int compareTo(State o) {
            if (this.d < o.d) return -1;
            if (this.d > o.d) return 1;
            return this.who - o.who;
        }

    }

    class SegmentTreeMax {
        int n;
        int t [];

        private void set (int v, int tl, int tr, int pos, int value) {
            if (tl == tr) {
                t [v] = value;
            } else {
                int tm = (tl + tr) >> 1;
                if (pos <= tm) {
                    set (v * 2, tl, tm, pos, value);
                } else {
                    set (v * 2 + 1, tm + 1, tr, pos, value);
                }
                t[v] = max (t[v * 2], t[v * 2 + 1]);
            }
        }

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

        private int get (int v, int tl, int tr, int l, int r) {
            if (l > r) return 0;
            if (l == tl && r == tr) {
                return t [v];
            }
            int tm = (tl + tr) >> 1;
            int left = get (2 * v, tl, tm, l, min (r, tm));
            int right = get (2 * v + 1, tm + 1, tr, max (tm + 1, l), r);
            return max (left, right);
        }

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

        public SegmentTreeMax(int n) {
            this.n = n;
            t = new int [4 * n];
        }

    }

    Bus a [];
    Passenger p [];
    State s [];

    public void solve() throws Exception {
        int n = sc.nextInt();
        int k = sc.nextInt();
        a = new Bus [n];
        p = new Passenger [k];
        s = new State [2 * n + k];
        for (int i = 0; i < n; i++) {
            a [i] = new Bus (sc.nextInt(), sc.nextInt(), sc.nextInt(), i);
        }

        Arrays.sort(a);

        for (int i = 0; i < n; i++) {
            s [2 * i] = new State (a[i].s , 1, i);
            s [2 * i + 1] = new State (a[i].f, 3, i);
        }

        for (int i = 0; i < k; i++) {
            p [i] = new Passenger (sc.nextInt(), sc.nextInt(), sc.nextInt(), i);
            s [i + 2 * n] = new State (p[i].l, 2, i);
        }

        Arrays.sort(s);

        SegmentTreeMax tree = new SegmentTreeMax(n);

        for (int i = 0; i < s.length; i++) {
            int index = s[i].index;
            if (s[i].who == 1) {
                tree.set(index, a[index].f);
            } else if (s[i].who == 3) {
                tree.set(index, 0);
            } else {
                int time = p[index].b;
                int l = -1; int r = n;
                while (r - l > 1) {
                    int mid = (r + l) >> 1;
                    if (a[mid].t < time) l = mid; else r = mid;
                }
                int ll = l;
                int rr = n;
                while (rr - ll > 1) {
                    int mid = (rr + ll) >> 1;
                    int value = tree.get(l + 1, mid);
                    if (value >= p[index].r) {
                        rr = mid;
                    } else {
                        ll = mid;
                    }
                }
                if (rr != n) {
                    p[index].setBusno(rr);
                }
            }
        }

        for (int i = 0; i < k; i++) {
            if (p[i].busno != -1) {
                int pindex = a[p[i].busno].index + 1;
                out.print(pindex+" ");
            } else {
                out.print(-1+" ");
            }
        }

    }




    /*--------------------------------------------------------------*/

    static String filename = "";
    static boolean fromFile = false;

    BufferedReader in;
    PrintWriter out;
    FastScanner sc;

    public static void main(String[] args) {
        new Thread(null, new Solution(), "", 1 << 25).start();
    }

    public void run() {
        try {
            init();
            solve();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            out.close();
        }
    }

    void init() throws Exception {
    if (fromFile) {
    in = new BufferedReader(new FileReader(filename+".in"));
        out = new PrintWriter(new FileWriter(filename+".out"));
    } else {
    in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
    }
        sc = new FastScanner(in);
    }
}

class FastScanner {

    BufferedReader reader;
    StringTokenizer strTok;

    public FastScanner(BufferedReader reader) {
        this.reader = reader;
    }

    public String nextToken() throws IOException {
        while (strTok == null || !strTok.hasMoreTokens()) {
            strTok = new StringTokenizer(reader.readLine());
        }

        return strTok.nextToken();
    }

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

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

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

    public BigInteger nextBigInteger() throws IOException {
    return new BigInteger(nextToken());
    }

    public BigDecimal nextBigDecimal() throws IOException {
    return new BigDecimal(nextToken());
    }
}