#include <bits/stdc++.h>
using namespace std;
const int MAXN = 50001;
struct BIT {
  int sz;
  int crd[MAXN];
  int T[MAXN];
  BIT(int Sz = 0) : sz(Sz) {
    for (int i = 1; i <= sz; ++i) crd[i] = T[i] = 0;
  }
  void reset() {
    for (int i = 1; i <= sz; ++i) T[i] = 0;
  }
  int low(int first) { return lower_bound(crd + 1, crd + sz + 1, first) - crd; }
  int hi(int first) {
    return upper_bound(crd + 1, crd + sz + 1, first) - 1 - crd;
  }
  void up(int i, int v) {
    for (; i <= sz; i += i & (-i)) T[i] += v;
  }
  int get(int i) {
    int ans = 0;
    for (; i; i -= i & (-i)) ans += T[i];
    return ans;
  }
  int get(int l, int r) { return get(r) - get(l - 1); }
};
int N, M;
pair<int, pair<int, int> > H[MAXN], V[MAXN];
BIT T;
bool check(int value) {
  T.reset();
  multiset<pair<int, int> > In, Out;
  for (int i = 1; i <= N; ++i) {
    if (V[i].second.second - V[i].second.first < 2 * value) continue;
    In.insert(pair<int, int>(V[i].second.first + value, i));
  }
  for (int i = 1; i <= M; ++i) {
    while (In.size() && In.begin()->first <= H[i].first) {
      int num = In.begin()->second;
      In.erase(In.begin());
      T.up(T.low(V[num].first), 1);
      Out.insert(pair<int, int>(V[num].second.second - value + 1, num));
    }
    while (Out.size() && Out.begin()->first <= H[i].first) {
      int num = Out.begin()->second;
      Out.erase(Out.begin());
      T.up(T.low(V[num].first), -1);
    }
    if (H[i].second.second - H[i].second.first < 2 * value) continue;
    if (T.get(T.low(H[i].second.first + value),
              T.hi(H[i].second.second - value)) > 0)
      return 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  for (int i = 1; i <= N; ++i)
    cin >> V[i].first >> V[i].second.first >> V[i].second.second,
        V[i].second.second += V[i].second.first;
  for (int i = 1; i <= M; ++i)
    cin >> H[i].second.first >> H[i].first >> H[i].second.second,
        H[i].second.second += H[i].second.first;
  sort(H + 1, H + M + 1);
  T = BIT(N);
  for (int i = 1; i <= N; ++i) T.crd[i] = V[i].first;
  sort(T.crd + 1, T.crd + N + 1);
  int low = 1, hi = 1e9 + 1;
  while (low != hi) {
    int mid = (low + hi) >> 1;
    if (check(mid))
      low = mid + 1;
    else
      hi = mid;
  }
  cout << low - 1 << endl;
}
