#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define fi first
#define se second
int st[3000009];
vector<int> cop;
int comp(int y){
return lower_bound(cop.begin(), cop.end(), y) - cop.begin() + 1;
}
void update(int v, int tl, int tr, int pos, int val){
if (tl == tr){
st[v] += val;
return;
}
int tm = (tl + tr) / 2;
if (pos <= tm){
update(2*v, tl, tm, pos, val);
}
else{
update(2*v+1, tm+1, tr, pos, val);
}
st[v] = st[2*v] + st[2*v+1];
}
int get(int v, int tl, int tr, int l, int r){
if (max(tl, l) > min(tr, r)){
return 0;
}
if (tl >= l && tr <= r){
return st[v];
}
int tm = (tl + tr) / 2;
return get(2*v, tl, tm, l, r) + get(2*v+1, tm+1, tr, l, r);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<pair<pii, pii > > obj;
cop.resize(n+2*m);
int x, y, z;
for (int i=0; i<n; i++){
cin >> x >> y >> z;
obj.push_back({{x, -1*1e5}, {z, 0}});
obj.push_back({{y, 1e5}, {z, 0}});
cop[i] = z;
}
for (int i=0; i<m; i++){
cin >> x >> y >> z;
obj.push_back({{x, i+1},{y, z}});
cop[n+2*i] = y;
cop[n+2*i+1] = z;
}
sort(cop.begin(), cop.end());
cop.erase(unique(cop.begin(), cop.end()), cop.end());
sort(obj.begin(), obj.end());
pii maxi = {0, 0};
for (auto i : obj){
if (abs(i.fi.se) == 1e5){
update(1, 1, cop.size()+1, comp(i.se.fi), i.fi.se / 1e5 * -1);
}
else{
int cur = get(1, 1, cop.size()+1, comp(i.se.fi), comp(i.se.se));
if (cur > maxi.fi){
maxi = {cur, i.fi.se};
}
}
}
cout << maxi.second;
}