#include <bits/stdc++.h>
using namespace std;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
void color(int x, int y, vector<vector<int>> &g) {
  if (x < 0 or x >= (int)g.size()) return;
  if (y < 0 or y >= (int)g[0].size()) return;
  if (g[x][y] == 0) {
    g[x][y] = 2;
    for (int d = 0; d < 4; d++) {
      color(x + dx[d], y + dy[d], g);
    }
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long int> xs, ys;
  vector<long long int> a(n), b(n), c(n);
  for (int 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]);
  }
  vector<long long int> d(m), e(m), f(m);
  for (int 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]);
  }
  xs.push_back(0);
  ys.push_back(0);
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  sort(ys.begin(), ys.end());
  ys.erase(unique(ys.begin(), ys.end()), ys.end());
  map<long long int, long long int> xconv;
  for (int i = 0; i < (int)xs.size(); i++) {
    xconv[xs[i]] = i;
  }
  map<long long int, long long int> yconv;
  for (int i = 0; i < (int)ys.size(); i++) {
    yconv[ys[i]] = i;
  }
  vector<vector<int>> grid(xs.size() * 2 + 2,
                           vector<int>(ys.size() * 2 + 2, 0));
  for (int i = 0; i < n; i++) {
    int y = 2 * yconv[c[i]] + 1;
    int xfrom = 2 * xconv[a[i]] + 1;
    int xto = 2 * xconv[b[i]] + 1;
    for (int x = xfrom; x <= xto; x++) {
      grid[x][y] = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    int x = 2 * xconv[d[i]] + 1;
    int yfrom = 2 * yconv[e[i]] + 1;
    int yto = 2 * yconv[f[i]] + 1;
    for (int y = yfrom; y <= yto; y++) {
      grid[x][y] = 1;
    }
  }
  color(2 * xconv[0] + 1, 2 * yconv[0] + 1, grid);
  if (grid[0][0] == 2) {
    cout << "INF" << endl;
    return 0;
  }
  long long int ans = 0;
  for (int i = 0; i < (int)xs.size() - 1; i++) {
    long long int w = xs[i + 1] - xs[i];
    for (int j = 0; j < (int)ys.size() - 1; j++) {
      long long int h = ys[j + 1] - ys[j];
      if (grid[2 * i + 2][2 * j + 2] == 2) {
        ans += w * h;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
