#include <bits/stdc++.h>
using namespace std;
struct oxy1 {
  long long position, down, up;
} liney[50005];
struct oxy2 {
  long long position, left, right;
} linex[50005];
long long minn(long long a, long long b, long long c, long long d) {
  a = a < b ? a : b;
  a = a < c ? a : c;
  a = a < d ? a : d;
  return a;
}
long long cross(struct oxy1 a, struct oxy2 b) {
  if (!(a.position <= b.right && a.position >= b.left && b.position >= a.down &&
        b.position <= a.up))
    return 0;
  else {
    return minn(abs(a.position - b.left), abs(a.position - b.right),
                abs(b.position - a.down), abs(b.position - a.up));
  }
}
int main() {
  long long n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    long long x, y, l;
    cin >> x >> y >> l;
    liney[i].position = x;
    liney[i].down = y;
    liney[i].up = y + l;
  }
  for (int i = 1; i <= m; i++) {
    long long x, y, l;
    cin >> x >> y >> l;
    linex[i].position = y;
    linex[i].left = x;
    linex[i].right = x + l;
  }
  long long temp = 0, maxx = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if ((temp = cross(liney[i], linex[j])) > maxx) maxx = temp;
    }
  }
  cout << maxx << endl;
}
