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
#include <bits/stdc++.h>
using namespace std;
const int MAXINT = 0x7FFFFFFF;
class SEGTREE {
 private:
  struct STNODE {
    int l;
    int r;
    set<int> st;
  };
  STNODE Node[1600100];

 public:
  int build(int l, int r, int t = 1) {
    Node[t].l = l;
    Node[t].r = r;
    if (l == r) return 0;
    int mid = (l + r) / 2;
    build(l, mid, t * 2);
    build(mid + 1, r, t * 2 + 1);
    return 0;
  }
  int insert(int x, int val, int t = 1) {
    int tl = Node[t].l;
    int tr = Node[t].r;
    int mid = (tl + tr) / 2;
    Node[t].st.insert(val);
    if (tl == tr) return 0;
    if (x <= mid)
      insert(x, val, t * 2);
    else
      insert(x, val, t * 2 + 1);
    return 0;
  }
  int query(int l, int r, int val, int t = 1) {
    int tl = Node[t].l;
    int tr = Node[t].r;
    if (l <= tl && tr <= r) {
      set<int>::iterator x = Node[t].st.lower_bound(val);
      if (x == Node[t].st.end()) return MAXINT;
      return *x;
    }
    int mid = (tl + tr) / 2;
    int result = MAXINT;
    if (l <= mid) result = min(result, query(l, r, val, t * 2));
    if (r > mid) result = min(result, query(l, r, val, t * 2 + 1));
    return result;
  }
  int erase(int x, int val, int t = 1) {
    int tl = Node[t].l;
    int tr = Node[t].r;
    int mid = (tl + tr) / 2;
    set<int>::iterator it = Node[t].st.find(val);
    if (it == Node[t].st.end()) return -1;
    Node[t].st.erase(it);
    if (tl == tr) return 0;
    if (x <= mid)
      erase(x, val, t * 2);
    else
      erase(x, val, t * 2 + 1);
    return 0;
  }
};
SEGTREE Tree;
struct EVENT {
  int type;
  int l;
  int r;
  int t;
  int id;
  bool operator<(const EVENT& b) const {
    if (r != b.r) return r < b.r;
    return type > b.type;
  }
};
EVENT event[200020];
int pos[400040] = {0};
int pcnt = 0;
inline int dcpos(int x) { return 1 + lower_bound(pos, pos + pcnt, x) - pos; }
int kibus[100010] = {0};
pair<int, int> busid[100010];
int main(void) {
  int n = 0;
  int m = 0;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &event[i].l, &event[i].r, &event[i].t);
    event[i].type = 0;
    event[i].id = i + 1;
    busid[i].first = event[i].t;
    busid[i].second = event[i].id;
    pos[pcnt++] = event[i].l;
    pos[pcnt++] = event[i].r;
  }
  for (int i = n; i < n + m; i++) {
    scanf("%d %d %d", &event[i].l, &event[i].r, &event[i].t);
    event[i].type = 1;
    event[i].id = i - n;
    pos[pcnt++] = event[i].l;
    pos[pcnt++] = event[i].r;
  }
  sort(busid, busid + n);
  sort(pos, pos + pcnt);
  pcnt = unique(pos, pos + pcnt) - pos;
  Tree.build(1, pcnt);
  for (int i = 0; i < n; i++) Tree.insert(dcpos(event[i].l), event[i].t);
  sort(event, event + n + m);
  memset(kibus, -1, sizeof(kibus));
  for (int i = 0; i < n + m; i++) {
    if (event[i].type == 0) {
      Tree.erase(dcpos(event[i].l), event[i].t);
    } else {
      int p0s = dcpos(event[i].l);
      int mv = Tree.query(1, p0s, event[i].t);
      if (mv == MAXINT) continue;
      kibus[event[i].id] =
          lower_bound(busid, busid + n, make_pair(mv, -1))->second;
    }
  }
  for (int i = 0; i < m; i++) {
    printf("%d ", kibus[i]);
  }
  puts("");
  return 0;
}
