#include <bits/stdc++.h>
void compress(std::vector<int>& xSet, std::vector<int>& deCompX);
int getCompressedVal(std::vector<int> xSet, int xRaw);
int find_CmpIdx(std::vector<int> compX, int X);
int RegionID(int x, int y, int ySize);
int root(int a, std::vector<int>& par);
void Unite(int a, int b, std::vector<int>& par);
bool isSame(int a, int b, std::vector<int>& par);
int getArea(int RegionID, int ySize, std::vector<int>& deCompX,
            std::vector<int>& deCompY);
int main() {
  int M, N;
  std::cin >> N >> M;
  std::vector<int> X(0), Y(0);
  std::vector<int> A(N + 1, 0), B(N + 1, 0), C(N + 1, 0), D(M + 1, 0),
      E(M + 1, 0), F(M + 1, 0);
  X.push_back(0);
  Y.push_back(0);
  X.push_back(10000000000);
  X.push_back(-10000000000);
  Y.push_back(10000000000);
  Y.push_back(-10000000000);
  for (int i = 1; i < N + 1; i++) {
    std::cin >> A[i] >> B[i] >> C[i];
    X.push_back(A[i]);
    X.push_back(B[i]);
    Y.push_back(C[i]);
  }
  for (int i = 1; i < M + 1; i++) {
    std::cin >> D[i] >> E[i] >> F[i];
    X.push_back(D[i]);
    Y.push_back(E[i]);
    Y.push_back(F[i]);
  }
  std::vector<int> deCompX(X.size()), deCompY(Y.size());
  compress(X, deCompX);
  compress(Y, deCompY);
  for (int i = 1; i < N + 1; i++) {
    A[i] = getCompressedVal(X, A[i]);
    B[i] = getCompressedVal(X, B[i]);
    C[i] = getCompressedVal(Y, C[i]);
  }
  for (int i = 1; i < M + 1; i++) {
    D[i] = getCompressedVal(Y, D[i]);
    E[i] = getCompressedVal(Y, E[i]);
    F[i] = getCompressedVal(X, F[i]);
  }
  std::vector<std::vector<bool>> aboveLine(X.size(),
                                           std::vector<bool>(Y.size(), 0));
  std::vector<std::vector<bool>> leftLine(X.size(),
                                          std::vector<bool>(Y.size(), 0));
  for (int i = 1; i < N + 1; i++) {
    for (int j = A[i]; j < B[i]; j++) {
      leftLine[j][C[i]] = true;
    }
  }
  for (int i = 1; i < M + 1; i++) {
    for (int j = E[i]; j < F[i]; j++) {
      aboveLine[D[i]][j] = true;
    }
  }
  std::vector<int> par(X.size() * Y.size() + 1);
  for (std::vector<int>::size_type i = 1; i <= par.size(); i++) {
    par[i] = i;
  }
  for (int i = X.size() - 1; i >= 0; i--) {
    for (int j = Y.size() - 1; j > 0; j--) {
      if (i != 0) {
        if (aboveLine[i][j] == false) {
          Unite(RegionID(i, j, Y.size()), RegionID(i - 1, j, Y.size()), par);
        }
      }
      if (leftLine[i][j] == false) {
        Unite(RegionID(i, j, Y.size()), RegionID(i, j - 1, Y.size()), par);
      }
    }
  }
  int cowCompX = getCompressedVal(X, 0);
  int cowCompY = getCompressedVal(Y, 0);
  int L_infID = RegionID(0, 0, Y.size());
  if (isSame(RegionID(cowCompX, cowCompY, Y.size()), L_infID, par) == true) {
    std::cout << "INF";
  } else {
    int totalArea = 0;
    for (std::vector<int>::size_type i = 0; i < X.size(); i++) {
      for (std::vector<int>::size_type j = 0; j < Y.size(); j++) {
        if (isSame(RegionID(cowCompX, cowCompY, Y.size()),
                   RegionID(i, j, Y.size()), par) == true) {
          totalArea +=
              getArea(RegionID(i, j, Y.size()), Y.size(), deCompX, deCompY);
        }
      }
    }
    std::cout << totalArea;
  }
  return 0;
}
void compress(std::vector<int>& xSet, std::vector<int>& deCompX) {
  std::sort(xSet.begin(), xSet.end());
  xSet.erase(std::unique(xSet.begin(), xSet.end()), xSet.end());
  for (std::vector<int>::size_type i = 1; i < xSet.size(); i++) {
    deCompX[i] = xSet[i];
  }
  return;
}
int getCompressedVal(std::vector<int> xSet, int xRaw) {
  return std::lower_bound(xSet.begin(), xSet.end(), xRaw) - xSet.begin();
}
int find_CmpIdx(std::vector<int> compX, int X) {
  int idx = std::lower_bound(compX.begin(), compX.end(), X) - compX.begin();
  return idx;
}
int RegionID(int x, int y, int ySize) { return x * (ySize - 1) + y; }
int root(int a, std::vector<int>& par) {
  if (par[a] == a) {
    return a;
  } else {
    int ra = root(par[a], par);
    par[a] = ra;
    return ra;
  }
}
void Unite(int a, int b, std::vector<int>& par) {
  int ra = root(a, par);
  int rb = root(b, par);
  if (ra == rb) {
    return;
  } else {
    par[ra] = rb;
  }
  return;
}
bool isSame(int a, int b, std::vector<int>& par) {
  int ra = root(a, par);
  int rb = root(b, par);
  return ra == rb;
}
int getArea(int RegionID, int ySize, std::vector<int>& deCompX,
            std::vector<int>& deCompY) {
  int x, y;
  y = RegionID % (ySize - 1);
  x = (RegionID - y) / (ySize - 1);
  return (deCompX[x + 1] - deCompX[x]) * (deCompY[y + 1] - deCompY[y]);
}
