#include <bits/stdc++.h>
using namespace std;
struct FT {
  int bit[200005 + 2];
  FT() {
    for (int i = 0; i <= 200005; i++) {
      bit[i] = 0;
    }
  }
  int query(int pos) {
    int sum = 0;
    while (pos) {
      sum += bit[pos];
      pos -= (pos & -pos);
    }
    return sum;
  }
  void update(int pos, int x) {
    while (pos <= 200005) {
      bit[pos] += x;
      pos += (pos & -pos);
    }
    return;
  }
};
struct p {
  int x1, x2, y1, y2, h;
  p() {}
  p(int b, int _x1, int _x2, int _y1) {
    if (b) {
      h = b;
      x1 = _x1;
      x2 = _x2;
      y1 = _y1;
    } else {
      y1 = _x1;
      y2 = _x2;
      x1 = _y1;
      h = 0;
    }
  }
};
map<int, int> M;
bool operator<(const p &a, const p &b) {
  if (a.x1 == b.x1) {
    if (a.h == 1 && b.h == 0) return 1;
    if (a.h == 0 && b.h == 2) return 1;
    if (a.h == 1 && b.h == 2) return 1;
    return 0;
  } else {
    return a.x1 < b.x1;
  }
}
vector<p> v;
int f(int k) {
  FT BIT;
  int n = (int)v.size();
  vector<p> v2;
  vector<int> v3;
  for (int i = 0; i < n; i++) {
    if (v[i].h == 1) {
      if (v[i].x1 + k <= v[i].x2 - k) {
        v2.push_back(p(1, v[i].x1 + k, v[i].x2 - k, v[i].y1));
        v3.push_back(v[i].y1);
      }
    } else {
      if (v[i].y1 + k <= v[i].y2 - k) {
        v2.push_back(p(0, v[i].y1 + k, v[i].y2 - k, v[i].x1));
        v3.push_back(v[i].y1 + k);
        v3.push_back(v[i].y2 - k);
      }
    }
  }
  vector<p> v4;
  for (int i = 0; i < (int)v2.size(); i++) {
    if (v2[i].h) {
      v4.push_back(p(1, v2[i].x1, v2[i].x2, v2[i].y1));
      v4.push_back(p(2, v2[i].x2, v2[i].x2, v2[i].y1));
    } else {
      v4.push_back(p(0, v2[i].y1, v2[i].y2, v2[i].x1));
    }
  }
  M.clear();
  sort(v3.begin(), v3.end());
  v3.resize(unique(v3.begin(), v3.end()) - v3.begin());
  for (int i = 0; i < (int)v3.size(); i++) {
    M[v3[i]] = i + 1;
  }
  sort(v4.begin(), v4.end());
  n = (int)v4.size();
  for (int i = 0; i < n; i++) {
    if (v4[i].h == 1) {
      BIT.update(M[v4[i].y1], 1);
    } else if (v4[i].h == 2) {
      BIT.update(M[v4[i].y1], -1);
    } else {
      int sum2 = BIT.query(M[v4[i].y2]);
      int sum1 = BIT.query(M[v4[i].y1] - 1);
      if (sum2 - sum1 >= 1) {
        return 1;
      }
    }
  }
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  int x, y, l;
  for (int i = 0; i < n; i++) {
    cin >> x >> y >> l;
    v.push_back(p(0, y, y + l, x));
  }
  for (int j = 0; j < m; j++) {
    cin >> x >> y >> l;
    v.push_back(p(1, x, x + l, y));
  }
  sort(v.begin(), v.end());
  int lo = 0, hi = 100000005, mi;
  if (!f(lo)) {
    cout << 0 << endl;
    return 0;
  }
  if (f(hi)) {
    cout << hi << endl;
    return 0;
  }
  while (hi - lo > 1) {
    mi = (lo + hi) >> 1;
    if (f(mi))
      lo = mi;
    else
      hi = mi;
  }
  cout << lo << endl;
}
