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 N = 5e5 + 10, M = 3e6 + 10, INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int a[N], n, m, in[N], out[N], idx, rnk[N];
vector<int> g[N];
int gcd(int a, int b) {
  if (!b)
    return a;
  else
    return gcd(b, a % b);
}
struct node {
  int L[N << 2], R[N << 2], maxx[N << 2], tag[N << 2], ID[N << 2];
  void push_up(int u) { maxx[u] = max(maxx[u << 1], maxx[u << 1 | 1]); }
  void build(int u, int l, int r) {
    L[u] = l, R[u] = r;
    if (l == r) return;
    int mid = l + r >> 1;
    build(u << 1, l, mid);
    build(u << 1 | 1, mid + 1, r);
    push_up(u);
  }
  void update(int u, int pos, int val, int id) {
    if (L[u] == R[u]) {
      maxx[u] = max(maxx[u], val);
      ID[u] = id;
      return;
    }
    int mid = L[u] + R[u] >> 1;
    if (pos <= mid)
      update(u << 1, pos, val, id);
    else
      update(u << 1 | 1, pos, val, id);
    push_up(u);
  }
  int querymax(int u, int ql, int qr) {
    if (ql <= L[u] && qr >= R[u]) return maxx[u];
    int mid = L[u] + R[u] >> 1;
    int Max = 0;
    if (ql <= mid) Max = max(Max, querymax(u << 1, ql, qr));
    if (qr > mid) Max = max(Max, querymax(u << 1 | 1, ql, qr));
    return Max;
  }
  int query(int u, int val, int pos) {
    if (maxx[u] < val) return -1;
    if (L[u] == R[u]) return ID[u];
    int mid = L[u] + R[u] >> 1;
    if (mid >= pos) {
      int tmp = query(u << 1, val, pos);
      if (tmp > 0) return tmp;
    }
    return query(u << 1 | 1, val, pos);
  }
} st;
struct Q {
  int l, r, t;
  int id;
  bool operator<(const Q &rhs) const {
    if (l == rhs.l) return id < rhs.id;
    return l < rhs.l;
  }
} bus[N], people[N], q[N];
vector<int> ve;
int ans[N];
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> bus[i].l >> bus[i].r >> bus[i].t;
    ve.push_back(bus[i].t);
    bus[i].id = i;
    q[i] = bus[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> people[i].l >> people[i].r >> people[i].t;
    ve.push_back(people[i].t);
    people[i].id = i + n;
    q[i + n] = people[i];
  }
  sort(ve.begin(), ve.end());
  ve.erase(unique(ve.begin(), ve.end()), ve.end());
  sort(q + 1, q + n + m + 1);
  st.build(1, 1, n + m);
  for (int i = 1; i <= n + m; i++) {
    int t = lower_bound(ve.begin(), ve.end(), q[i].t) - ve.begin() + 1;
    if (q[i].id <= n) {
      st.update(1, t, q[i].r, q[i].id);
    } else {
      ans[q[i].id - n] = st.query(1, q[i].r, t);
    }
  }
  for (int i = 1; i <= m; i++) printf("%d ", ans[i]);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
