#include <bits/stdc++.h>
using namespace std;
const int N = 1 << 16;
struct segment {
  int base, from, to;
  segment() {}
  segment(int a, int b, int c) {
    base = a;
    from = b;
    to = c;
  }
};
int tests, current_case;
int n, m;
segment a[N], b[N];
int curr, ans;
void message(int current_case) {
  fprintf(stderr, "Case %d solved!\n", current_case);
}
int main() {
  int i, j;
  tests = 1;
  for (current_case = 1; current_case <= tests; current_case++) {
    scanf("%d %d", &n, &m);
    for (i = 1; i <= n; i++) {
      scanf("%d %d %d", &a[i].base, &a[i].from, &a[i].to);
      a[i].to += a[i].from;
    }
    for (i = 1; i <= m; i++) {
      scanf("%d %d %d", &b[i].from, &b[i].base, &b[i].to);
      b[i].to += b[i].from;
    }
    ans = 0;
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= m; j++) {
        if (a[i].base >= b[j].from && a[i].base <= b[j].to &&
            b[j].base >= a[i].from && b[j].base <= a[i].to) {
          curr = min(min(a[i].base - b[j].from, b[j].to - a[i].base),
                     min(b[j].base - a[i].from, a[i].to - b[j].base));
          ans = max(ans, curr);
        }
      }
    }
    printf("%d\n", ans);
  MESSAGE:
    message(current_case);
  }
  return 0;
}
