#include <bits/stdc++.h>
using namespace std;
using std::map;
bool sortByY(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.first.second < b.first.second;
}
int main() {
  int n, m;
  int x, y, l;
  int res = 0;
  vector<pair<pair<int, int>, int> > V, H;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    scanf("%d%d%d", &x, &y, &l);
    V.push_back(make_pair(make_pair(x, y), l));
  }
  for (int i = 0; i < m; i++) {
    scanf("%d%d%d", &x, &y, &l);
    H.push_back(make_pair(make_pair(x, y), l));
  }
  sort(H.begin(), H.end(), sortByY);
  for (int v = 0; v < n; v++) {
    int low = V[v].first.second;
    int high = V[v].first.second + V[v].second;
    int l = 0;
    int r = m - 1;
    int mid;
    int w = -1;
    while (l <= r) {
      mid = (l + r) / 2;
      if (H[mid].first.second >= low && H[mid].first.second <= high) {
        w = mid;
        break;
      } else if (H[mid].first.second < low)
        l = mid + 1;
      else
        r = mid - 1;
    }
    if (w == -1) continue;
    int up, down, left, right;
    for (int i = w; i >= 0 && H[i].first.second - low > res; i--) {
      up = high - H[i].first.second;
      down = H[i].first.second - low;
      left = V[v].first.first - H[i].first.first;
      right = H[i].first.first + H[i].second - V[v].first.first;
      if (left <= 0 || right <= 0) continue;
      int ans = min(min(up, down), min(left, right));
      res = max(ans, res);
    }
    for (int i = w + 1; i < m && high - H[i].first.second > res; i++) {
      up = high - H[i].first.second;
      down = H[i].first.second - low;
      left = V[v].first.first - H[i].first.first;
      right = H[i].first.first + H[i].second - V[v].first.first;
      if (left <= 0 || right <= 0) continue;
      int ans = min(min(up, down), min(left, right));
      res = max(ans, res);
    }
  }
  cout << res;
  return 0;
}
