#include <bits/stdc++.h>
using namespace std;
struct line {
  long x;
  long y;
  long r;
};
vector<line> doc, ngang;
long gtnn(long a, long b, long c, long d) { return min(a, min(b, min(c, d))); }
long tinh(long x_1, long y_1, long r_1, long x_2, long y_2, long r_2) {
  if (y_1 > y_2 || y_1 + r_1 < y_2 || x_2 > x_1 || x_2 + r_2 < x_1) return 0;
  long a, b;
  a = x_1, b = y_2;
  return gtnn(abs(x_1 - x_2), abs(x_2 + r_2 - x_1), abs(y_2 - y_1),
              abs(y_1 + r_1 - y_2));
}
int main() {
  long n, m;
  cin >> n >> m;
  doc.assign(n, line());
  ngang.assign(m, line());
  for (long i = 0; i < doc.size(); i++) cin >> doc[i].x >> doc[i].y >> doc[i].r;
  for (long i = 0; i < ngang.size(); i++) {
    cin >> ngang[i].x >> ngang[i].y >> ngang[i].r;
  }
  long ans = 0;
  for (long i = 0; i < doc.size(); i++)
    for (long j = 0; j < ngang.size(); j++) {
      ans = max(ans, tinh(doc[i].x, doc[i].y, doc[i].r, ngang[j].x, ngang[j].y,
                          ngang[j].r));
    }
  cout << ans;
}
