#include <bits/stdc++.h>
const long long inf = 2000000000LL;
using namespace std;
const int md = 1000000007;
struct Man {
 public:
  int l, r, b, id;
  Man() {}
  Man(int _l, int _r, int _b, int _id) : l(_l), r(_r), b(_b), id(_id) {}
};
struct Bus {
 public:
  int s, f, t;
  Bus() {}
  Bus(int _s, int _f, int _t) : s(_s), f(_f), t(_t) {}
};
bool cmp_Man(Man x, Man y) { return x.l < y.l; }
bool cmp_Bus(Bus x, Bus y) { return x.s < y.s; }
map<int, int> t_b, tn;
int f_max[400001], tt[100001], res[100001];
vector<Bus> bus;
vector<Man> man;
int go(int v, int l, int r, int gg) {
  if (l == r) {
    if (f_max[v] >= gg) return l;
    return -1;
  }
  int t = (l + r) >> 1;
  if (f_max[2 * v] >= gg)
    return go(2 * v, l, t, gg);
  else
    return go(2 * v + 1, t + 1, r, gg);
}
int get_min(int v, int l, int r, int ll, int rr, int gg) {
  if (l == r) {
    if (f_max[v] >= gg) return l;
    return -1;
  }
  if (l == ll && r == rr) {
    return go(v, l, r, gg);
  }
  int t = (l + r) >> 1;
  if (rr <= t)
    return get_min(2 * v, l, t, ll, rr, gg);
  else if (ll > t)
    return get_min(2 * v + 1, t + 1, r, ll, rr, gg);
  int ans = -1;
  ans = get_min(2 * v, l, t, ll, t, gg);
  if (ans == -1) ans = get_min(2 * v + 1, t + 1, r, t + 1, rr, gg);
  return ans;
}
void upd(int v, int l, int r, int id, int nv) {
  if (l == r) {
    f_max[v] = nv;
    return;
  }
  int t = (l + r) >> 1;
  if (id <= t)
    upd(2 * v, l, t, id, nv);
  else
    upd(2 * v + 1, t + 1, r, id, nv);
  f_max[v] = max(f_max[2 * v], f_max[2 * v + 1]);
  return;
}
int main() {
  int n, m;
  cin >> n >> m;
  bus.clear();
  tn.clear();
  for (int i = 1; i <= n; ++i) {
    int s, f, t;
    scanf("%d %d %d", &s, &f, &t);
    Bus B(s, f, t);
    tn[t] = i;
    bus.push_back(B);
    tt[i] = t;
  }
  man.clear();
  for (int i = 1; i <= m; ++i) {
    int l, r, b;
    scanf("%d %d %d", &l, &r, &b);
    Man M(l, r, b, i);
    man.push_back(M);
  }
  sort(man.begin(), man.end(), cmp_Man);
  sort(bus.begin(), bus.end(), cmp_Bus);
  sort(tt + 1, tt + n + 1);
  t_b.clear();
  for (int i = 1; i <= n; ++i) t_b[tt[i]] = i;
  int id_m = 0, id_b = 0;
  for (;;) {
    if (id_m == (int)(man).size() && id_b == (int)(bus).size()) break;
    bool m = false;
    if (id_m < (int)(man).size() &&
        (id_b == (int)(bus).size() || man[id_m].l < bus[id_b].s))
      m = true;
    if (m) {
      int l = 1, r = n;
      while (r > l) {
        int m = (l + r) >> 1;
        if (tt[m] < man[id_m].b)
          l = m + 1;
        else
          r = m;
      }
      if (tt[r] < man[id_m].b)
        res[man[id_m].id] = -1;
      else
        res[man[id_m].id] = get_min(1, 1, n, r, n, man[id_m].r);
      if (res[man[id_m].id] != -1)
        res[man[id_m].id] = tn[tt[res[man[id_m].id]]];
      id_m++;
    } else {
      upd(1, 1, n, t_b[bus[id_b].t], bus[id_b].f);
      id_b++;
    }
  }
  for (int i = 1; i <= m; ++i) printf("%d ", res[i]);
  cout << endl;
  return 0;
}
