#include <bits/stdc++.h>
using namespace std;
template <typename T>
map<T, int> compress(vector<T> &vec) {
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  map<T, int> dict;
  for (int i = 0; i < vec.size(); i++) {
    dict[vec[i]] = i;
  }
  return dict;
}
int A[200010], B[200010], C[200010], D[200010], E[200010], F[200010];
int main() {
  int N, M;
  vector<int> vecx, vecy;
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; i++) {
    scanf("%d%d%d", A + i, B + i, C + i);
    vecy.push_back(A[i]);
    vecy.push_back(B[i]);
    vecx.push_back(C[i]);
  }
  for (int i = 0; i < M; i++) {
    scanf("%d%d%d", D + i, E + i, F + i);
    vecy.push_back(D[i]);
    vecx.push_back(E[i]);
    vecx.push_back(F[i]);
  }
  vecx.push_back(-1000000000);
  vecx.push_back(1000000000);
  vecy.push_back(-1000000000);
  vecy.push_back(1000000000);
  auto dictX = compress(vecx);
  auto dictY = compress(vecy);
  int W = vecx.size() - 1;
  int H = vecy.size() - 1;
  vector<vector<int>> visited(H, vector<int>(W));
  queue<pair<int, int>> que;
  for (int i = 0; i < H; i++) {
    if (!(vecy[i] <= 0 && 0 <= vecy[i + 1])) continue;
    for (int j = 0; j < W; j++) {
      if (vecx[j] <= 0 && 0 <= vecx[j + 1]) {
        que.push({i, j});
      }
    }
  }
  vector<vector<int>> bV(H + 1, vector<int>(W + 1)),
      bH(H + 1, vector<int>(W + 1));
  for (int i = 0; i < N; i++) {
    bV[dictY[A[i]]][dictX[C[i]]]++;
    bV[dictY[B[i]]][dictX[C[i]]]--;
  }
  for (int i = 0; i < M; i++) {
    bH[dictY[D[i]]][dictX[E[i]]]++;
    bH[dictY[D[i]]][dictX[F[i]]]--;
  }
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      bH[i][j + 1] += bH[i][j];
      bV[i + 1][j] += bV[i][j];
    }
  }
  long long ans = 0;
  while (que.size()) {
    auto p = que.front();
    que.pop();
    int y = p.first;
    int x = p.second;
    if (visited[y][x]) continue;
    visited[y][x] = true;
    if (y == 0 || y == H - 1 || x == 0 || x == W - 1) {
      cout << "INF" << endl;
      return 0;
    }
    ans += (long long)(vecx[x + 1] - vecx[x]) * (vecy[y + 1] - vecy[y]);
    ;
    ;
    ;
    ;
    if (x + 1 < W && !bV[y][x + 1]) {
      que.push({y, x + 1});
    }
    if (0 <= x - 1 && !bV[y][x]) {
      que.push({y, x - 1});
    }
    if (0 <= y - 1 && !bH[y][x]) {
      que.push({y - 1, x});
    }
    if (y + 1 < H && !bH[y + 1][x]) {
      que.push({y + 1, x});
    }
  }
  printf("%lld\n", ans);
  return 0;
}
