#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5, M = 100000 + 5;
const bool T_BUS = false, T_PERSON = true;
const int EVENT = N + M;
const int SIZELS = EVENT * 2;
int n, m;
struct Event {
  bool type;
  int id;
  int l, r, t;
  inline bool operator<(const Event &b) const {
    if (r != b.r) return r > b.r;
    return type == T_BUS && b.type == T_PERSON;
  }
};
Event event[EVENT];
int ans[M];
int ls[SIZELS], cnt_ls;
map<int, int> bit[SIZELS];
inline void b_insert(int p, int t, int id) {
  for (; p <= cnt_ls; p += (p & -p)) {
    bit[p][t] = id;
  }
}
inline int b_query(int p, int t) {
  int ret = 0x3f3f3f3f, retid = -1;
  for (; p; p ^= (p & -p)) {
    map<int, int>::iterator it = bit[p].lower_bound(t);
    if (it == bit[p].end()) continue;
    if (it->first < ret) {
      ret = it->first;
      retid = it->second;
    }
  }
  return retid;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    event[i].type = T_BUS;
    event[i].id = i;
    scanf("%d%d%d", &event[i].l, &event[i].r, &event[i].t);
  }
  for (int i = n + 1; i <= n + m; ++i) {
    event[i].type = T_PERSON;
    event[i].id = i - n;
    scanf("%d%d%d", &event[i].l, &event[i].r, &event[i].t);
  }
  for (int i = 1; i <= n + m; ++i) {
    ls[++cnt_ls] = event[i].l;
    ls[++cnt_ls] = event[i].r;
  }
  sort(ls + 1, ls + cnt_ls + 1);
  cnt_ls = unique(ls + 1, ls + cnt_ls + 1) - ls - 1;
  for (int i = 1; i <= n + m; ++i) {
    event[i].l = lower_bound(ls + 1, ls + cnt_ls + 1, event[i].l) - ls;
    event[i].r = lower_bound(ls + 1, ls + cnt_ls + 1, event[i].r) - ls;
  }
  sort(event + 1, event + n + m + 1);
  for (int i = 1; i <= n + m; ++i) {
    if (event[i].type == T_BUS) {
      b_insert(event[i].l, event[i].t, event[i].id);
    } else {
      ans[event[i].id] = b_query(event[i].l, event[i].t);
    }
  }
  for (int i = 1; i <= m; ++i) printf("%d ", ans[i]);
  putchar('\n');
  return 0;
}
