#include <bits/stdc++.h>
using namespace std;
const int N = 3005;
int n, m, nr, nc;
unordered_map<int, int> fr, fc;
long long ans, A[N], B[N], C[N], D[N], E[N], F[N], r[N], c[N], a[N][N];
bool vis1[N][N], vis2[N][N], vis[N][N];
long long area(int i, int j) { return (r[i + 1] - r[i]) * (c[j + 1] - c[j]); }
bool up(int i, int j) { return !vis2[i][j]; }
bool down(int i, int j) { return !vis2[i + 1][j]; }
bool left(int i, int j) { return !vis1[i][j]; }
bool right(int i, int j) { return !vis1[i][j + 1]; }
void add(long long x) {
  if (x == 0x3f3f3f3f3f3f3f3fll || ans + x >= 0x3f3f3f3f3f3f3f3fll) {
    printf("INF\n");
    exit(0);
  }
  ans += x;
}
bool count0(int i, int j) {
  return r[i] <= 0 && r[i + 1] >= 0 && c[j] <= 0 && c[j + 1] >= 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++)
    scanf("%lld%lld%lld", &A[i], &B[i], &C[i]), r[++nr] = A[i], r[++nr] = B[i],
                                                c[++nc] = C[i];
  for (int i = 1; i <= m; i++)
    scanf("%lld%lld%lld", &D[i], &E[i], &F[i]), c[++nc] = F[i], c[++nc] = E[i],
                                                r[++nr] = D[i];
  sort(r + 1, r + 1 + nr);
  sort(c + 1, c + 1 + nc);
  nr = unique(r + 1, r + 1 + nr) - r - 1;
  nc = unique(c + 1, c + 1 + nc) - c - 1;
  for (int i = 1; i <= nr; i++) fr[r[i]] = i;
  for (int i = 1; i <= nc; i++) fc[c[i]] = i;
  if (nr == 1 || nc == 1) {
    printf("INF\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    int l = fr[A[i]], r = fr[B[i]], x = fc[C[i]];
    for (int j = l; j < r; j++) vis1[j][x] = true;
  }
  for (int i = 1; i <= m; i++) {
    int l = fc[E[i]], r = fc[F[i]], x = fr[D[i]];
    for (int j = l; j < r; j++) vis2[x][j] = true;
  }
  queue<pair<int, int>> q;
  for (int i = 1; i < nr; i++)
    for (int j = 1; j < nc; j++) {
      a[i][j] = area(i, j);
      if (up(i, j) && i == 1 || down(i, j) && i == nr - 1 ||
          left(i, j) && j == 1 || right(i, j) && j == nc - 1)
        a[i][j] = 0x3f3f3f3f3f3f3f3fll;
      if (count0(i, j)) {
        add(a[i][j]);
        q.push({i, j});
        vis[i][j] = true;
      }
    }
  while (!q.empty()) {
    int i = q.front().first, j = q.front().second;
    q.pop();
    if (up(i, j) && !vis[i - 1][j]) {
      add(a[i - 1][j]);
      vis[i - 1][j] = true;
      q.push({i - 1, j});
    }
    if (down(i, j) && !vis[i + 1][j]) {
      add(a[i + 1][j]);
      vis[i + 1][j] = true;
      q.push({i + 1, j});
    }
    if (left(i, j) && !vis[i][j - 1]) {
      add(a[i][j - 1]);
      vis[i][j - 1] = true;
      q.push({i, j - 1});
    }
    if (right(i, j) && !vis[i][j + 1]) {
      add(a[i][j + 1]);
      vis[i][j + 1] = true;
      q.push({i, j + 1});
    }
  }
  printf("%lld\n", ans);
}
