#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, inf = 0x3f3f3f3f;
struct ALTXDY {
  int tp, t, x, y, id;
  bool operator<(const ALTXDY &a) const {
    return t == a.t ? tp < a.tp : t > a.t;
  }
};
ALTXDY q[N << 1], tmp[N << 1];
int n, m, k, c[N << 2];
pair<int, int> tree[N << 1], ans[N];
void reset(int x) {
  for (; x <= k; x += (x & (-x))) tree[x] = make_pair(inf, inf);
}
void update(int x, pair<int, int> val) {
  for (; x <= k; x += (x & (-x))) tree[x] = min(tree[x], val);
}
pair<int, int> query(int x) {
  pair<int, int> ans = make_pair(inf, inf);
  for (; x >= 1; x -= (x & (-x))) ans = min(ans, tree[x]);
  return ans;
}
void cdq(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1;
  cdq(l, mid);
  cdq(mid + 1, r);
  int i = l, j = mid + 1, cnt = l - 1;
  while (i <= mid && j <= r) {
    if (q[i].x <= q[j].x) {
      tmp[++cnt] = q[i];
      if (q[i].tp == 0) update(k - q[i].y + 1, make_pair(q[i].t, q[i].id));
      i++;
    } else {
      tmp[++cnt] = q[j];
      if (q[j].tp == 1) ans[q[j].id] = min(ans[q[j].id], query(k - q[j].y + 1));
      j++;
    }
  }
  while (i <= mid) {
    tmp[++cnt] = q[i];
    i++;
  }
  while (j <= r) {
    tmp[++cnt] = q[j];
    if (q[j].tp == 1) ans[q[j].id] = min(ans[q[j].id], query(k - q[j].y + 1));
    j++;
  }
  for (int i = l; i <= r; i++) reset(k - q[i].y + 1);
  for (int i = l; i <= r; i++) q[i] = tmp[i];
}
int main() {
  memset(ans, inf, sizeof(ans));
  memset(tree, inf, sizeof(tree));
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    int t, s, f;
    scanf("%d%d%d", &s, &f, &t);
    q[i] = (ALTXDY){0, t, s, f, i};
    c[++k] = f;
  }
  for (int i = 1; i <= m; i++) {
    int b, l, r;
    scanf("%d%d%d", &l, &r, &b);
    q[i + n] = (ALTXDY){1, b, l, r, i};
    c[++k] = r;
  }
  sort(c + 1, c + 1 + k);
  k = unique(c + 1, c + 1 + k) - c - 1;
  for (int i = 1; i <= n + m; i++)
    q[i].y = lower_bound(c + 1, c + 1 + k, q[i].y) - c;
  sort(q + 1, q + 1 + n + m);
  cdq(1, n + m);
  for (int i = 1; i <= m; i++)
    if (ans[i].first == inf)
      printf("-1 ");
    else
      printf("%d ", ans[i].second);
  return 0;
}
