#include <bits/stdc++.h>
using namespace std;
struct ww {
  int x, y, z;
} a[100010], b[100010], c[100010], d[100010];
set<int> S;
int n, mid, m;
inline bool cc1(const ww &a, const ww &b) {
  return a.x < b.x || a.x == b.x && a.z > b.z;
}
inline bool judge(int x) {
  int n1 = 0, n2 = 0;
  for (int i = 1; i <= n; i++)
    if (a[i].z / 2 >= mid) {
      c[++n1] = a[i];
      c[n1].y = a[i].y + mid;
      c[n1].z = a[i].y + a[i].z - mid;
    }
  for (int i = 1; i <= m; i++)
    if (b[i].z / 2 >= mid) {
      d[++n2].x = b[i].x + mid;
      d[n2].y = b[i].y;
      d[n2].z = 1;
      d[++n2].x = b[i].x + b[i].z - mid + 1;
      d[n2].y = b[i].y;
      d[n2].z = -1;
    }
  sort(c + 1, c + n1 + 1, cc1);
  sort(d + 1, d + n2 + 1, cc1);
  int j = 1;
  S.clear();
  for (int i = 1; i <= n1; i++) {
    for (; j <= n2 && d[j].x <= c[i].x; j++)
      if (d[j].z > 0)
        S.insert(d[j].y);
      else
        S.erase(d[j].y);
    set<int>::iterator A = S.lower_bound(c[i].y);
    if (A == S.end()) continue;
    if ((*A) <= c[i].z) return 1;
  }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z);
  for (int i = 1; i <= m; i++) scanf("%d%d%d", &b[i].x, &b[i].y, &b[i].z);
  int l, r;
  for (l = 1, r = 100000000; l <= r;) {
    mid = (l + r) / 2;
    if (judge(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%d\n", l - 1);
  return 0;
}
