#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';
constexpr double eps = 1e-10;
template <typename T1, typename T2>
inline void chmin(T1& a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1& a, T2 b) {
  if (a < b) a = b;
}
template <class T>
void Print(vector<T> v) {
  for (int i = (0); i < (v.size()); i++) {
    cout << v[i] << ' ';
  }
  cout << newl;
}
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  struct LS {
    int p, s, e;
    LS(int p = 0, int s = 0, int e = 0) : p(p), s(s), e(e) {}
  };
  vector<LS> vs(N), hs(M);
  auto lsCmp = [](const LS& l, const LS& r) { return l.p < r.p; };
  for (int i = (0); i < (N); i++) {
    cin >> vs[i].s >> vs[i].e >> vs[i].p;
  }
  for (int i = (0); i < (M); i++) {
    cin >> hs[i].p >> hs[i].s >> hs[i].e;
  }
  i64 result = 0;
  if (M > 1 && N > 1) {
    sort(hs.begin(), hs.end(), lsCmp);
    sort(vs.begin(), vs.end(), lsCmp);
    int mx = lower_bound(hs.begin(), hs.end(), LS(0), lsCmp) - hs.begin();
    int my = lower_bound(vs.begin(), vs.end(), LS(0), lsCmp) - vs.begin();
    vector<vector<bool>> vis(M - 1, vector<bool>(N - 1, false));
    queue<pair<int, int>> qu;
    qu.emplace(mx, my);
    while (qu.size()) {
      int x, y;
      tie(x, y) = qu.front();
      qu.pop();
      int px = x - 1, py = y - 1;
      if (px < 0 || py < 0 || x > vs.size() - 1 || y > hs.size() - 1) {
        result = 0;
        break;
      }
      if (vis[py][px]) continue;
      vis[py][px] = true;
      result += ((i64)vs[x].p - vs[px].p) * ((i64)hs[y].p - hs[py].p);
      if (hs[py].s > vs[px].p || vs[x].p > hs[py].e) qu.emplace(x, y - 1);
      if (vs[px].s > hs[py].p || hs[y].p > vs[px].e) qu.emplace(x - 1, y);
      if (hs[y].s > vs[px].p || vs[x].p > hs[y].e) qu.emplace(x, y + 1);
      if (vs[x].s > hs[py].p || hs[y].p > vs[x].e) qu.emplace(x + 1, y);
    }
  }
  if (result == 0)
    cout << "INF";
  else
    cout << result;
}
