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

public class Main {

	BufferedReader in;
	StringTokenizer str = null;
	PrintWriter out;
	
	private String next() throws Exception{
		while (str == null || !str.hasMoreElements())
			str = new StringTokenizer(in.readLine());
		return str.nextToken();
	}
	
	private int nextInt() throws Exception{
		return Integer.parseInt(next());
	}
	
	private long nextLong() throws Exception{
		return Long.parseLong(next());
	}
	
	private double nextDouble() throws Exception{
		return Double.parseDouble(next());
	}
	
	int []s,f,t;
	int []l,r,b;
	SegmentTree tree;
	Event []e;
	Map<Integer, Integer> map;

	int []x;

	public void run() throws Exception{
		in =  new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		int n = nextInt(), m = nextInt();

		x = new int[n + m];
		int atx = 0;

		s = new int[n];
		f = new int[n];
		t = new int[n];
		
		int at = 0;
		e = new Event[n + m];

		for(int i = 0; i < n; ++i) {
			s[i] = nextInt();
			f[i] = nextInt();
			t[i] = nextInt();
			x[atx++] = t[i];
			e[at++] = new Event(s[i], f[i], t[i], 0, i + 1);
		}
		l = new int[m];
		r = new int[m];
		b = new int[m];
		for(int i = 0; i < m; ++i) {
			l[i] = nextInt();
			r[i] = nextInt();
			b[i] = nextInt();
			x[atx++] = b[i];
			e[at++] = new Event(l[i], r[i], b[i], 1, i);
		}

		Arrays.sort(x);
		Arrays.sort(e);
		int id = 0;
		map = new HashMap<Integer, Integer>();
		for(int i = 0; i < x.length; ++i) {
			if (!map.containsKey(x[i])) {
				map.put(x[i], id++);
			}
		}

		tree = new SegmentTree(id);

		int []a = new int[m];
		Arrays.fill(a, -1);

		for(int i = 0; i < n + m; ++i) {
			int time = map.get(e[i].time);
			// System.out.println(e[i]);
			// System.out.println("compressed time = " + time + " time = " + + e[i].time);
			if (e[i].type == 0) {
				// System.out.println("update query");
				tree.update(time, new Node(e[i].id, e[i].r));
				// System.out.println("interval = [" + time + " " + (id-1) + "]");
				// System.out.println("after update " + tree.query(time, id-1, e[i].r));
			}else {
				// System.out.println("interval = [" + time + " " + (id-1) + "]");
				Node bs = tree.query(time, id-1, e[i].r);
				// System.out.println("get query (" + bs + ")");
				if (bs.max >= e[i].r) {
					// a[e[i].id] = bus.get(bs.id);	
					a[e[i].id] = bs.id;
				}
			}
			// System.out.println();
		}
		for(int i = 0; i < m; ++i) {
			out.print(a[i] + " ");
		}
		out.println();
		out.close();
	}

	class Event implements Comparable<Event>{
		int l, r, time, type, id;
		public Event(int l, int r, int time, int type, int id) {
			this.l = l;
			this.r = r;
			this.time = time;
			this.type = type;
			this.id = id;
		}

		public int compareTo(Event e) {
			if (this.l < e.l) return -1;
			if (this.l > e.l) return 1;
			if (this.type < e.type) return -1;
			if (this.type > e.type) return 1;
			return this.r - e.r;
		}

		public String toString() {
			return this.type + " " + this.l + " " + this.r + " " + this.time;	
		}
	}

	final static int oo = Integer.MAX_VALUE/2;

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

		private Node merge(Node left, Node right) {
			if (left.max < right.max) return right;
			return left;
		}

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

		private void update(int v, int tl, int tr, int pos, Node val) {
			if (tl == tr) {
				tree[v] = merge(tree[v], val);
				// System.out.println("in v=" + v + " with value " + val);
				return;
			}
			int tm = (tl + tr) / 2;
			if (pos <= tm) {
				update(2 * v, tl, tm, pos, val);
			}else {
				update(2 * v + 1, tm + 1, tr, pos, val);
			}
			tree[v] = merge(tree[2 * v], tree[2 * v + 1]);
		}

		public Node query(int l, int r, int right) {
			return query(1, 0, n - 1, l, r, right);
		}

		private Node query(int v, int tl, int tr, int l, int r, int right) {
			if (l > r) return new Node(-1, -oo);
			if (tl == tr) {
				return tree[v];
			}
			if (tree[v].max < right) return new Node(-1, -oo);
			// if (tl == l && tr == r) {
			// 	return tree[v];
			// }
			int tm = (tl + tr) / 2;	
			// if (tree[2 * v].max >= right) {
			// 	return query(2 * v, tl, tm, l, Math.min(tm, r), right); 
			// }else if (tree[2 * v + 1].max >= right) {
			// 	return query(2 * v + 1, tm + 1, tr, Math.max(l, tm + 1), r, right);
			// }else {
			// 	return new Node(-1, -oo);
			// }
			Node left = query(2 * v, tl, tm, l, Math.min(tm, r), right); 
			if (left.max >= right) return left;
			return query(2 * v + 1, tm + 1, tr, Math.max(l, tm + 1), r, right);
		}
	}

	class Node {
		int id, max;
		public Node(int id, int max) {
			this.id = id;
			this.max = max;
		}

		public String toString() {
			return this.id + " " + this.max;
		}
	}

	public static void main(String[] args) throws Exception{
		new Main().run();
	}
}
