#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1000000000;
const ll LINF = 1001002003004005006ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
struct IOSetup {
  IOSetup() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(12);
  }
} iosetup;
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << p.first << " " << p.second;
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++)
    os << v[i] << (i + 1 == (int)v.size() ? "" : " ");
  return os;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &x : v) is >> x;
  return is;
}
signed main() {
  int n, m;
  cin >> n >> m;
  vector<ll> a(n), b(n), c(n), d(m), e(m), f(m), xs = {-LINF, LINF},
                                                 ys = {-LINF, LINF};
  for (int i = 0; i < (n); i++) {
    cin >> a[i] >> b[i] >> c[i];
    xs.push_back(a[i]);
    xs.push_back(b[i]);
    ys.push_back(c[i]);
  }
  for (int i = 0; i < (m); i++) {
    cin >> d[i] >> e[i] >> f[i];
    xs.push_back(d[i]);
    ys.push_back(e[i]);
    ys.push_back(f[i]);
  }
  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());
  xs.erase(unique(xs.begin(), xs.end()), end(xs));
  ys.erase(unique(ys.begin(), ys.end()), end(ys));
  int w = (int)xs.size() - 1, h = (int)ys.size() - 1;
  vector<vector<bool>> ri(h, vector<bool>(w, false)),
      le(h, vector<bool>(w, false)), up(h, vector<bool>(w, false)),
      dw(h, vector<bool>(w, false));
  vector<vector<ll>> s(h, vector<ll>(w));
  for (int i = 0; i < (h); i++)
    for (int j = 0; j < (w); j++) {
      if (i == 0 or i == h - 1 or j == 0 or j == w - 1)
        s[i][j] = -1;
      else
        s[i][j] = (ys[i + 1] - ys[i]) * (xs[j + 1] - xs[j]);
    }
  for (int i = 0; i < (n); i++) {
    int xl = a[i], xr = b[i], y = c[i];
    auto yi = lower_bound(ys.begin(), ys.end(), y) - begin(ys);
    auto xli = lower_bound(xs.begin(), xs.end(), xl) - begin(xs);
    auto xri = lower_bound(xs.begin(), xs.end(), xr) - begin(xs);
    for (int x = xli; x < xri; x++) {
      dw[yi][x] = true;
      up[yi - 1][x] = true;
    }
  }
  for (int j = 0; j < (m); j++) {
    int yl = e[j], yr = f[j], x = d[j];
    auto xi = lower_bound(xs.begin(), xs.end(), x) - begin(xs);
    auto yli = lower_bound(ys.begin(), ys.end(), yl) - begin(ys);
    auto yri = lower_bound(ys.begin(), ys.end(), yr) - begin(ys);
    for (int y = yli; y < yri; y++) {
      le[y][xi] = true;
      ri[y][xi - 1] = true;
    }
  }
  ll res = 0;
  vector<vector<bool>> check(h, vector<bool>(w, false));
  int sj = lower_bound(xs.begin(), xs.end(), 0) - begin(xs),
      si = lower_bound(ys.begin(), ys.end(), 0) - begin(ys);
  if (s[si][sj] == -1) {
    cout << "INF" << endl;
    return 0;
  }
  queue<pair<int, int>> que;
  que.push({si, sj});
  while (!que.empty()) {
    auto [i, j] = que.front();
    que.pop();
    if (check[i][j]) continue;
    res += s[i][j];
    check[i][j] = true;
    if (!up[i][j]) {
      if (s[i + 1][j] == -1) {
        cout << "INF" << endl;
        return 0;
      }
      que.push({i + 1, j});
    }
    if (!dw[i][j]) {
      if (s[i - 1][j] == -1) {
        cout << "INF" << endl;
        return 0;
      }
      que.push({i - 1, j});
    }
    if (!ri[i][j]) {
      if (s[i][j + 1] == -1) {
        cout << "INF" << endl;
        return 0;
      }
      que.push({i, j + 1});
    }
    if (!le[i][j]) {
      if (s[i][j - 1] == -1) {
        cout << "INF" << endl;
        return 0;
      }
      que.push({i, j - 1});
    }
  }
  cout << res << endl;
  return 0;
}
