#include <bits/stdc++.h>
using namespace std;
using VP = vector<pair<long long, long long>>;
using VVP = vector<VP>;
using VI = vector<long long>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const long long INF = 1LL << 61;
const long long mod = 1e9 + 7;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int n, m;
long long sx, sy;
long long r;
vector<vector<bool>> yb;
vector<vector<bool>> xb;
vector<vector<bool>> visited;
long long ans = 0;
VI xw(2020);
VI yw(2020);
bool ff = 0;
void dfs(long long x, long long y) {
  if (visited[x][y]) return;
  if (ff) return;
  if (x == 0 && y == 0) {
    ff = 1;
    return;
  }
  visited[x][y] = 1;
  ans += xw[x] * yw[y];
  if (x != 0 && xb[x][y]) dfs(x - 1, y);
  if (x != r - 1 && xb[x + 1][y]) dfs(x + 1, y);
  if (y != 0 && yb[x][y]) dfs(x, y - 1);
  if (y != r - 1 && yb[x][y + 1]) dfs(x, y + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i, j;
  cin >> n >> m;
  long long a[n], b[n], c[n];
  long long d[m], e[m], f[m];
  VI xs, ys;
  map<long long, long long> zx, zy;
  xs.push_back(-inf);
  xs.push_back(inf);
  ys.push_back(-inf);
  ys.push_back(inf);
  xs.push_back(0);
  ys.push_back(0);
  for (i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    xs.push_back(a[i]);
    xs.push_back(b[i]);
    ys.push_back(c[i]);
  }
  for (i = 0; i < m; i++) {
    cin >> d[i] >> e[i] >> f[i];
    xs.push_back(d[i]);
    ys.push_back(e[i]);
    ys.push_back(f[i]);
  }
  sort(xs.begin(), xs.end());
  sort(ys.begin(), ys.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  ys.erase(unique(ys.begin(), ys.end()), ys.end());
  for (i = 0; i < xs.size(); i++) {
    if (i + 1 < xs.size()) xw[i] = xs[i + 1] - xs[i];
    zx[xs[i]] = i;
    if (xs[i] == 0) sx = i;
  }
  for (i = 0; i < ys.size(); i++) {
    if (i + 1 < ys.size()) yw[i] = ys[i + 1] - ys[i];
    zy[ys[i]] = i;
    if (ys[i] == 0) sy = i;
  }
  r = xs.size();
  yb = vector<vector<bool>>(r, vector<bool>(r, 1));
  xb = vector<vector<bool>>(r, vector<bool>(r, 1));
  visited = vector<vector<bool>>(r, vector<bool>(r, 0));
  for (i = 0; i < n; i++) {
    a[i] = zx[a[i]];
    b[i] = zx[b[i]];
    c[i] = zy[c[i]];
    for (j = a[i]; j < b[i]; j++) {
      yb[j][c[i]] = 0;
    }
  }
  for (i = 0; i < m; i++) {
    d[i] = zx[d[i]];
    e[i] = zy[e[i]];
    f[i] = zy[f[i]];
    for (j = e[i]; j < f[i]; j++) {
      xb[d[i]][j] = 0;
    }
  }
  dfs(sx, sy);
  if (ff) {
    cout << "INF" << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}
