#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e18 + 7;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
const double PI = 2 * acos(0.0);
const double E = 2.71828;
struct seg {
  int x, y, len;
} a[50005], b[50005];
int n, m;
vector<int> open[300005], close[300005];
vector<pair<int, int> > sg[300005];
vector<int> w;
multiset<int> second;
bool f(int x) {
  w.clear();
  second.clear();
  for (int(i) = 0; (i) < (n); ++(i)) {
    if (a[i].len < x + x) {
      continue;
    }
    w.push_back(a[i].y + x);
    w.push_back(a[i].y + a[i].len - x);
  }
  for (int(i) = 0; (i) < (m); ++(i)) {
    if (b[i].len < x + x) {
      continue;
    }
    w.push_back(b[i].y);
  }
  sort((w).begin(), (w).end());
  w.erase(unique((w).begin(), (w).end()), w.end());
  for (int(i) = 0; (i) < (w.size()); ++(i)) {
    open[i].clear();
    close[i].clear();
    sg[i].clear();
  }
  for (int(i) = 0; (i) < (n); ++(i)) {
    if (a[i].len < x + x) {
      continue;
    }
    int idFirst = lower_bound((w).begin(), (w).end(), a[i].y + x) - w.begin();
    int idSecond =
        lower_bound((w).begin(), (w).end(), a[i].y + a[i].len - x) - w.begin();
    open[idFirst].push_back(a[i].x);
    close[idSecond].push_back(a[i].x);
  }
  for (int(i) = 0; (i) < (m); ++(i)) {
    if (b[i].len < x + x) {
      continue;
    }
    int id = lower_bound((w).begin(), (w).end(), b[i].y) - w.begin();
    sg[id].push_back(make_pair(b[i].x + x, b[i].x + b[i].len - x));
  }
  for (int(i) = 0; (i) < (w.size()); ++(i)) {
    for (int(j) = 0; (j) < (open[i].size()); ++(j)) {
      second.insert(open[i][j]);
    }
    for (int(j) = 0; (j) < (sg[i].size()); ++(j)) {
      int x = sg[i][j].first, y = sg[i][j].second;
      multiset<int>::iterator it = second.lower_bound(x);
      if (it != second.end() && *it <= y) {
        return true;
      }
    }
    for (int(j) = 0; (j) < (close[i].size()); ++(j)) {
      second.erase(second.lower_bound(close[i][j]));
    }
  }
  return false;
}
int main(void) {
  scanf("%d %d", &n, &m);
  for (int(i) = 0; (i) < (n); ++(i)) {
    scanf("%d %d %d", &a[i].x, &a[i].y, &a[i].len);
  }
  for (int(i) = 0; (i) < (m); ++(i)) {
    scanf("%d %d %d", &b[i].x, &b[i].y, &b[i].len);
  }
  int l = 0, r = mod / 2;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (f(m))
      l = m;
    else
      r = m;
  }
  printf("%d\n", l);
  return 0;
}
