#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::lower_bound;
using std::make_pair;
using std::min;
using std::numeric_limits;
using std::pair;
using std::set;
using std::sort;
using std::unique;
using std::vector;
int n;
const int maxn = 100000;
int m;
const int maxm = 100000;
struct data {
  int left, right, time, id;
};
vector<data> bus;
vector<data> citizen;
vector<int> result;
vector<set<pair<int, int>>> seg_tree;
int seg_size;
void make_tree(int size) {
  seg_size = 1;
  while (seg_size < size + 2) seg_size <<= 1;
  seg_tree.resize(seg_size << 1);
}
void update_point(int p, pair<int, int> value) {
  for (p = p + seg_size + 1; p; p >>= 1) seg_tree[p].insert(value);
}
pair<int, int> query_seg(int lhs, int rhs, int time) {
  pair<int, int> result(numeric_limits<int>::max(), -2);
  for (lhs = lhs + seg_size, rhs = rhs + seg_size + 2; lhs ^ rhs ^ 1;
       lhs >>= 1, rhs >>= 1) {
    if (~lhs & 1) {
      const auto& it = seg_tree[lhs ^ 1].lower_bound(make_pair(time, -2));
      if (it != seg_tree[lhs ^ 1].end()) result = min(result, *it);
    }
    if (rhs & 1) {
      const auto& it = seg_tree[rhs ^ 1].lower_bound(make_pair(time, -2));
      if (it != seg_tree[rhs ^ 1].end()) result = min(result, *it);
    }
  }
  return result;
}
void discretization() {
  vector<int> point;
  point.reserve((n + m) << 1);
  for (const data& t : bus) {
    point.push_back(t.left);
    point.push_back(t.right);
  }
  for (const data& t : citizen) {
    point.push_back(t.left);
    point.push_back(t.right);
  }
  sort(point.begin(), point.end());
  point.erase(unique(point.begin(), point.end()), point.end());
  for (data& t : bus) {
    t.left = lower_bound(point.begin(), point.end(), t.left) - point.begin();
    t.right = lower_bound(point.begin(), point.end(), t.right) - point.begin();
  }
  for (data& t : citizen) {
    t.left = lower_bound(point.begin(), point.end(), t.left) - point.begin();
    t.right = lower_bound(point.begin(), point.end(), t.right) - point.begin();
  }
  make_tree(point.size());
}
int main() {
  cin >> n >> m;
  bus.resize(n);
  for (int i = 0; i != n; ++i) {
    cin >> bus[i].left >> bus[i].right >> bus[i].time;
    bus[i].id = i;
  }
  citizen.resize(m);
  for (int i = 0; i != m; ++i) {
    cin >> citizen[i].left >> citizen[i].right >> citizen[i].time;
    citizen[i].id = i;
  }
  discretization();
  sort(bus.begin(), bus.end(),
       [](const data& lhs, const data& rhs) { return lhs.left < rhs.left; });
  sort(citizen.begin(), citizen.end(),
       [](const data& lhs, const data& rhs) { return lhs.left < rhs.left; });
  result.resize(m);
  for (auto i = citizen.begin(), j = bus.begin(); i != citizen.end(); ++i) {
    for (; j != bus.end() && j->left <= i->left; ++j)
      update_point(j->right, make_pair(j->time, j->id));
    result[i->id] = query_seg(i->right, seg_size - 2, i->time).second + 1;
  }
  for (int i : result) cout << i << ' ';
}
