#include <bits/stdc++.h>
using namespace std;
struct L {
  int64_t s;
  int64_t g;
  int64_t l;
};
vector<int64_t> xss(9001);
vector<int64_t> yss(9001);
vector<vector<int>> v_map(9001, vector<int>(9001));
vector<vector<int>> h_map(9001, vector<int>(9001));
vector<vector<int>> s_map(9001, vector<int>(9001));
int64_t solve(int xidx, int yidx) {
  if (xidx == 0 || xidx == xss.size() || yidx == 0 || yidx == yss.size()) {
    return -1;
  }
  if (s_map[xidx][yidx]) return 0;
  s_map[xidx][yidx] = 1;
  int64_t ans = (xss[xidx] - xss[xidx - 1]) * (yss[yidx] - yss[yidx - 1]);
  if (!h_map[xidx - 1][yidx - 1]) {
    int64_t c = solve(xidx - 1, yidx);
    if (c == -1) return -1;
    ans += c;
  }
  if (!h_map[xidx][yidx - 1]) {
    int64_t c = solve(xidx + 1, yidx);
    if (c == -1) return -1;
    ans += c;
  }
  if (!v_map[xidx - 1][yidx - 1]) {
    int64_t c = solve(xidx, yidx - 1);
    if (c == -1) return -1;
    ans += c;
  }
  if (!v_map[xidx - 1][yidx]) {
    int64_t c = solve(xidx, yidx + 1);
    if (c == -1) return -1;
    ans += c;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(20);
  int n, m;
  cin >> n >> m;
  vector<L> vs(n);
  vector<L> hs(m);
  {
    int nx = 0;
    int ny = 0;
    for (int i = (int)(0); i < (int)(n); i++) {
      int64_t a, b, c;
      cin >> a >> b >> c;
      xss[nx++] = a;
      xss[nx++] = b;
      yss[ny++] = c;
      vs[i] = {a, b, c};
    }
    for (int j = (int)(0); j < (int)(m); j++) {
      int64_t a, b, c;
      cin >> c >> a >> b;
      yss[ny++] = a;
      yss[ny++] = b;
      xss[nx++] = c;
      hs[j] = {a, b, c};
    }
    sort(xss.begin(), xss.end());
    {
      auto it = unique(xss.begin(), xss.end());
      xss.erase(it, xss.end());
    }
    sort(yss.begin(), yss.end());
    {
      auto it = unique(yss.begin(), yss.end());
      yss.erase(it, yss.end());
    }
  }
  for (auto& v : vs) {
    int yidx = std::lower_bound(yss.begin(), yss.end(), v.l) - yss.begin();
    int sidx = std::lower_bound(xss.begin(), xss.end(), v.s) - xss.begin();
    int gidx = std::lower_bound(xss.begin(), xss.end(), v.g) - xss.begin();
    for (int i = (int)(sidx); i < (int)(gidx); i++) {
      v_map[i][yidx] = 1;
    }
  }
  for (auto& h : hs) {
    int xidx = std::lower_bound(xss.begin(), xss.end(), h.l) - xss.begin();
    int sidx = std::lower_bound(yss.begin(), yss.end(), h.s) - yss.begin();
    int gidx = std::lower_bound(yss.begin(), yss.end(), h.g) - yss.begin();
    for (int i = (int)(sidx); i < (int)(gidx); i++) {
      h_map[xidx][i] = 1;
    }
  }
  int xidx = std::lower_bound(xss.begin(), xss.end(), 0) - xss.begin();
  int yidx = std::lower_bound(yss.begin(), yss.end(), 0) - yss.begin();
  int64_t ans = solve(xidx, yidx);
  if (ans == -1) {
    cout << "INF" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}
