#include <bits/stdc++.h>
using namespace std;
const int maxn = 51234;
int n, m;
map<int, vector<pair<int, int>>> fx, fy;
bool check(int need) {
  map<int, vector<pair<int, int>>> query;
  map<int, vector<pair<int, int>>> events;
  for (auto [x, vi] : fx)
    for (auto [l, r] : vi)
      if (l + need <= r - need) query[x].emplace_back(l + need, r - need);
  for (auto [y, vi] : fy)
    for (auto [l, r] : vi)
      if (l + need <= r - need) {
        events[l + need].emplace_back(y, 1);
        events[r - need + 1].emplace_back(y, -1);
      }
  map<int, int> cnt;
  auto it = events.begin();
  for (auto [x, vi] : query) {
    while (it != events.end() && it->first <= x) {
      for (auto [y, sig] : it->second) {
        cnt[y] += sig;
        if (!cnt[y]) cnt.erase(y);
      }
      it++;
    }
    for (auto [l, r] : vi) {
      auto lb = cnt.lower_bound(l), rb = cnt.lower_bound(r + 1);
      if (lb != rb) return true;
    }
  }
  return false;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int(i) = (1); (i) <= (n); (i)++) {
    int x, y, l;
    scanf("%d%d%d", &x, &y, &l);
    fx[x].emplace_back(y, y + l);
  }
  for (int(i) = (1); (i) <= (m); (i)++) {
    int x, y, l;
    scanf("%d%d%d", &x, &y, &l);
    fy[y].emplace_back(x, x + l);
  }
  int lo = 0, hi = 1e8;
  while (lo < hi) {
    int mi = lo + hi + 1 >> 1;
    if (check(mi))
      lo = mi;
    else
      hi = mi - 1;
  }
  printf("%d", lo);
}
