#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1000;
const int K = 6 * MAX_N + 2;
const int INF = 1e9 + 7;
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, 1, 0, -1};
int N, M;
int A[MAX_N], B[MAX_N], C[MAX_N], D[MAX_N], E[MAX_N], F[MAX_N];
int m[K][K];
vector<int> xs, ys;
void solve() {
  xs.push_back(0), xs.push_back(-INF);
  ys.push_back(0), ys.push_back(-INF);
  for (int i = 0; i < N; i++) {
    xs.push_back(A[i]), xs.push_back(A[i]);
    xs.push_back(B[i]), xs.push_back(B[i]);
    ys.push_back(C[i]), ys.push_back(C[i]);
  }
  for (int i = 0; i < M; i++) {
    xs.push_back(D[i]), xs.push_back(D[i]);
    ys.push_back(E[i]), ys.push_back(E[i]);
    ys.push_back(F[i]), ys.push_back(F[i]);
  }
  sort((xs).begin(), (xs).end());
  sort((ys).begin(), (ys).end());
  for (int i = 0; i < N; i++) {
    int a = lower_bound((xs).begin(), (xs).end(), A[i]) - xs.begin(),
        b = upper_bound((xs).begin(), (xs).end(), B[i]) - xs.begin() - 1,
        c = lower_bound((ys).begin(), (ys).end(), C[i]) - ys.begin();
    for (int x = a; x < b; x++) {
      m[x][c] = -1;
    }
  }
  for (int i = 0; i < M; i++) {
    int d = lower_bound((xs).begin(), (xs).end(), D[i]) - xs.begin(),
        e = lower_bound((xs).begin(), (xs).end(), E[i]) - xs.begin(),
        f = upper_bound((ys).begin(), (ys).end(), F[i]) - ys.begin() - 1;
    for (int y = e; y < f; y++) {
      m[d][y] = -1;
    }
  }
  long long int ans = 0;
  queue<pair<int, int> > q;
  int xz = lower_bound((xs).begin(), (xs).end(), 0) - xs.begin(),
      yz = lower_bound((ys).begin(), (ys).end(), 0) - ys.begin();
  q.push(pair<int, int>(xz, yz));
  while (!q.empty()) {
    int x = q.front().first, y = q.front().second;
    q.pop();
    if (x == -1 || x == K || y == -1 || y == K) {
      cout << "INF" << endl;
      return;
    }
    if (m[x][y] != 0) continue;
    m[x][y] = 1;
    ans += abs(xs[x + 1] - xs[x]) * abs(ys[y + 1] - ys[y]);
    for (int d = 0; d < 4; d++) {
      int nx = x + dx[d], ny = y + dy[d];
      q.push(pair<int, int>(nx, ny));
    }
  }
  cout << ans << endl;
}
int main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i] >> C[i];
  }
  for (int i = 0; i < M; i++) {
    cin >> D[i] >> E[i] >> F[i];
  }
  solve();
  return 0;
}
