#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int n, m;
struct node {
  int l;
  int r;
  int t;
  int id;
} a[2 * N + 5];
bool cmp(const node &x, const node &y) {
  if (x.l == y.l)
    return x.id < y.id;
  else
    return x.l < y.l;
}
int cnt;
int Hash[2 * N + 5];
int maxv[8 * N + 5];
int ID[8 * N + 5];
void pushup(int k, int l, int r) {
  maxv[k] = max(maxv[k << 1], maxv[k << 1 | 1]);
}
void build(int k, int l, int r) {
  if (l == r) {
    maxv[k] = -1;
    return;
  }
  int mid = (l + r) >> 1;
  build(k << 1, l, mid);
  build(k << 1 | 1, mid + 1, r);
  pushup(k, l, r);
}
void update(int k, int l, int r, int x, int v, int id) {
  if (l == r && l == x) {
    maxv[k] = v;
    ID[k] = id;
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    update(k << 1, l, mid, x, v, id);
  else
    update(k << 1 | 1, mid + 1, r, x, v, id);
  pushup(k, l, r);
}
int query(int k, int l, int r, int x, int y, int v) {
  if (l == r) return ID[k];
  int res = 0;
  int mid = (l + r) >> 1;
  if (x <= mid && maxv[k << 1] >= v) res += query(k << 1, l, mid, x, y, v);
  if (res == 0 && maxv[k << 1 | 1] >= v && mid < y)
    res += query(k << 1 | 1, mid + 1, r, x, y, v);
  return res;
}
int ans[2 * N + 5];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n + m; i++) {
    scanf("%d%d%d", &a[i].l, &a[i].r, &a[i].t);
    a[i].id = i;
    Hash[++cnt] = a[i].t;
  }
  sort(a + 1, a + cnt + 1, cmp);
  sort(Hash + 1, Hash + cnt + 1);
  int len = unique(Hash + 1, Hash + cnt + 1) - (Hash + 1);
  build(1, 1, n + m);
  for (int i = 1; i <= n + m; i++) {
    int index = lower_bound(Hash + 1, Hash + len + 1, a[i].t) - Hash;
    if (a[i].id <= n) {
      update(1, 1, cnt, index, a[i].r, a[i].id);
    } else {
      int get = query(1, 1, cnt, index, cnt, a[i].r);
      ans[a[i].id - n] = ((get == 0) ? -1 : get);
    }
  }
  for (int i = 1; i <= m; i++) printf("%d\n", ans[i]);
  return 0;
}
