#include <bits/stdc++.h>
using namespace std;
int N, M;
long long int A[1050], B[1050], C[1050], D[1050], E[1050], F[1050];
set<long long int> SX, SY;
long long int INF = 9999999999;
vector<long long int> X;
vector<long long int> Y;
map<long long int, int> NX, NY;
int num_X, num_Y;
set<pair<int, int>> Xp, Xm, Yp, Ym;
vector<pair<int, int>> Adj[4050][4050];
queue<pair<int, int>> Q;
int used[4050][4050];
int main(void) {
  cin >> N >> M;
  for (int i = 1; i <= N; i++) {
    cin >> A[i] >> B[i] >> C[i];
    SX.insert(A[i]);
    SX.insert(B[i]);
    SY.insert(C[i]);
  }
  for (int i = 1; i <= M; i++) {
    cin >> D[i] >> E[i] >> F[i];
    SX.insert(D[i]);
    SY.insert(E[i]);
    SY.insert(F[i]);
  }
  SX.insert(0);
  SY.insert(0);
  X.push_back(-INF);
  num_X = 0;
  for (auto v : SX) {
    NX[v] = X.size();
    num_X++;
    X.push_back(v);
  }
  Y.push_back(-INF);
  num_Y = 0;
  for (auto v : SY) {
    NY[v] = Y.size();
    num_Y++;
    Y.push_back(v);
  }
  for (int k = 1; k <= N; k++) {
    int j = NY[C[k]] - 1;
    for (int i = 1; i <= num_X - 1; i++) {
      long long int a = X[i];
      long long int b = X[i + 1];
      if (A[k] <= a && b <= B[k]) {
        Yp.insert(make_pair(i, j));
        Ym.insert(make_pair(i, j + 1));
      }
    }
  }
  for (int k = 1; k <= M; k++) {
    int i = NX[D[k]] - 1;
    for (int j = 1; j <= num_Y - 1; j++) {
      long long int e = Y[j];
      long long int f = Y[j + 1];
      if (E[k] <= e && f <= F[k]) {
        Xp.insert(make_pair(i, j));
        Xm.insert(make_pair(i + 1, j));
      }
    }
  }
  for (int i = 0; i <= num_X; i++) {
    for (int j = 0; j <= num_Y; j++) {
      if (Xm.count(make_pair(i, j)) == 0 && i >= 1) {
        Adj[i][j].push_back(make_pair(i - 1, j));
      }
      if (Xp.count(make_pair(i, j)) == 0) {
        Adj[i][j].push_back(make_pair(i + 1, j));
      }
      if (Ym.count(make_pair(i, j)) == 0 && j >= 1) {
        Adj[i][j].push_back(make_pair(i, j - 1));
      }
      if (Yp.count(make_pair(i, j)) == 0) {
        Adj[i][j].push_back(make_pair(i, j + 1));
      }
    }
  }
  Q.push(make_pair(NX[0], NY[0]));
  used[NX[0]][NY[0]] = 1;
  int sign = 1;
  for (int i = 0; i <= num_X; i++) {
    if (used[i][0] == 1 || used[i][num_Y] == 1) {
      sign = -1;
    }
  }
  for (int j = 0; j <= num_Y; j++) {
    if (used[0][j] == 1 || used[num_X][j] == 1) {
      sign = -1;
    }
  }
  long long int ans = 0;
  for (int i = 1; i <= num_X - 1; i++) {
    for (int j = 1; j <= num_Y; j++) {
      if (used[i][j] == 1) {
        ans += (X[i + 1] - X[i]) * (Y[j + 1] - Y[j]);
      }
    }
  }
  if (sign == -1) {
    cout << "INF" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}
