#include <bits/stdc++.h>
using namespace std;
template <typename T>
vector<T> compress(vector<T> &C1, vector<T> &C2, vector<T> &C3) {
  vector<T> vals;
  for (int i = 0; i < C1.size(); i++) {
    vals.push_back(C1[i]);
    vals.push_back(C1[i] + 1);
  }
  for (int i = 0; i < C2.size(); i++) {
    vals.push_back(C2[i]);
    vals.push_back(C2[i] + 1);
  }
  for (int i = 0; i < C3.size(); i++) {
    vals.push_back(C3[i]);
    vals.push_back(C3[i] + 1);
  }
  sort((vals).begin(), (vals).end());
  vals.erase(unique((vals).begin(), (vals).end()), vals.end());
  for (int i = 0; i < C1.size(); i++)
    C1[i] = lower_bound((vals).begin(), (vals).end(), C1[i]) - vals.begin();
  for (int i = 0; i < C2.size(); i++)
    C2[i] = lower_bound((vals).begin(), (vals).end(), C2[i]) - vals.begin();
  for (int i = 0; i < C3.size(); i++)
    C3[i] = lower_bound((vals).begin(), (vals).end(), C3[i]) - vals.begin();
  return vals;
}
vector<int> dx{1, 0, -1, 0};
vector<int> dy{0, -1, 0, 1};
void bfs() {}
int main() {
  int N, M;
  cin >> N >> M;
  vector<long long> A, B, C, D, E, F;
  for (int i = 0; i < N; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    A.push_back(2 * a);
    B.push_back(2 * b);
    C.push_back(2 * c);
  }
  for (int i = 0; i < M; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    D.push_back(2 * a);
    E.push_back(2 * b);
    F.push_back(2 * c);
  }
  vector<long long> X = compress(A, B, D);
  vector<long long> Y = compress(C, E, F);
  vector<vector<int>> G(X.size() + 2, vector<int>(Y.size() + 2, 2));
  for (int i = 0; i < X.size(); i++) {
    for (int j = 0; j < Y.size(); j++) {
      G[i + 1][j + 1] = 0;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int x = A[i]; x < B[i] + 1; x++) {
      G[x + 1][C[i] + 1] = 1;
    }
  }
  for (int i = 0; i < M; i++) {
    for (int y = E[i]; y < F[i] + 1; y++) {
      G[D[i] + 1][y + 1] = 1;
    }
  }
  pair<long long, long long> s;
  s.first = upper_bound((X).begin(), (X).end(), 0) - X.begin();
  s.second = upper_bound((Y).begin(), (Y).end(), 0) - Y.begin();
  long long ans = 0;
  queue<pair<long long, long long>> q;
  q.push(s);
  while (!q.empty()) {
    auto pos = q.front();
    q.pop();
    long long x = pos.first;
    long long y = pos.second;
    if (x % 2 == 0 && y % 2 == 0) {
      ans += (X[x + 1] - X[x - 1]) * (Y[y + 1] - Y[y - 1]) / 4;
    }
    for (int i = 0; i < 4; i++) {
      long long nx = x + dx[i];
      long long ny = y + dy[i];
      if (G[nx][ny] == 2) {
        cout << "INF" << endl;
        return 0;
      } else if (G[nx][ny] == 0) {
        G[nx][ny] = 1;
        q.push({nx, ny});
      }
    }
  }
  cout << ans << endl;
  return 0;
}
