#include <bits/stdc++.h>
using namespace std;
long long a[1010], b[1010], c[1010];
long long d[1010], e[1010], f[1010];
int ngx[1010][1010];
int ngy[1010][1010];
bool visit[1010][1010];
long long ind(int key, const vector<int>& v) {
  return lower_bound(v.begin(), v.end(), key) - v.begin();
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> x, y;
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i] >> b[i] >> c[i];
    x.push_back(a[i]);
    x.push_back(b[i]);
    y.push_back(c[i]);
  }
  for (int i = 0; i < (int)(m); i++) {
    cin >> d[i] >> e[i] >> f[i];
    x.push_back(d[i]);
    y.push_back(e[i]);
    y.push_back(f[i]);
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  y.erase(unique(y.begin(), y.end()), y.end());
  for (int i = 0; i < (int)(n); i++) {
    int from = ind(a[i], x);
    int to = ind(b[i], x);
    int ycor = ind(c[i], y);
    for (int j = (from); j < (to); ++j) {
      ngx[j][ycor] = true;
    }
  }
  for (int i = 0; i < (int)(m); i++) {
    int from = ind(e[i], y);
    int to = ind(f[i], y);
    int xcor = ind(d[i], x);
    for (int j = (from); j < (to); ++j) {
      ngy[xcor][j] = true;
    }
  }
  int xs = ind(0, x) - 1;
  int ys = ind(0, y) - 1;
  queue<pair<int, int>> q;
  q.emplace(xs, ys);
  long long res = 0;
  int w = x.size();
  int h = y.size();
  while (!q.empty()) {
    int xx = q.front().first;
    int yy = q.front().second;
    q.pop();
    if (xx < 0 || yy < 0 || xx >= w - 1 || yy >= h - 1) {
      cout << "INF" << endl;
      return 0;
    }
    if (visit[xx][yy]) continue;
    res += ((long long)x[xx + 1] - x[xx]) * ((long long)y[yy + 1] - y[yy]);
    if (!ngx[xx][yy]) q.emplace(xx, yy - 1);
    if (!ngx[xx][yy + 1]) q.emplace(xx, yy + 1);
    if (!ngy[xx][yy]) q.emplace(xx - 1, yy);
    if (!ngy[xx + 1][yy]) q.emplace(xx + 1, yy);
    visit[xx][yy] = 1;
  }
  cout << res << endl;
  return 0;
}
