#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i] >> C[i];
  }
  vector<int> D(M), E(M), F(M);
  for (int i = 0; i < M; i++) {
    cin >> D[i] >> E[i] >> F[i];
  }
  vector<ll> X, Y;
  X.push_back(0);
  Y.push_back(0);
  for (int i = 0; i < N; i++) {
    X.push_back(A[i]);
    X.push_back(B[i]);
    Y.push_back(C[i]);
  }
  for (int i = 0; i < M; i++) {
    X.push_back(D[i]);
    Y.push_back(E[i]);
    Y.push_back(F[i]);
  }
  sort(X.begin(), X.end());
  X.erase(unique(X.begin(), X.end()), X.end());
  sort(Y.begin(), Y.end());
  Y.erase(unique(Y.begin(), Y.end()), Y.end());
  vector<vector<ll>> mp(2 * X.size() - 1, vector<ll>(2 * Y.size() - 1, 0));
  for (int i = 1; i < 2 * X.size() - 1; i += 2) {
    ll height = X[i / 2 + 1] - X[i / 2];
    for (int j = 1; j < 2 * Y.size() - 1; j += 2) {
      ll width = Y[i / 2 + 1] - Y[i / 2];
      mp[i][j] = height * width;
    }
  }
  for (int i = 0; i < N; i++) {
    int aidx = lower_bound(X.begin(), X.end(), A[i]) - X.begin();
    int bidx = lower_bound(X.begin(), X.end(), B[i]) - X.begin();
    int cidx = lower_bound(Y.begin(), Y.end(), C[i]) - Y.begin();
    for (int j = 2 * aidx; j <= 2 * bidx; j++) {
      mp[j][2 * cidx] = -1;
    }
  }
  for (int i = 0; i < M; i++) {
    int didx = lower_bound(X.begin(), X.end(), D[i]) - X.begin();
    int eidx = lower_bound(Y.begin(), Y.end(), E[i]) - Y.begin();
    int fidx = lower_bound(Y.begin(), Y.end(), F[i]) - Y.begin();
    for (int j = 2 * eidx; j <= 2 * fidx; j++) {
      mp[2 * didx][j] = -1;
    }
  }
  int sx = 2 * (lower_bound(X.begin(), X.end(), 0) - X.begin());
  int sy = 2 * (lower_bound(Y.begin(), Y.end(), 0) - Y.begin());
  queue<pair<int, int>> q;
  q.emplace(sx, sy);
  ll ans = 0;
  vector<vector<bool>> is_reached(2 * X.size() - 1,
                                  vector<bool>(2 * Y.size() - 1, false));
  is_reached[sx][sy] = true;
  vector<pair<int, int>> motion;
  motion.emplace_back(1, 0);
  motion.emplace_back(-1, 0);
  motion.emplace_back(0, 1);
  motion.emplace_back(0, -1);
  bool reached_edge = false;
  while (!q.empty() && !reached_edge) {
    pair<int, int> cp = q.front();
    q.pop();
    for (auto m : motion) {
      int nx = cp.first + m.first;
      int ny = cp.second + m.second;
      if (nx < 0 || 2 * X.size() - 1 <= nx || ny < 0 ||
          2 * Y.size() - 1 <= ny) {
        reached_edge = true;
        break;
      }
      if (mp[nx][ny] == -1 || is_reached[nx][ny]) continue;
      is_reached[nx][ny] = true;
      ans += mp[nx][ny];
      q.emplace(nx, ny);
    }
  }
  if (reached_edge)
    cout << "INF\n";
  else
    cout << ans << '\n';
  return 0;
}
