#include <bits/stdc++.h>
using namespace std;
const long long maxm = 2e5 + 5;
struct E1 {
  long long s, f, t, id;
} e[maxm];
struct E2 {
  long long l, r, b, id;
} q[maxm];
bool cmp1(E1 a, E1 b) { return a.s < b.s; }
bool cmp2(E2 a, E2 b) { return a.l < b.l; }
long long a[maxm << 2], idx[maxm << 2];
long long xx[maxm], num;
long long ans[maxm];
long long n, m;
void pushup(long long node) { a[node] = max(a[node * 2], a[node * 2 + 1]); }
void update(long long x, long long val, long long idd, long long l, long long r,
            long long node) {
  if (l == r) {
    a[node] = val;
    idx[node] = idd;
    return;
  }
  long long mid = (l + r) / 2;
  if (x <= mid)
    update(x, val, idd, l, mid, node * 2);
  else
    update(x, val, idd, mid + 1, r, node * 2 + 1);
  pushup(node);
}
long long ask(long long st, long long ed, long long val, long long l,
              long long r, long long node) {
  if (a[node] < val) return -1;
  if (l == r) return idx[node];
  long long mid = (l + r) / 2;
  long long ans = -1;
  if (st <= mid) ans = ask(st, ed, val, l, mid, node * 2);
  if (ans == -1 && ed > mid) ans = ask(st, ed, val, mid + 1, r, node * 2 + 1);
  return ans;
}
signed main() {
  scanf("%d%d", &n, &m);
  for (long long i = 1; i <= n; i++) {
    scanf("%d%d%d", &e[i].s, &e[i].f, &e[i].t);
    e[i].id = i;
    xx[++num] = e[i].t;
  }
  for (long long i = 1; i <= m; i++) {
    scanf("%d%d%d", &q[i].l, &q[i].r, &q[i].b);
    q[i].id = i;
    xx[++num] = q[i].b;
  }
  sort(e + 1, e + 1 + n, cmp1);
  sort(q + 1, q + 1 + m, cmp2);
  sort(xx + 1, xx + 1 + num);
  num = unique(xx + 1, xx + 1 + num) - xx - 1;
  for (long long i = 1; i <= n; i++) {
    e[i].t = lower_bound(xx + 1, xx + 1 + num, e[i].t) - xx;
  }
  for (long long i = 1; i <= m; i++) {
    q[i].b = lower_bound(xx + 1, xx + 1 + num, q[i].b) - xx;
  }
  long long k = 1;
  for (long long i = 1; i <= m; i++) {
    while (k <= n && e[k].s <= q[i].l) {
      update(e[k].t, e[k].f, e[k].id, 1, num, 1);
      k++;
    }
    ans[q[i].id] = ask(q[i].b, num, q[i].r, 1, num, 1);
  }
  for (long long i = 1; i <= m; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
