#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<ll> compress(vector<ll> &X) {
  vector<ll> vals = X;
  sort(vals.begin(), vals.end());
  vals.erase(unique(vals.begin(), vals.end()), vals.end());
  for (int i = 0; i < (int)X.size(); i++) {
    X[i] = lower_bound(vals.begin(), vals.end(), X[i]) - vals.begin();
  }
  return vals;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int main() {
  int n, m;
  cin >> n >> m;
  vector<ll> x, y;
  vector<ll> a(n), b(n), c(n), d(m), e(m), f(m);
  for (int i = 0; i < (n); i++) {
    cin >> a[i] >> b[i] >> c[i];
    x.push_back(a[i]);
    x.push_back(b[i]);
    y.push_back(c[i]);
  }
  for (int i = 0; i < (m); i++) {
    cin >> d[i] >> e[i] >> f[i];
    x.push_back(d[i]);
    y.push_back(e[i]);
    y.push_back(f[i]);
  }
  x.push_back(100100100ll);
  x.push_back(-100100100ll);
  x.push_back(0ll);
  y.push_back(100100100ll);
  y.push_back(-100100100ll);
  y.push_back(0ll);
  auto xx = compress(x);
  auto yy = compress(y);
  vector<ll> nx, ny;
  for (int i = 0; i < ((int)xx.size()); i++)
    for (int j = 0; j < (2); j++) nx.push_back(xx[i]);
  for (int i = 0; i < ((int)yy.size()); i++)
    for (int j = 0; j < (2); j++) ny.push_back(yy[i]);
  vector<vector<pair<ll, ll>>> data(
      (int)nx.size() - 1,
      vector<pair<ll, ll>>((int)ny.size() - 1, make_pair(1, 0)));
  for (int i = 0; i < ((int)xx.size() - 1); i++)
    for (int j = 0; j < ((int)yy.size() - 1); j++) {
      data[i * 2 + 1][j * 2 + 1].second =
          (xx[i + 1] - xx[i]) * (yy[j + 1] - yy[j]);
    }
  for (int i = 0; i < (n); i++) {
    int id = lower_bound(yy.begin(), yy.end(), c[i]) - yy.begin();
    int from = lower_bound(xx.begin(), xx.end(), a[i]) - xx.begin();
    int to = lower_bound(xx.begin(), xx.end(), b[i]) - xx.begin();
    for (int j = from * 2; j <= to * 2; j++) data[j][id * 2].first = 0;
  }
  for (int i = 0; i < (m); i++) {
    int id = lower_bound(xx.begin(), xx.end(), d[i]) - xx.begin();
    int from = lower_bound(yy.begin(), yy.end(), e[i]) - yy.begin();
    int to = lower_bound(yy.begin(), yy.end(), f[i]) - yy.begin();
    for (int j = from * 2; j <= to * 2; j++) data[id * 2][j].first = 0;
  }
  int sx = (lower_bound(xx.begin(), xx.end(), 0ll) - xx.begin()) * 2;
  int sy = (lower_bound(yy.begin(), yy.end(), 0ll) - yy.begin()) * 2;
  queue<pair<int, int>> que;
  que.push(make_pair(sx, sy));
  ll ans = 0;
  while (!que.empty()) {
    auto p = que.front();
    que.pop();
    for (int i = 0; i < (4); i++) {
      int nnx = p.first + dx[i], nny = p.second + dy[i];
      if (0 <= nnx && nnx < (int)nx.size() - 1 && 0 <= nny &&
          nny < (int)ny.size() - 1) {
        if (!data[nnx][nny].first) continue;
        if (nnx == 0 || nnx == (int)nx.size() - 1 || nny == 0 ||
            nny == (int)ny.size() - 1) {
          cout << "INF" << endl;
          return 0;
        } else {
          data[nnx][nny].first = 0;
          ans += data[nnx][nny].second;
          que.push(make_pair(nnx, nny));
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
