#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const long long mod = 1e9 + 7;
int main() {
  int N, M;
  cin >> N >> M;
  vector<long long> A(N), B(N), C(N), D(M), E(M), F(M);
  map<long long, long long> mpX, mpY;
  mpX[0] = 0;
  mpY[0] = 0;
  for (int i = (int)(0); i < (int)(N); i++) {
    cin >> A[i] >> B[i] >> C[i];
    mpX[A[i]] = 0;
    mpX[B[i]] = 0;
    mpY[C[i]] = 0;
  }
  for (int i = (int)(0); i < (int)(M); i++) {
    cin >> D[i] >> E[i] >> F[i];
    mpX[D[i]] = 0;
    mpY[E[i]] = 0;
    mpY[F[i]] = 0;
  }
  vector<int> xs, ys;
  for (auto& p : mpX) {
    p.second = xs.size();
    xs.push_back(p.first);
  }
  for (auto& p : mpY) {
    p.second = ys.size();
    ys.push_back(p.first);
  }
  int H = xs.size() * 2;
  int W = ys.size() * 2;
  vector<vector<int>> dis(H, vector<int>(W));
  for (int i = (int)(0); i < (int)(N); i++) {
    long long a = mpX[A[i]] * 2;
    long long b = mpX[B[i]] * 2;
    long long c = mpY[C[i]] * 2;
    for (long long x = a; x <= b; x++) dis[x][c] = -1;
  }
  for (int i = (int)(0); i < (int)(M); i++) {
    long long d = mpX[D[i]] * 2;
    long long e = mpY[E[i]] * 2;
    long long f = mpY[F[i]] * 2;
    for (long long y = e; y <= f; y++) dis[d][y] = -1;
  }
  int dx[] = {0, -1, 0, 1};
  int dy[] = {-1, 0, 1, 0};
  queue<pair<long long, long long>> Q;
  long long sx = mpX[0] * 2;
  long long sy = mpY[0] * 2;
  Q.emplace(sx, sy);
  while (!Q.empty()) {
    auto p = Q.front();
    Q.pop();
    if (dis[p.first][p.second] != 0) continue;
    dis[p.first][p.second] = 1;
    for (int k = (int)(0); k < (int)(4); k++) {
      long long nx = p.first + dx[k];
      long long ny = p.second + dy[k];
      if (nx < 0 || nx >= H) continue;
      if (ny < 0 || ny >= W) continue;
      Q.emplace(nx, ny);
    }
  }
  long long ans = 0;
  for (int x = (int)(0); x < (int)(H); x++)
    for (int y = (int)(0); y < (int)(W); y++) {
      if (dis[x][y] != 1) continue;
      if (x == 0 || x == H - 1 || y == 0 || y == W - 1) {
        cout << "INF" << endl;
        return 0;
      }
      if (x % 2 == 0 || y % 2 == 0) continue;
      ans += (xs[x / 2 + 1] - xs[x / 2]) * (ys[y / 2 + 1] - ys[y / 2]);
    }
  cout << ans << endl;
  return 0;
}
