#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
struct LINE {
  int a, b, c;
};
ll f(vector<ll> &y, vector<ll> &x, int yidx, int xidx) {
  return (y[yidx + 1] - y[yidx]) * (x[xidx + 1] - x[xidx]);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<LINE> v1(n), v2(m);
  vector<ll> x = {0}, y = {0};
  map<int, int> x2idx, y2idx;
  for (int i = 0; i < n; i++) {
    cin >> v1[i].a >> v1[i].b >> v1[i].c;
    y.push_back(v1[i].a);
    y.push_back(v1[i].b);
    x.push_back(v1[i].c);
  }
  for (int i = 0; i < m; i++) {
    cin >> v2[i].a >> v2[i].b >> v2[i].c;
    x.push_back(v2[i].a);
    x.push_back(v2[i].b);
    y.push_back(v2[i].c);
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  auto xend = unique(x.begin(), x.end());
  auto yend = unique(y.begin(), y.end());
  for (auto it = x.begin(); it != xend; it++) {
    x2idx.insert({*it, it - x.begin()});
  }
  for (auto it = y.begin(); it != yend; it++) {
    y2idx.insert({*it, it - y.begin()});
  }
  vector<vector<bool>> checkh(yend - y.begin(), vector<bool>(xend - x.begin()));
  vector<vector<bool>> checkv(yend - y.begin(), vector<bool>(xend - x.begin()));
  for (int i = 0; i < n; i++) {
    int yidx1 = y2idx[v1[i].a];
    int yidx2 = y2idx[v1[i].b];
    int xidx = x2idx[v1[i].c];
    for (int j = yidx1; j < yidx2; j++) checkv[j][xidx] = true;
  }
  for (int i = 0; i < m; i++) {
    int xidx1 = x2idx[v2[i].a];
    int xidx2 = x2idx[v2[i].b];
    int yidx = y2idx[v2[i].c];
    for (int j = xidx1; j < xidx2; j++) checkh[yidx][j] = true;
  }
  vector<vector<bool>> visited(yend - y.begin(),
                               vector<bool>(xend - x.begin()));
  queue<pii> q;
  int sy = y2idx[0], sx = x2idx[0];
  q.push({sy, sx});
  visited[sy][sx] = true;
  ll answer = f(y, x, sy, sx);
  while (!q.empty()) {
    pii now = q.front();
    q.pop();
    if (!checkv[now.first][now.second]) {
      if (now.second > 0) {
        if (!visited[now.first][now.second - 1]) {
          q.push({now.first, now.second - 1});
          visited[now.first][now.second - 1] = true;
          answer += f(y, x, now.first, now.second - 1);
        }
      } else {
        answer = LLONG_MAX;
        break;
      }
    }
    if (!checkv[now.first][now.second + 1]) {
      if (now.second < xend - x.begin()) {
        if (!visited[now.first][now.second + 1]) {
          q.push({now.first, now.second + 1});
          visited[now.first][now.second + 1] = true;
          answer += f(y, x, now.first, now.second + 1);
        }
      } else {
        answer = LLONG_MAX;
        break;
      }
    }
    if (!checkh[now.first][now.second]) {
      if (now.first > 0) {
        if (!visited[now.first - 1][now.second]) {
          q.push({now.first - 1, now.second});
          visited[now.first - 1][now.second] = true;
          answer += f(y, x, now.first - 1, now.second);
        }
      } else {
        answer = LLONG_MAX;
        break;
      }
    }
    if (!checkh[now.first + 1][now.second]) {
      if (now.first < yend - y.begin()) {
        if (!visited[now.first + 1][now.second]) {
          q.push({now.first + 1, now.second});
          visited[now.first + 1][now.second] = true;
          answer += f(y, x, now.first + 1, now.second);
        }
      } else {
        answer = LLONG_MAX;
        break;
      }
    }
  }
  if (answer == LLONG_MAX)
    cout << "INF";
  else
    cout << answer;
  return 0;
}
