#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void chkmin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline void chkmax(T &a, T b) {
  if (a < b) a = b;
}
int x[110000], y[110000], len[110000];
int N, M;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    q;
set<int> st;
bool possible(int r) {
  int i, u;
  set<int>::iterator it, jt;
  q = priority_queue<pair<int, int>, vector<pair<int, int> >,
                     greater<pair<int, int> > >();
  st.clear();
  for (i = 0; i < N; i++) {
    if (len[i] < r * 2) continue;
    q.push(pair<int, int>(x[i], i + 110000));
  }
  for (i = N; i < N + M; i++) {
    if (len[i] < r * 2) continue;
    q.push(pair<int, int>(x[i] + r, i));
    q.push(pair<int, int>(x[i] + len[i] - r, i + 110000 * 2));
  }
  while (!q.empty()) {
    u = q.top().second;
    q.pop();
    if (u < 110000) {
      st.insert(y[u]);
    } else if (u < 110000 * 2) {
      u -= 110000;
      it = st.lower_bound(y[u] + r);
      jt = st.upper_bound(y[u] + len[u] - r);
      if (it != jt) return true;
    } else {
      u -= 110000 * 2;
      st.erase(y[u]);
    }
  }
  return false;
}
int main() {
  int i, high, low, mid;
  scanf("%d%d", &N, &M);
  for (i = 0; i < N + M; i++) scanf("%d%d%d", &x[i], &y[i], &len[i]);
  low = 0;
  high = 100000000;
  while (high > low + 1) {
    mid = (high + low) / 2;
    if (possible(mid))
      low = mid;
    else
      high = mid;
  }
  if (possible(high))
    printf("%d\n", high);
  else
    printf("%d\n", low);
  return 0;
}
