#include <bits/stdc++.h>
using namespace std;
int const nax = 2e5 + 10;
int const N = 3005;
int n, m;
int x[nax], y[nax];
int top_x, top_y, nx, ny;
inline void upd_min(int &a, int b) { a = min(a, b); }
inline void upd_max(int &a, int b) { a = max(a, b); }
int a[N];
int b[N];
int c[N];
int d[N];
int e[N];
int f[N];
bool U[N][N];
bool D[N][N];
bool L[N][N];
bool R[N][N];
bool vis[N][N];
int find_x(int x) { return lower_bound(::x + 1, ::x + ::nx + 1, x) - ::x; }
int find_y(int y) { return lower_bound(::y + 1, ::y + ::ny + 1, y) - ::y; }
int min_x, max_x;
int min_y, max_y;
pair<int, int> q[N * N];
long long sum;
void BFS(int sx, int sy) {
  queue<pair<int, int>> q;
  q.emplace(sx, sy);
  vis[sx][sx] = true;
  for (; !q.empty(); q.pop()) {
    int x = q.front().first, y = q.front().second;
    upd_min(min_x, x);
    upd_max(max_x, x);
    upd_min(min_y, y);
    upd_max(max_y, y);
    long long area = 1LL * (::x[x + 1] - ::x[x]) * (::y[y + 1] - ::y[y]);
    sum += area;
    if (!L[x][y] && !vis[x - 1][y] && x > 1) {
      q.emplace(x - 1, y);
      vis[x - 1][y] = true;
    }
    if (!R[x][y] && !vis[x + 1][y] && x + 1 <= ::nx) {
      q.emplace(x + 1, y);
      vis[x + 1][y] = true;
    }
    if (!U[x][y] && !vis[x][y - 1] && y > 1) {
      q.emplace(x, y - 1);
      vis[x][y - 1] = true;
    }
    if (!D[x][y] && !vis[x][y + 1] && y + 1 <= ::ny) {
      q.emplace(x, y + 1);
      vis[x][y + 1] = true;
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%d %d %d", a + i, b + i, c + i);
    x[++top_x] = a[i];
    x[++top_x] = b[i];
    y[++top_y] = c[i];
  }
  const int lim = 1e9 + 7;
  x[++top_x] = lim;
  x[++top_x] = -lim, x[++top_x] = 0;
  y[++top_y] = lim;
  y[++top_y] = -lim, y[++top_y] = 0;
  for (int i = 1; i <= m; ++i) {
    scanf("%d %d %d", d + i, e + i, f + i);
    x[++top_x] = d[i];
    y[++top_y] = e[i];
    y[++top_y] = f[i];
  }
  sort(x + 1, x + top_x + 1);
  sort(y + 1, y + top_y + 1);
  nx = unique(x + 1, x + top_x + 1) - x - 1;
  ny = unique(y + 1, y + top_y + 1) - y - 1;
  for (int i = 1; i <= n; ++i) {
    int x1 = find_x(a[i]);
    int x2 = find_x(b[i]);
    int y = find_y(c[i]);
    for (int j = x1; j < x2; ++j) {
      U[j][y] = D[j][y - 1] = true;
    }
  }
  for (int i = 1; i <= m; ++i) {
    int x = find_x(d[i]);
    int y1 = find_y(e[i]);
    int y2 = find_y(f[i]);
    for (int j = y1; j < y2; ++j) {
      L[x][j] = R[x - 1][j] = true;
    }
  }
  int sx = find_x(0), sy = find_y(0);
  min_x = nx + 1, max_x = 0;
  min_y = ny + 1, min_y = 0;
  BFS(sx, sy);
  if (min_x == 1 || max_x == nx || min_y == 1 || max_y == ny) {
    puts("INF");
  } else {
    printf("%lld\n", sum);
  }
}
