#include <bits/stdc++.h>
using namespace std;
int const M = 4e5;
int const inf = 2000000000;
int n, m, cnt, pp[M], pb[M];
pair<int, int> t[4 * M], ans[M / 2];
struct q {
  int ty, ti, l, r, id;
};
bool ct(q a, q b) {
  if (a.ti < b.ti) return true;
  if (a.ti > b.ti) return false;
  return a.ty > b.ty;
}
vector<q> a;
struct h {
  int ty, v, id, w;
};
bool cl(h a, h b) { return a.v < b.v; }
void u(int v, int fl, int rl, int p, pair<int, int> val) {
  if (fl == rl)
    t[v] = val;
  else {
    int mi = (fl + rl) / 2;
    if (p <= mi)
      u(v * 2 + 1, fl, mi, p, val);
    else
      u(v * 2 + 2, mi + 1, rl, p, val);
    t[v].first = max(t[v * 2 + 1].first, t[v * 2 + 2].first);
  }
}
void go(int v, int fl, int rl, int mr, int id) {
  if (fl == rl) {
    if (t[v].first >= mr) {
      if (fl < ans[id].first) {
        ans[id] = make_pair(fl, t[v].second);
      }
    }
  } else {
    int mi = (fl + rl) / 2;
    if (t[v * 2 + 1].first >= mr)
      go(v * 2 + 1, fl, mi, mr, id);
    else
      go(v * 2 + 2, mi + 1, rl, mr, id);
  }
}
void g(int v, int fl, int rl, int l, int r, int mr, int id) {
  if (l > r) return;
  if (fl == l && rl == r) {
    go(v, fl, rl, mr, id);
  } else {
    int mi = (fl + rl) / 2;
    g(v * 2 + 1, fl, mi, l, min(r, mi), mr, id);
    g(v * 2 + 2, mi + 1, rl, max(mi + 1, l), r, mr, id);
  }
}
vector<h> b;
vector<q> in[M], out[M], qu[M];
int main() {
  for (int i = 0; i < 4 * M; ++i) t[i] = make_pair(-1, -1);
  for (int i = 0; i < M / 2; ++i) ans[i] = make_pair(inf, -1);
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    q nq;
    scanf("%d%d%d", &nq.l, &nq.r, &nq.ti);
    nq.ty = 1;
    nq.id = i + 1;
    a.push_back(nq);
    h nh;
    nh.id = i + 1;
    nh.v = nq.l;
    nh.ty = 1;
    nh.w = 1;
    b.push_back(nh);
    nh.w = 2;
    nh.v = nq.r;
    b.push_back(nh);
  }
  for (int i = 0; i < m; ++i) {
    q nq;
    scanf("%d%d%d", &nq.l, &nq.r, &nq.ti);
    nq.ty = 2;
    nq.id = i + 1;
    a.push_back(nq);
    h nh;
    nh.id = i + 1;
    nh.v = nq.l;
    nh.ty = 2;
    nh.w = 1;
    b.push_back(nh);
    nh.v = nq.r;
    nh.w = 2;
    b.push_back(nh);
  }
  cnt = 0;
  sort(a.begin(), a.end(), ct);
  vector<int> nt;
  int dt;
  for (int i = 0; i < a.size(); ++i) {
    if (i > 0 && a[i].ti != a[i - 1].ti) ++cnt;
    nt.push_back(cnt);
    if (a[i].ty == 1)
      pb[a[i].id] = i;
    else
      pp[a[i].id] = i;
  }
  dt = cnt;
  for (int i = 0; i < a.size(); ++i) a[i].ti = nt[i];
  nt.clear();
  sort(b.begin(), b.end(), cl);
  cnt = 0;
  for (int i = 0; i < b.size(); ++i) {
    if (i > 0 && b[i].v != b[i - 1].v) ++cnt;
    nt.push_back(cnt);
  }
  for (int i = 0; i < nt.size(); ++i) {
    if (b[i].ty == 1) {
      if (b[i].w == 1)
        a[pb[b[i].id]].l = nt[i];
      else
        a[pb[b[i].id]].r = nt[i];
    } else {
      if (b[i].w == 1)
        a[pp[b[i].id]].l = nt[i];
      else
        a[pp[b[i].id]].r = nt[i];
    }
  }
  for (int i = 0; i < a.size(); ++i) {
    if (a[i].ty == 2)
      qu[a[i].l].push_back(a[i]);
    else
      in[a[i].l].push_back(a[i]);
  }
  int sz = b.size();
  for (int i = 0; i < sz; ++i) {
    for (int j = 0; j < in[i].size(); ++j) {
      u(0, 0, dt, in[i][j].ti, make_pair(in[i][j].r, in[i][j].id));
      out[in[i][j].r].push_back(in[i][j]);
    }
    for (int j = 0; j < qu[i].size(); ++j) {
      g(0, 0, dt, qu[i][j].ti, dt, qu[i][j].r, qu[i][j].id);
    }
    for (int j = 0; j < out[i].size(); ++j) {
      u(0, 0, dt, out[i][j].ti, make_pair(-1, -1));
    }
  }
  for (int i = 1; i <= m; ++i) printf("%d\n", ans[i].second);
  return 0;
}
