#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
using namespace std;
long long spf[21];
long long fac[21];
void sieve() {
  spf[1] = 1;
  for (long long i = 2; i < 21; i++) spf[i] = i;
  for (long long i = 4; i < 21; i += 2) spf[i] = 2;
  for (long long i = 3; i * i < 21; i++) {
    if (spf[i] == i) {
      for (long long j = i * i; j < 21; j += i)
        if (spf[j] == j) spf[j] = i;
    }
  }
}
map<long long, long long> getfactor(long long a) {
  map<long long, long long> m;
  while (a > 1) {
    m[spf[a]]++;
    a /= spf[a];
  }
  return m;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0 || y < 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long inverse(long long a, long long p) { return power(a, p - 2, p); }
long long ncr(long long n, long long r, long long p) {
  if (r > n) return 0;
  if (r == 0 || r == n) return 1;
  return (fac[n] * inverse(fac[r], p) % p * inverse(fac[n - r], p) % p) % p;
}
set<pair<long long, long long> > bit[100005];
long long get(long long index, long long m) {
  long long tot = 1e18, ind = -1;
  while (index > 0) {
    auto it = bit[index].lower_bound(make_pair(m, 0));
    if (it != bit[index].end() && it->first <= tot)
      tot = it->first, ind = it->second;
    index -= index & (-index);
  }
  return ind;
}
void update(long long index, long long val, long long ind) {
  while (index <= 100000) {
    bit[index].insert(make_pair(val, ind));
    index += index & (-index);
  }
}
void solve() {
  long long n, m;
  cin >> n >> m;
  long long ans[m + 1];
  set<long long> ss;
  unordered_map<long long, long long> map;
  pair<pair<long long, long long>, pair<long long, long long> > p[n + 1],
      q[m + 1];
  for (long long i = 1; i <= n; i++) {
    long long s, f, t;
    cin >> s >> f >> t;
    p[i] = make_pair(make_pair(s, f), make_pair(t, i));
    ss.insert(f);
  }
  long long ct = 1;
  for (auto it : ss) map[it] = ct++;
  sort(p + 1, p + n + 1);
  for (long long i = 1; i <= m; i++) {
    long long s, f, t;
    cin >> s >> f >> t;
    q[i] = make_pair(make_pair(s, f), make_pair(t, i));
  }
  sort(q + 1, q + m + 1);
  long long j = 1;
  for (long long i = 1; i <= m; i++) {
    while (j <= n && p[j].first.first <= q[i].first.first) {
      update(n - map[p[j].first.second] + 1, p[j].second.first,
             p[j].second.second);
      j++;
    }
    auto it = ss.lower_bound(q[i].first.second);
    if (it != ss.end()) {
      ans[q[i].second.second] = get(n - map[*it] + 1, q[i].second.first);
    } else
      ans[q[i].second.second] = -1;
  }
  for (long long i = 1; i <= m; i++) cout << ans[i] << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long test = 1;
  while (test--) {
    solve();
  }
}
