#include <bits/stdc++.h>
using namespace std;
struct ww {
  int x, y, z;
} a[50010], b[50010];
int i, j, k, n, m, an;
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z), a[i].z += a[i].y;
  for (i = 1; i <= m; i++)
    scanf("%d%d%d", &b[i].x, &b[i].y, &b[i].z), b[i].z += b[i].x;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      an = max(an, min(min(a[i].x - b[j].x, b[j].z - a[i].x),
                       min(b[j].y - a[i].y, a[i].z - b[j].y)));
  printf("%d\n", an);
  return 0;
}
