#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;
int MXp[4050][4050], MXm[4050][4050], MYp[4050][4050], MYm[4050][4050];
vector<pair<int, int>> Adj[4050][4050];
queue<pair<int, int>> Q;
int used[4050][4050];
void visit(int Px, int Py) {
  used[Px][Py] = 1;
  if (Px - 1 >= 0 && used[Px - 1][Py] == 0 && MXm[Px][Py] != -1) {
    visit(Px - 1, Py);
  }
  if (Px + 1 <= num_X && used[Px + 1][Py] == 0 && MXp[Px][Py] != -1) {
    visit(Px + 1, Py);
  }
  if (Py - 1 >= 0 && used[Px][Py - 1] == 0 && MYm[Px][Py] != -1) {
    visit(Px, Py - 1);
  }
  if (Py + 1 <= num_Y && used[Px][Py + 1] == 0 && MYp[Px][Py] != -1) {
    visit(Px, Py + 1);
  }
}
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]) {
        MYp[i][j] = -1;
        MYm[i][j + 1] = -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]) {
        MXp[i][j] = -1;
        MXm[i + 1][j] = -1;
      }
    }
  }
  visit(NX[0], NY[0]);
  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;
}
