#include <bits/stdc++.h>
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1000000007;
const ll INF = 1e18;
const double PI = acos(-1);
using namespace std;
struct INIT {
  INIT() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  }
} INIT;
signed main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> X, Y;
  vector<ll> A(N), B(N), C(N);
  for (ll i = 0; i < ll(N); ++i) {
    cin >> A[i] >> B[i] >> C[i];
    X.emplace_back(A[i]);
    X.emplace_back(B[i]);
    Y.emplace_back(C[i]);
  }
  vector<ll> D(M), E(M), F(M);
  for (ll i = 0; i < ll(M); ++i) {
    cin >> D[i] >> E[i] >> F[i];
    X.emplace_back(D[i]);
    Y.emplace_back(E[i]);
    Y.emplace_back(F[i]);
  }
  X.emplace_back(0);
  Y.emplace_back(0);
  sort((X).begin(), (X).end());
  sort((Y).begin(), (Y).end());
  X.erase(unique((X).begin(), (X).end()), X.end());
  Y.erase(unique((Y).begin(), (Y).end()), Y.end());
  for (ll i = 0; i < ll(N); ++i) {
    A[i] = lower_bound((X).begin(), (X).end(), A[i]) - X.begin();
    B[i] = lower_bound((X).begin(), (X).end(), B[i]) - X.begin();
    C[i] = lower_bound((X).begin(), (X).end(), C[i]) - X.begin();
  }
  for (ll i = 0; i < ll(M); ++i) {
    D[i] = lower_bound((X).begin(), (X).end(), D[i]) - X.begin();
    E[i] = lower_bound((X).begin(), (X).end(), E[i]) - X.begin();
    F[i] = lower_bound((X).begin(), (X).end(), F[i]) - X.begin();
  }
  ll H = X.size() * 2;
  ll W = Y.size() * 2;
  vector<vector<ll>> d(H, vector<ll>(W));
  for (ll i = 0; i < ll(N); ++i) {
    for (ll j = (A[i] * 2); j < (B[i] * 2 + 1); ++j) d[j][C[i] * 2] = -1;
  }
  for (ll i = 0; i < ll(M); ++i) {
    for (ll j = (E[i] * 2); j < (F[i] * 2 + 1); ++j) d[D[i] * 2][j] = -1;
  }
  ll sx = (lower_bound((X).begin(), (X).end(), 0) - X.begin()) * 2;
  ll sy = (lower_bound((Y).begin(), (Y).end(), 0) - Y.begin()) * 2;
  queue<pair<ll, ll>> q;
  q.emplace(sx, sy);
  d[sx][sy] = 1;
  ll dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
  ll dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
  while (!q.empty()) {
    auto [x, y] = q.front();
    q.pop();
    for (ll i = 0; i < ll(4); ++i) {
      ll nx = x + dx[i];
      ll ny = y + dy[i];
      if ((nx < 0 || H <= nx) || (ny < 0 || W <= ny)) continue;
      if (d[nx][ny] != 0) continue;
      d[nx][ny] = 1;
      q.emplace(nx, ny);
    }
  }
  ll ans = 0;
  for (ll i = 0; i < ll(H); ++i)
    for (ll j = 0; j < ll(W); ++j) {
      if (d[i][j] != 1) continue;
      if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
        cout << "INF"
             << "\n";
        return 0;
      }
      if (i % 2 == 0 || j % 2 == 0) continue;
      ans += (X[i / 2 + 1] - X[i / 2]) * (Y[j / 2 + 1] - Y[j / 2]);
    }
  cout << ans << "\n";
  return 0;
}
