#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[1001], b[1001], c[1000], d[1000], e[1000], f[1000];
int U[1001][1001], L[1001][1001];
vector<vector<bool>> vis;
int id(vector<long long> h, long long a) {
  return lower_bound(h.begin(), h.end(), a) - h.begin();
}
int main() {
  cin >> n >> m;
  vector<long long> h, w;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    h.push_back(a[i]);
    h.push_back(b[i]);
    w.push_back(c[i]);
  }
  for (int i = 0; i < m; i++) {
    cin >> d[i] >> e[i] >> f[i];
    h.push_back(d[i]);
    w.push_back(f[i]);
    w.push_back(e[i]);
  }
  h.push_back(111111111);
  h.push_back(-111111111);
  w.push_back(111111111);
  w.push_back(-111111111);
  h.push_back(0);
  w.push_back(0);
  sort(h.begin(), h.end());
  sort(w.begin(), w.end());
  h.erase(unique(h.begin(), h.end()), h.end());
  w.erase(unique(w.begin(), w.end()), w.end());
  vis = vector<vector<bool>>(h.size(), vector<bool>(h.size(), false));
  for (int i = 0; i < n; i++) {
    L[id(h, a[i])][id(w, c[i])]++;
    L[id(h, b[i])][id(w, c[i])]--;
  }
  for (int i = 0; i < m; i++) {
    U[id(h, d[i])][id(w, e[i])]++;
    U[id(h, d[i])][id(w, f[i])]--;
  }
  for (int i = 1; i < h.size() - 1; i++) {
    for (int j = 1; j < w.size() - 1; j++) {
      L[i][j] += L[i - 1][j];
      U[i][j] += U[i][j - 1];
    }
  }
  queue<pair<int, int>> q;
  q.push({id(h, 0), id(w, 0)});
  long long ans = 0;
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    int x = p.first, y = p.second;
    if (!x || !y || x == h.size() - 1 || y == h.size() - 1) {
      cout << "INF";
      return 0;
    }
    if (!vis[x][y]) {
      vis[x][y] = 1;
      ans += (h[x + 1] - h[x]) * (w[y + 1] - w[y]);
      if (!U[x][y]) q.push({x - 1, y});
      if (!L[x][y]) q.push({x, y - 1});
      if (!U[x + 1][y]) q.push({x + 1, y});
      if (!L[x][y + 1]) q.push({x, y + 1});
    }
  }
  cout << ans;
  return 0;
}
