#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define fi first
#define se second
typedef long long ll;
vector<int> seg, cop;
int cc(int k){
return lower_bound(cop.begin(), cop.end(), k) - cop.begin() + 1;
}
void upd(int v, int tl, int tr, int pos, int val){
seg[v] += val;
if (tl == tr) return;
int tm = (tl + tr) / 2;
if (tm >= pos) upd(2*v, tl, tm, pos, val);
else upd(2*v+1, tm+1, tr, pos, val);
}
int query(int v, int tl, int tr, int l, int r){
if (r < l) return 0;
if (tl == l && tr == r) return seg[v];
int tm = (tl + tr) / 2;
return query(2*v, tl, tm, l, min(tm, r)) + query(2*v+1, tm+1, tr, max(tm+1, l), r);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, m;
cin >> n >> m;
vector<pair<pii, pii> > q;
for (int i=0; i<n; i++){
int x1, x2, y;
cin >> x1 >> x2 >> y;
q.push_back({{x1, 0}, {y, 1}});
q.push_back({{x2, 1e9}, {y, -1}});
cop.push_back(y);
}
for (int i=0; i<m; i++){
int x, y1, y2;
cin >> x >> y1 >> y2;
q.push_back({{x, i+1}, {y1, y2}});
cop.push_back(y1);
cop.push_back(y2);
}
sort(q.begin(), q.end());
sort(cop.begin(), cop.end());
cop.erase(unique(cop.begin(), cop.end()), cop.end());
seg.assign(4*cop.size(), 0);
pii maxi = {0, 0};
for (auto cur : q){
if (cur.fi.se && cur.fi.se < 1e9){
int val = query(1, 1, cop.size(), cc(cur.se.fi), cc(cur.se.se));
maxi = min(maxi, {val*-1, cur.fi.se});
}
else{
upd(1, 1, cop.size(), cc(cur.se.fi), cur.se.se);
}
}
cout << maxi.se;
}