#include <bits/stdc++.h>
using namespace std;
struct line {
  long long x, y, r;
};
bool ss(line a, line b) { return a.x < b.x; }
long long n, m, ans;
line r[1500], c[1500];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> c[i].x >> c[i].y >> c[i].r;
  }
  ans = 0;
  for (int i = 0; i < m; i++) {
    cin >> r[i].x >> r[i].y >> r[i].r;
    for (int j = 0; j < n; j++) {
      if ((r[i].y - c[j].y) * (r[i].y - (c[j].y + c[j].r)) < 0 &&
          (r[i].x - c[j].x) * ((r[i].x + r[i].r) - c[j].x) < 0) {
        ans = max(
            ans,
            min(min(abs(r[i].y - c[j].y), abs(r[i].y - (c[j].y + c[j].r))),
                min(abs(r[i].x - c[j].x), abs((r[i].x + r[i].r) - c[j].x))));
      }
    }
  }
  cout << ans;
}
