#include <bits/stdc++.h>
using namespace std;
template <typename T>
T compress2(vector<T>& x1, vector<T>& x2) {
  vector<T> xs;
  const int N = x1.size();
  for (int i = 0; i < N; ++i) {
    for (int d = -1; d <= 1; ++d) {
      xs.push_back(x1[i] + d);
      xs.push_back(x2[i] + d);
    }
  }
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  for (int i = 0; i < N; ++i) {
    x1[i] = lower_bound(xs.begin(), xs.end(), x1[i]) - xs.begin();
    x2[i] = lower_bound(xs.begin(), xs.end(), x2[i]) - xs.begin();
  }
  return xs.size();
}
template <typename T>
T compress4(vector<T>& x1, vector<T>& x2, vector<T>& x3, vector<T>& x4) {
  vector<T> xs;
  for (int i = 0; i < x1.size(); ++i)
    xs.push_back(x1[i]), xs.push_back(x1[i] + 1);
  for (int i = 0; i < x2.size(); ++i)
    xs.push_back(x2[i]), xs.push_back(x2[i] + 1);
  for (int i = 0; i < x3.size(); ++i)
    xs.push_back(x3[i]), xs.push_back(x3[i] + 1);
  for (int i = 0; i < x4.size(); ++i)
    xs.push_back(x4[i]), xs.push_back(x4[i] + 1);
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  for (int i = 0; i < x1.size(); ++i)
    x1[i] = lower_bound(xs.begin(), xs.end(), x1[i]) - xs.begin();
  for (int i = 0; i < x2.size(); ++i)
    x2[i] = lower_bound(xs.begin(), xs.end(), x2[i]) - xs.begin();
  for (int i = 0; i < x3.size(); ++i)
    x3[i] = lower_bound(xs.begin(), xs.end(), x3[i]) - xs.begin();
  for (int i = 0; i < x4.size(); ++i)
    x4[i] = lower_bound(xs.begin(), xs.end(), x4[i]) - xs.begin();
  return xs.size();
}
void solve(long long N, long long M, std::vector<long long> A,
           std::vector<long long> B, std::vector<long long> C,
           std::vector<long long> D, std::vector<long long> E,
           std::vector<long long> F) {
  auto a = A;
  auto b = B;
  auto c = C;
  auto d = D;
  auto e = E;
  auto f = F;
  for (auto& x : a) x *= 2;
  for (auto& x : b) x *= 2;
  for (auto& x : c) x *= 2;
  for (auto& x : d) x *= 2;
  for (auto& x : e) x *= 2;
  for (auto& x : f) x *= 2;
  vector<long long> ox = {0};
  vector<long long> oy = {0};
  long long W = compress4(ox, a, b, d);
  long long H = compress4(oy, c, e, f);
  map<long long, long long> rx, ry;
  rx[ox[0]] = 0;
  ry[oy[0]] = 0;
  for (int i = 0; i < a.size(); ++i) rx[a[i]] = A[i];
  for (int i = 0; i < b.size(); ++i) rx[b[i]] = B[i];
  for (int i = 0; i < d.size(); ++i) rx[d[i]] = D[i];
  for (int i = 0; i < c.size(); ++i) ry[c[i]] = C[i];
  for (int i = 0; i < e.size(); ++i) ry[e[i]] = E[i];
  for (int i = 0; i < f.size(); ++i) ry[f[i]] = F[i];
  vector<vector<char>> field(W, vector<char>(H));
  for (int i = 0; i < N; ++i) {
    const auto l = min(a[i], b[i]);
    const auto r = max(a[i], b[i]) + 1;
    for (int x = (l); x < (r); ++x) field[x][c[i]] = -1;
  }
  for (int i = 0; i < M; ++i) {
    const auto l = min(e[i], f[i]);
    const auto r = max(e[i], f[i]) + 1;
    for (int y = (l); y < (r); ++y) field[d[i]][y] = -1;
  }
  long long ans = 0;
  stack<uint64_t> Q;
  Q.emplace(ox[0] << 32 | oy[0]);
  field[ox[0]][oy[0]] = 1;
  while (!Q.empty()) {
    uint64_t p = Q.top();
    Q.pop();
    for (int dx = (-1); dx < (2); ++dx)
      for (int dy = (-1); dy < (2); ++dy) {
        if (dx == 0 && dy == 0) continue;
        const auto nx = (p >> 32) + dx;
        const auto ny = (p & ((1ULL << 32) - 1)) + dy;
        if (0 <= nx && nx < W && 0 <= ny && ny < H) {
          if (field[nx][ny] == 0) {
            field[nx][ny] = 1;
            ans += (rx[nx + 1] - rx[nx - 1]) * (ry[ny + 1] - ry[ny - 1]);
            Q.emplace(nx << 32 | ny);
          }
        } else {
          cout << "INF" << endl;
          return;
        }
      }
  }
  cout << ans << endl;
}
int main() {
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  std::vector<long long> C(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
    scanf("%lld", &B[i]);
    scanf("%lld", &C[i]);
  }
  std::vector<long long> D(M);
  std::vector<long long> E(M);
  std::vector<long long> F(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &D[i]);
    scanf("%lld", &E[i]);
    scanf("%lld", &F[i]);
  }
  solve(N, M, std::move(A), std::move(B), std::move(C), std::move(D),
        std::move(E), std::move(F));
  return 0;
}
