#include <bits/stdc++.h>
using namespace std;
const long long logN = 20;
const long long M = 3000000007;
const long long INF = 1e12;
const long long N = 100005;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  vector<long long> x, y;
  long long A[n][3], B[m][3];
  for (long long i = 0; i < n; i++) {
    cin >> A[i][0] >> A[i][1] >> A[i][2];
    y.push_back(A[i][0]);
    y.push_back(A[i][1]);
    x.push_back(A[i][2]);
  }
  for (long long i = 0; i < m; i++) {
    cin >> B[i][0] >> B[i][1] >> B[i][2];
    y.push_back(B[i][0]);
    x.push_back(B[i][1]);
    x.push_back(B[i][2]);
  }
  y.push_back(-M);
  x.push_back(M);
  y.push_back(M);
  x.push_back(-M);
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  map<long long, long long> gg1, gg2, rgg1, rgg2;
  long long cnt = 0;
  for (auto i : x) {
    if (gg1[i] == 0) {
      gg1[i] = cnt;
      rgg1[cnt] = i;
      cnt++;
    }
  }
  long long p = cnt;
  cnt = 0;
  for (auto i : y) {
    if (gg2[i] == 0) {
      gg2[i] = cnt;
      rgg2[cnt] = i;
      cnt++;
    }
  }
  long long q = cnt;
  long long X[p + 1][q + 1], Y[p + 1][q + 1];
  for (long long i = 0; i < p + 1; i++)
    for (long long j = 0; j < q + 1; j++) {
      X[i][j] = 0;
      Y[i][j] = 0;
    }
  for (long long i = 0; i < n; i++) {
    X[gg2[A[i][0]]][gg1[A[i][2]]]++;
    X[gg2[A[i][1]]][gg1[A[i][2]]]--;
  }
  for (long long i = 0; i < m; i++) {
    Y[gg2[B[i][0]]][gg1[B[i][1]]]++;
    Y[gg2[B[i][0]]][gg1[B[i][2]]]--;
  }
  for (long long i = 1; i < p; i++)
    for (long long j = 1; j < q; j++) {
      X[i][j] += X[i - 1][j];
      Y[i][j] += Y[i][j - 1];
    }
  bool XY[p + 1][q + 1];
  for (long long i = 0; i < p + 1; i++)
    for (long long j = 0; j < q + 1; j++) XY[i][j] = 0;
  queue<pair<long long, long long> > t;
  t.push({gg1[0], gg2[0]});
  while (!t.empty()) {
    pair<long long, long long> r = t.front();
    t.pop();
    if (r.first < 0 or r.first >= p or r.second < 0 or r.second >= q or
        XY[r.first][r.second])
      continue;
    XY[r.first][r.second] = 1;
    if (Y[r.first + 1][r.second] == 0) {
      t.push({r.first + 1, r.second});
    }
    if (Y[r.first][r.second] == 0) {
      t.push({r.first - 1, r.second});
    }
    if (X[r.first][r.second + 1] == 0) {
      t.push({r.first, r.second + 1});
    }
    if (X[r.first][r.second] == 0) {
      t.push({r.first, r.second - 1});
    }
  }
  if (XY[0][0] == 1) {
    cout << "INF"
         << "\n";
    return 0;
  }
  long long ans = 0;
  for (long long i = 1; i < p - 1; i++)
    for (long long j = 1; j < q - 1; j++) {
      if (XY[i][j]) {
        ans += (rgg2[i + 1] - rgg2[i]) * (rgg1[j + 1] - rgg1[j]);
      }
    }
  cout << ans << "\n";
  return 0;
}
