#include <bits/stdc++.h>
using P = std::pair<int, int>;
using ll = long long int;
struct L {
  int a, b, c;
  L(int a = 0, int b = 0, int c = 0) : a(a), b(b), c(c) {}
};
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int main() {
  int n, m;
  std::cin >> n >> m;
  std::map<int, int> mpX, mpY;
  std::vector<L> vv, hv;
  for (int i = 0; i < n; ++i) {
    int a, b, c;
    std::cin >> a >> b >> c;
    mpX[a] = 0;
    mpX[b] = 0;
    mpY[c] = 0;
    vv.emplace_back(a, b, c);
  }
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    std::cin >> a >> b >> c;
    mpX[a] = 0;
    mpY[b] = 0;
    mpY[c] = 0;
    hv.emplace_back(a, b, c);
  }
  mpX[0] = 0;
  mpY[0] = 0;
  std::vector<int> xs, ys;
  for (auto p : mpX) {
    xs.push_back(p.first);
    mpX[p.first] = xs.size() - 1;
  }
  for (auto p : mpY) {
    ys.push_back(p.first);
    mpY[p.first] = ys.size() - 1;
  }
  int h = xs.size() * 2, w = ys.size() * 2;
  std::vector<std::vector<int>> d(h, std::vector<int>(w));
  for (auto l : vv) {
    for (int x = mpX[l.a] * 2; x <= mpX[l.b] * 2; ++x) {
      d[x][mpY[l.c] * 2] = -1;
    }
  }
  for (auto l : hv) {
    for (int y = mpY[l.b] * 2; y <= mpY[l.c] * 2; ++y) {
      d[mpX[l.a] * 2][y] = -1;
    }
  }
  std::queue<P> que;
  que.emplace(mpX[0] * 2, mpY[0] * 2);
  while (!que.empty()) {
    int x, y;
    std::tie(x, y) = que.front();
    que.pop();
    d[x][y] = 1;
    for (int i = 0; i < 4; ++i) {
      int nx = dx[i] + x;
      int ny = dy[i] + y;
      if (nx < 0 || nx >= h || ny < 0 || ny >= w || d[nx][ny] != 0) continue;
      que.emplace(nx, ny);
    }
  }
  ll ans = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (d[i][j] != 1) continue;
      if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
        std::cout << "INF" << std::endl;
        return 0;
      }
      ll ex = xs[(i + 1) / 2] - xs[i / 2];
      ll ey = ys[(j + 1) / 2] - ys[j / 2];
      ans += ex * ey;
    }
  }
  std::cout << ans << std::endl;
  return 0;
}
