#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long u[1005], d[1005], x[1005];
long long l[1005], r[1005], y[1005];
long long h, w;
bool wall[6005][6005], used[6005][6005];
vector<long long> compX, compY;
long long dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
void comp(vector<long long> &vec) {
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
}
long long get(vector<long long> &vec, long long x) {
  return lower_bound(vec.begin(), vec.end(), x) - vec.begin();
}
void dfs(int x, int y) {
  used[x][y] = true;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
    if (used[nx][ny] || wall[nx][ny]) continue;
    dfs(nx, ny);
  }
}
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> u[i] >> d[i] >> x[i];
  for (int i = 1; i <= m; i++) cin >> y[i] >> l[i] >> r[i];
  compX.push_back(-2e9);
  compX.push_back(2e9);
  compY.push_back(-2e9);
  compY.push_back(2e9);
  for (int i = 1; i <= n; i++) {
    compX.push_back(x[i]);
    compY.push_back(u[i]);
    compY.push_back(d[i]);
  }
  for (int i = 1; i <= m; i++) {
    compY.push_back(y[i]);
    compX.push_back(l[i]);
    compX.push_back(r[i]);
  }
  comp(compX), comp(compY);
  w = compX.size() * 2, h = compY.size() * 2;
  for (int i = 1; i <= n; i++) {
    long long U = get(compY, u[i]) * 2, D = get(compY, d[i]) * 2,
              X = get(compX, x[i]) * 2;
    for (int j = U; j <= D; j++) wall[X][j] = true;
  }
  for (int i = 1; i <= m; i++) {
    long long L = get(compX, l[i]) * 2, R = get(compX, r[i]) * 2,
              Y = get(compY, y[i]) * 2;
    for (int j = L; j <= R; j++) wall[j][Y] = true;
  }
  long long sx = get(compX, 0) * 2 - 1, sy = get(compY, 0) * 2 - 1;
  dfs(sx, sy);
  long long ans = 0;
  for (int x = 0; x < w; x++) {
    for (int y = 0; y < h; y++) {
      if (!used[x][y]) continue;
      if (x == 0 || x >= w - 2 || y == 0 || y >= h - 2) {
        cout << "INF" << endl;
        return 0;
      }
      if (x % 2 == 0 || y % 2 == 0) continue;
      long long X = x / 2, Y = y / 2;
      if (X + 1 >= compX.size() || Y + 1 >= compY.size()) {
        cout << "INF" << endl;
        return 0;
      }
      ans += (compX[X + 1] - compX[X]) * (compY[Y + 1] - compY[Y]);
    }
  }
  cout << ans << endl;
  return 0;
}
