#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vpl = vector<pll>;
void fio() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct dsu {
  int n;
  vector<int> sizes, marks;
  vector<vector<int>> graph;
  ll area[2000005];
  void init(int rn) {
    n = rn;
    sizes = vector<int>(n);
    fill(sizes.begin(), sizes.end(), 1);
    marks = vector<int>(n);
    for (int i = 0; i < n; i++) marks[i] = i;
    graph = vector<vector<int>>(n);
    memset(area, 0, sizeof(area));
  }
  void mark(int m, int node) {
    if (marks[node] == m) return;
    marks[node] = m;
    for (int i : graph[node]) mark(m, i);
  }
  void merge(int a, int b) {
    if (marks[a] == marks[b]) return;
    graph[a].push_back(b);
    graph[b].push_back(a);
    if (sizes[marks[a]] > sizes[marks[b]]) swap(a, b);
    sizes[marks[b]] += sizes[marks[a]];
    area[marks[b]] += area[marks[a]];
    sizes[marks[a]] = 0;
    mark(marks[b], a);
  }
  int first(int n) { return marks[n]; }
  void adda(ll id, ll a) { area[marks[id]] += a; }
  ll geta(ll id) { return area[marks[id]]; }
};
const long double pi = 3.14159265358979323846;
const ll bnum = 1e9 + 17;
const ll mx = 2e6;
ll area[mx];
dsu d;
void solve() {
  ll n, m;
  cin >> n >> m;
  pair<ll, pll> ver[n];
  pair<ll, pll> hor[m];
  for (long long i = 0; i < (n); i++) {
    cin >> ver[i].second.first >> ver[i].second.second >> ver[i].first;
  }
  for (long long i = 0; i < (m); i++) {
    cin >> hor[i].first >> hor[i].second.first >> hor[i].second.second;
  }
  d.init(mx);
  set<ll> coords;
  coords.insert(bnum);
  map<ll, vpl> ve;
  map<ll, vl> st, en;
  ve[bnum].push_back(make_pair(-bnum, bnum));
  set<pair<pll, ll>> segs;
  segs.insert(make_pair(make_pair(-bnum, bnum), 0));
  for (long long i = 0; i < (n); i++) {
    ve[ver[i].first].push_back(ver[i].second);
    coords.insert(ver[i].first);
  }
  for (long long i = 0; i < (m); i++) {
    coords.insert(hor[i].second.first);
    st[hor[i].second.first].push_back(hor[i].first);
    coords.insert(hor[i].second.second);
    en[hor[i].second.second].push_back(hor[i].first);
  }
  for (auto x : ve) {
    sort(x.second.begin(), x.second.end());
    vpl ne;
    pll targ = make_pair(-bnum, -bnum);
    for (auto y : x.second) {
      if (y.first <= targ.second) {
        targ.second = max(targ.second, y.second);
      } else {
        if (targ != make_pair(-bnum, -bnum)) ne.push_back(targ);
        targ = y;
      }
    }
    ne.push_back(targ);
    ve[x.first] = ne;
  }
  ll last = -bnum, lid = 1;
  int orig = -1;
  for (ll x : coords) {
    ll dif = x - last;
    for (auto x : segs) {
      ll v = x.first.second - x.first.first;
      d.adda(x.second, v * dif);
    }
    if (last <= 0 && x > 0) {
      for (auto x : segs) {
        if (x.first.first <= 0 && 0 <= x.first.second) orig = x.second;
      }
    }
    for (ll y : st[x]) {
      for (auto x : segs) {
        if (x.first.first < y && y < x.first.second) {
          segs.erase(x);
          segs.insert(make_pair(make_pair(x.first.first, y), x.second));
          segs.insert(make_pair(make_pair(y, x.first.second), x.second));
          break;
        }
      }
    }
    for (pll y : ve[x]) {
      vector<pair<pll, ll>> bad, good;
      for (auto x : segs) {
        if (y.first <= x.first.first && x.first.second <= y.second) {
          bad.push_back(x);
          good.push_back(make_pair(x.first, lid++));
        }
      }
      for (auto x : bad) segs.erase(x);
      for (auto x : good) segs.insert(x);
    }
    for (ll y : en[x]) {
      pair<pll, ll> last, next;
      for (auto x : segs) {
        if (x.first.second == y) {
          last = x;
        } else if (x.first.first == y) {
          next = x;
        }
      }
      segs.erase(last);
      segs.erase(next);
      d.merge(last.second, next.second);
      pair<pll, ll> ne = make_pair(
          make_pair(last.first.first, next.first.second), last.second);
      segs.insert(ne);
    }
    last = x;
  }
  if (d.first(orig) == d.first(0)) {
    cout << "INF\n";
  } else {
    cout << d.geta(orig) << '\n';
  }
}
int main() {
  fio();
  int T = 1;
  while (T--) solve();
}
