#include <bits/stdc++.h>
using namespace std;
char _;
const int maxN = 50000 + 5;
const int maxM = 1000 * 1000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;
const int base = 701;
const int SQ = 330;
pair<pair<int, int>, int> a[maxN], b[maxN];
vector<int> vx;
int mp(int t) { return lower_bound(vx.begin(), vx.end(), t) - vx.begin(); }
vector<pair<int, int> > v[maxN];
vector<pair<int, int> > seg[4 * maxN];
vector<int> dp[4 * maxN];
void make_dp(int ind) {
  dp[ind].push_back(-mod);
  for (int i = 0; i < (int)seg[ind].size(); i++)
    dp[ind].push_back(max(dp[ind].back(), seg[ind][i].second));
}
void build(int s, int e, int ind) {
  if (e - s == 1) {
    seg[ind] = v[s];
    sort(seg[ind].begin(), seg[ind].end());
    make_dp(ind);
    return;
  }
  int mid = (s + e) >> 1;
  build(s, mid, 2 * ind + 0);
  build(mid, e, 2 * ind + 1);
  merge(seg[2 * ind].begin(), seg[2 * ind].end(), seg[2 * ind + 1].begin(),
        seg[2 * ind + 1].end(), back_inserter(seg[ind]));
  make_dp(ind);
}
int get(int l, int r, int val, int s, int e, int ind) {
  if (l >= e || r <= s) return -mod;
  if (l <= s && e <= r) {
    int ps =
        lower_bound(seg[ind].begin(), seg[ind].end(), make_pair(val, mod)) -
        seg[ind].begin();
    return dp[ind][ps];
  }
  int mid = (s + e) >> 1;
  return max(get(l, r, val, s, mid, 2 * ind),
             get(l, r, val, mid, e, 2 * ind + 1));
}
int n, m;
bool check(int t) {
  for (int i = 0; i < m; i++) {
    if (2 * t > b[i].second) continue;
    int l = b[i].first.first + t, r = b[i].first.first + b[i].second - t + 1;
    l = mp(l);
    r = mp(r);
    int tmp = get(l, r, b[i].first.second - t, 0, vx.size(), 1);
    if (tmp >= b[i].first.second + t) return true;
  }
  return false;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i].first.first >> a[i].first.second >> a[i].second;
    vx.push_back(a[i].first.first);
  }
  for (int i = 0; i < m; i++)
    cin >> b[i].first.first >> b[i].first.second >> b[i].second;
  sort(vx.begin(), vx.end());
  vx.resize(unique(vx.begin(), vx.end()) - vx.begin());
  for (int i = 0; i < n; i++)
    v[mp(a[i].first.first)].push_back(
        {a[i].first.second, a[i].first.second + a[i].second});
  build(0, vx.size(), 1);
  int lo = 0, hi = mod;
  while (hi - lo > 1) {
    int mid = (lo + hi) >> 1;
    if (check(mid))
      lo = mid;
    else
      hi = mid;
  }
  cout << lo << endl;
  return 0;
}
