#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
template <typename T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
int in() {
  int x;
  scanf("%d", &x);
  return x;
}
long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const long long INF = 1e9 + 10;
void compress_coordinate(vector<long long> x, map<long long, int> &zip,
                         vector<long long> &unzip) {
  int n = x.size();
  for (int i = 0; i < n; ++i) unzip.push_back(x[i]);
  sort((unzip).begin(), (unzip).end());
  unzip.erase(unique((unzip).begin(), (unzip).end()), unzip.end());
  for (int i = 0; i < unzip.size(); ++i) zip[unzip[i]] = i;
}
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<long long> a(n), b(n), c(n), d(m), e(m), f(m), xs, ys;
  for (int i = 0; i < n; ++i) {
    a[i] = in();
    b[i] = in();
    c[i] = in();
    xs.push_back(a[i]);
    xs.push_back(b[i]);
    ys.push_back(c[i]);
  }
  for (int i = 0; i < m; ++i) {
    d[i] = in();
    e[i] = in();
    f[i] = in();
    xs.push_back(d[i]);
    ys.push_back(e[i]);
    ys.push_back(f[i]);
  }
  xs.push_back(0);
  xs.push_back(-INF);
  xs.push_back(INF);
  ys.push_back(0);
  ys.push_back(-INF);
  ys.push_back(INF);
  map<long long, int> zipx, zipy;
  vector<long long> unzipx, unzipy;
  compress_coordinate(xs, zipx, unzipx);
  compress_coordinate(ys, zipy, unzipy);
  int szx = unzipx.size() - 1, szy = unzipy.size() - 1;
  vector<vector<int> > wallx(szx, vector<int>(szy)), wally(wallx);
  for (int i = 0; i < m; ++i) {
    d[i] = zipx[d[i]];
    e[i] = zipy[e[i]];
    f[i] = zipy[f[i]];
    for (int p = e[i]; p <= f[i] - 1; ++p) wallx[d[i] - 1][p] = 1;
  }
  for (int i = 0; i < n; ++i) {
    a[i] = zipx[a[i]];
    b[i] = zipx[b[i]];
    c[i] = zipy[c[i]];
    for (int p = a[i]; p <= b[i] - 1; ++p) wally[p][c[i] - 1] = 1;
  }
  vector<vector<int> > visit(szx, vector<int>(szy));
  queue<pair<int, int> > que;
  int sx = zipx[0], sy = zipy[0];
  visit[sx][sy] = 1;
  que.push(pair<int, int>(sx, sy));
  while (!que.empty()) {
    pair<int, int> p = que.front();
    que.pop();
    int x = p.first, y = p.second;
    vector<pair<int, int> > next;
    if (!wallx[x][y]) next.push_back(pair<int, int>(x + 1, y));
    if (x > 0 && !wallx[x - 1][y]) next.push_back(pair<int, int>(x - 1, y));
    if (!wally[x][y]) next.push_back(pair<int, int>(x, y + 1));
    if (y > 0 && !wally[x][y - 1]) next.push_back(pair<int, int>(x, y - 1));
    for (pair<int, int> q : next) {
      int xx = q.first, yy = q.second;
      if (xx == 0 || xx == szx - 1 || yy == 0 || yy == szy - 1) {
        cout << "INF" << endl;
        return 0;
      }
      if (visit[xx][yy]) continue;
      visit[xx][yy] = 1;
      que.push(q);
    }
  }
  long long ans = 0;
  for (int i = 0; i < szx; ++i)
    for (int j = 0; j < szy; ++j) {
      if (!visit[i][j]) continue;
      long long dx = unzipx[i + 1] - unzipx[i];
      long long dy = unzipy[j + 1] - unzipy[j];
      ans += dx * dy;
    }
  cout << ans << endl;
  return 0;
}
