#include <bits/stdc++.h>
using namespace std;
struct segment {
  int x, y, l;
};
struct event {
  int x, type, id;
  bool operator<(const event& other) const {
    if (x != other.x) {
      return x < other.x;
    }
    if (type != other.type) {
      return type < other.type;
    }
    if (id != other.id) {
      return id < other.id;
    }
    return false;
  }
};
vector<int> t;
void update(int pos, int val, int n) {
  pos += n;
  t[pos] = val;
  for (pos >>= 1; pos; pos >>= 1) {
    t[pos] = t[pos * 2] + t[pos * 2 + 1];
  }
}
int get(int l, int r, int n) {
  int ans = 0;
  for (l += n, r += n; l <= r; l = (l + 1) >> 1, r = (r - 1) >> 1) {
    if (l & 1) {
      ans += t[l];
    }
    if (!(r & 1)) {
      ans += t[r];
    }
  }
  return ans;
}
bool check(vector<segment>& hor, vector<segment>& ver) {
  int n = static_cast<int>((hor).size());
  vector<int> v(n);
  for (int i = 0; i < n; ++i) {
    v[i] = hor[i].y;
  }
  sort((v).begin(), (v).end());
  v.resize(unique((v).begin(), (v).end()) - v.begin());
  int N = static_cast<int>((v).size());
  t.assign(2 * N, 0);
  vector<event> events;
  for (int i = 0; i < n; ++i) {
    hor[i].y = lower_bound((v).begin(), (v).end(), hor[i].y) - v.begin();
    event e = {hor[i].x, 0, i};
    events.push_back(e);
    e = {hor[i].x + hor[i].l, 2, i};
    events.push_back(e);
  }
  for (int i = 0; i < static_cast<int>((ver).size()); ++i) {
    event e = {ver[i].x, 1, i};
    events.push_back(e);
  }
  sort((events).begin(), (events).end());
  for (event& e : events) {
    if (e.type == 0) {
      update(hor[e.id].y, 1, N);
    } else if (e.type == 2) {
      update(hor[e.id].y, 0, N);
    } else {
      int l = lower_bound((v).begin(), (v).end(), ver[e.id].y) - v.begin();
      int r = upper_bound((v).begin(), (v).end(), ver[e.id].y + ver[e.id].l) -
              v.begin() - 1;
      if (l == N || l > r) {
        continue;
      }
      int ans = get(l, r, N);
      if (ans) {
        return true;
      }
    }
  }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<segment> hor(m), ver(n);
  for (int i = 0; i < n; ++i) {
    cin >> ver[i].x >> ver[i].y >> ver[i].l;
  }
  for (int i = 0; i < m; ++i) {
    cin >> hor[i].x >> hor[i].y >> hor[i].l;
  }
  int l = 0, r = 1e8 + 100;
  while (l != r - 1) {
    int middle = (l + r) >> 1;
    vector<segment> v, h;
    for (int i = 0; i < n; ++i) {
      if (ver[i].l >= 2 * middle) {
        segment tmp = {ver[i].x, ver[i].y + middle, ver[i].l - 2 * middle};
        v.push_back(tmp);
      }
    }
    for (int i = 0; i < m; ++i) {
      if (hor[i].l >= 2 * middle) {
        segment tmp = {hor[i].x + middle, hor[i].y, hor[i].l - 2 * middle};
        h.push_back(tmp);
      }
    }
    if (check(h, v)) {
      l = middle;
    } else {
      r = middle;
    }
  }
  cout << l << "\n";
}
