#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long INF = 1e18 + 18;
const long long MAX = 100005;
const long long MOD = 1000000007;
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;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) {
  return s << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
istream &operator>>(istream &i, vector<T> &v) {
  for (long long j = (0); j < (v.size()); j++) i >> v[j];
  return i;
}
template <typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1) s << "	";
  }
  return s;
}
template <typename T>
ostream &operator<<(ostream &s, const vector<vector<T>> &vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}
struct mint {
  long long x;
  mint(long long x = 0) : x((x % MOD + MOD) % MOD) {}
  mint &operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint &operator-=(const mint a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }
  mint inv() const { return pow(MOD - 2); }
  mint &operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < MOD);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);
  long long n, m;
  cin >> n >> m;
  vector<tuple<long long, long long, long long>> lh;
  vector<tuple<long long, long long, long long>> lv;
  vector<long long> x;
  vector<long long> y;
  x.push_back(0);
  y.push_back(0);
  for (long long i = (0); i < (n); i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    lh.emplace_back(a, b, c);
    x.push_back(a);
    x.push_back(b);
    y.push_back(c);
  }
  for (long long i = (0); i < (m); i++) {
    long long d, e, f;
    cin >> d >> e >> f;
    lv.emplace_back(d, e, f);
    x.push_back(d);
    y.push_back(e);
    y.push_back(f);
  }
  sort(x.begin(), x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  sort(y.begin(), y.end());
  y.erase(unique(y.begin(), y.end()), y.end());
  unordered_map<long long, long long> memox;
  unordered_map<long long, long long> memoy;
  auto idx = [&](long long k) {
    if (memox.count(k) > 0) {
      return memox[k];
    } else {
      return memox[k] = lower_bound(x.begin(), x.end(), k) - x.begin();
    }
  };
  auto idy = [&](long long k) {
    if (memoy.count(k) > 0) {
      return memoy[k];
    } else {
      return memoy[k] = lower_bound(y.begin(), y.end(), k) - y.begin();
    }
  };
  long long h = x.size() * 2;
  long long w = y.size() * 2;
  vector<vector<long long>> g(h, vector<long long>(w));
  for (long long i = (0); i < (n); i++) {
    long long a, b, c;
    tie(a, b, c) = lh[i];
    for (long long k = (idx(a)); k < (idx(b)); k++) {
      g[k * 2][idy(c) * 2] = -1;
      g[(k)*2 + 1][idy(c) * 2] = -1;
    }
  }
  for (long long i = (0); i < (m); i++) {
    long long d, e, f;
    tie(d, e, f) = lv[i];
    for (long long k = (idx(e)); k < (idy(f)); k++) {
      g[idx(d) * 2][k * 2] = -1;
      g[idx(d) * 2][k * 2 + 1] = -1;
    }
  }
  g[idx(0) * 2][idy(0) * 2] = 1;
  auto in = [&](long long y, long long x) {
    return y >= 0 && y < h && x >= 0 && x < w;
  };
  queue<pair<long long, long long>> q;
  vector<long long> dx = {1, 0, -1, 0};
  vector<long long> dy = {0, 1, 0, -1};
  q.push({idx(0) * 2, idy(0) * 2});
  while (!q.empty()) {
    pair<long long, long long> p = q.front();
    q.pop();
    for (long long i = (0); i < (4); i++) {
      long long nx = p.first + dx[i];
      long long ny = p.second + dy[i];
      if (!in(nx, ny)) continue;
      if (g[nx][ny] == 0) {
        g[nx][ny] = 1;
        q.push({nx, ny});
      }
    }
  };
  long long ans = 0;
  for (long long i = (0); i < (h); i++) {
    for (long long j = (0); j < (w); j++) {
      if (g[i][j] != 1) continue;
      if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
        cout << "INF" << endl;
        return 0;
      }
      if (i % 2 == 0 || j % 2 == 0) continue;
      long long lx = x[i / 2 + 1] - x[i / 2];
      long long ly = y[j / 2 + 1] - y[j / 2];
      ans += ly * lx;
    }
  }
  cout << ans << endl;
  return 0;
}
