#include <bits/stdc++.h>
using namespace std;
const int N = 50005;
struct P {
  int l, r, v;
} xl[N], yl[N];
int n, m, id[N], Y1[N], Y2[N], mid;
bool cmp1(int x, int y) { return xl[x].v < xl[y].v; }
bool cmp2(int x, int y) { return yl[x].l + mid < yl[y].l + mid; }
bool cmp3(int x, int y) { return yl[x].r - mid < yl[y].r - mid; }
map<int, int> lzs;
bool check() {
  int i;
  for (i = 0; i < m; i++) id[i] = i;
  for (i = 0; i < n; i++) Y1[i] = i;
  for (i = 0; i < n; i++) Y2[i] = i;
  sort(id, id + m, cmp1);
  sort(Y1, Y1 + n, cmp2);
  sort(Y2, Y2 + n, cmp3);
  int j = 0, h = 0;
  lzs.clear();
  for (i = 0; i < m; i++) {
    while (j < n && yl[Y1[j]].l + mid <= xl[id[i]].v) {
      if (yl[Y1[j]].l + mid <= yl[Y1[j]].r - mid) lzs[yl[Y1[j]].v]++;
      j++;
    }
    while (h < n && yl[Y2[h]].r - mid < xl[id[i]].v) {
      if (yl[Y2[h]].l + mid <= yl[Y2[h]].r - mid) {
        lzs[yl[Y2[h]].v]--;
        if (!lzs[yl[Y2[h]].v]) lzs.erase(yl[Y2[h]].v);
      }
      h++;
    }
    if (xl[id[i]].l + mid > xl[id[i]].r - mid) continue;
    map<int, int>::iterator it = lzs.lower_bound(xl[id[i]].l + mid);
    if (it == lzs.end() || it->first > xl[id[i]].r - mid) continue;
    return true;
  }
  return false;
}
int main() {
  int i;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%d%d%d", &yl[i].v, &yl[i].l, &yl[i].r);
    yl[i].r += yl[i].l;
  }
  for (i = 0; i < m; i++) {
    scanf("%d%d%d", &xl[i].l, &xl[i].v, &xl[i].r);
    xl[i].r += xl[i].l;
  }
  int low = 0, high = 200000005;
  while (low < high - 1) {
    mid = (low + high) / 2;
    if (check())
      low = mid;
    else
      high = mid;
  }
  printf("%d\n", low);
  return 0;
}
