#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
template <class T>
inline T sqr(T x) {
  return x * x;
}
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = (int)1e5 + 10;
const int INF = (int)1e9;
struct event {
  int l, r, t, id;
  event() : l(0), r(0), t(0), id(0) {}
  event(int l, int r, int t, int id) : l(l), r(r), t(t), id(id) {}
  const bool operator<(const event &e) const {
    return l < e.l || l == e.l && id < e.id;
  }
};
int T[4 * maxn], num[maxn], res[maxn];
void update(int l, int r, int pos, int val, int idx) {
  if (r < pos || pos < l) return;
  if (l == r) {
    T[idx] = val;
  } else {
    int m = (l + r) >> 1;
    update(l, m, pos, val, 2 * idx);
    update(m + 1, r, pos, val, 2 * idx + 1);
    T[idx] = max(T[2 * idx], T[2 * idx + 1]);
  }
}
int get(int l, int r, int pos, int val, int idx) {
  if (pos <= l) {
    if (T[idx] < val) return -1;
    if (l == r) return l;
    int m = (l + r) >> 1;
    if (T[2 * idx] >= val) return get(l, m, pos, val, 2 * idx);
    return get(m + 1, r, pos, val, 2 * idx + 1);
  } else {
    int m = (l + r) >> 1;
    if (pos >= m + 1) {
      return get(m + 1, r, pos, val, 2 * idx + 1);
    } else {
      int ret = get(l, m, pos, val, 2 * idx);
      if (ret != -1) return ret;
      return get(m + 1, r, pos, val, 2 * idx + 1);
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x;
  vector<event> e(n + m);
  for (int i = 0; i < n; i++) {
    int l, r, t;
    scanf("%d%d%d", &l, &r, &t);
    e[i] = event(l, r, t, 0);
    x.push_back(t);
  }
  sort((x).begin(), (x).end());
  for (int i = 0; i < n; i++) {
    int pos = lower_bound((x).begin(), (x).end(), e[i].t) - x.begin();
    num[pos] = i + 1;
  }
  for (int i = 0; i < m; i++) {
    int l, r, t;
    scanf("%d%d%d", &l, &r, &t);
    e[i + n] = event(l, r, t, i + 1);
  }
  sort((e).begin(), (e).end());
  for (int i = 0; i < n + m; i++) {
    if (e[i].id) {
      int pos = lower_bound((x).begin(), (x).end(), e[i].t) - x.begin();
      if (pos == n) {
        res[e[i].id] = -1;
        continue;
      }
      int t = get(0, n - 1, pos, e[i].r, 1);
      if (t == -1) {
        res[e[i].id] = -1;
      } else {
        res[e[i].id] = num[t];
      }
    } else {
      int pos = lower_bound((x).begin(), (x).end(), e[i].t) - x.begin();
      update(0, n - 1, pos, e[i].r, 1);
    }
  }
  for (int i = 1; i <= m; i++) {
    printf("%d ", res[i]);
  }
  return 0;
}
