#include <bits/stdc++.h>
using namespace std;
const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;
template <typename T>
inline void read(T &x) {
  char ch, t = 0;
  x = 0;
  while (!isdigit(ch = (iS == iT
                            ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                               (iS == iT ? EOF : *iS++))
                            : *iS++)))
    t |= ch == '-';
  while (isdigit(ch))
    x = x * 10 + (ch ^ 48),
    ch = (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin),
                      (iS == iT ? EOF : *iS++))
                   : *iS++);
  x = t ? -x : x;
}
inline int read_int() {
  int x;
  return read(x), x;
}
inline long long read_ll() {
  long long x;
  return read(x), x;
}
template <typename T>
inline void chkmin(T &a, T b) {
  a = a < b ? a : b;
}
template <typename T>
inline void chkmax(T &a, T b) {
  a = a > b ? a : b;
}
int a[1010];
int b[1010];
int c[1010];
int d[1010];
int e[1010];
int f[1010];
int x[3030];
int y[3030];
int L[3030][3030];
int R[3030][3030];
int U[3030][3030];
int D[3030][3030];
int vis[3030][3030];
long long res;
int mix;
int mxx;
int miy;
int mxy;
int N, M;
inline int px(int v) { return lower_bound(x + 1, x + 1 + N, v) - x; }
inline int py(int v) { return lower_bound(y + 1, y + 1 + N, v) - y; }
inline void BFS(int p, int q) {
  queue<int> P, Q;
  P.push(p), Q.push(q);
  vis[p][q] = 1;
  while (!P.empty()) {
    p = P.front(), q = Q.front(), P.pop(), Q.pop();
    chkmin(mix, p), chkmax(mxx, p);
    chkmin(miy, q), chkmax(mxy, q);
    res += 1LL * (x[p + 1] - x[p]) * (y[q + 1] - y[q]);
    cerr << x[p] << ' ' << x[q] << ' ' << res << endl;
    int tp, tq;
    tp = p - 1, tq = q;
    if (!L[p][q] && !vis[tp][tq] && tp >= 1) {
      vis[tp][tq] = 1;
      P.push(tp), Q.push(tq);
    }
    tp = p + 1, tq = q;
    if (!R[p][q] && !vis[tp][tq] && tp <= N) {
      vis[tp][tq] = 1;
      P.push(tp), Q.push(tq);
    }
    tp = p, tq = q - 1;
    if (!U[p][q] && !vis[tp][tq] && tq >= 1) {
      vis[tp][tq] = 1;
      P.push(tp), Q.push(tq);
    }
    tp = p, tq = q + 1;
    if (!D[p][q] && !vis[tp][tq] && tq <= M) {
      vis[tp][tq] = 1;
      P.push(tp), Q.push(tq);
    }
  }
}
int main() {
  int n = read_int(), m = read_int();
  x[++N] = 0, x[++N] = -1000000001, x[++N] = 1000000001;
  y[++M] = 0, y[++M] = -1000000001, y[++M] = 1000000001;
  for (int i = 1; i <= n; i++) {
    x[++N] = a[i] = read_int();
    x[++N] = b[i] = read_int();
    y[++M] = c[i] = read_int();
  }
  for (int i = 1; i <= m; i++) {
    x[++N] = d[i] = read_int();
    y[++M] = e[i] = read_int();
    y[++M] = f[i] = read_int();
  }
  sort(x + 1, x + 1 + N);
  sort(y + 1, y + 1 + M);
  N = unique(x + 1, x + 1 + N) - x - 1;
  M = unique(y + 1, y + 1 + M) - y - 1;
  mix = N + 1, mxx = 0;
  miy = M + 1, mxy = 0;
  for (int i = 1; i <= n; i++) {
    a[i] = lower_bound(x + 1, x + 1 + N, a[i]) - x;
    b[i] = lower_bound(x + 1, x + 1 + N, b[i]) - x;
    c[i] = lower_bound(y + 1, y + 1 + M, c[i]) - y;
    for (int j = a[i]; j < b[i]; j++) U[j][c[i]] = D[j][c[i] - 1] = 1;
  }
  for (int i = 1; i <= m; i++) {
    d[i] = lower_bound(x + 1, x + 1 + N, d[i]) - x;
    e[i] = lower_bound(y + 1, y + 1 + M, e[i]) - y;
    f[i] = lower_bound(y + 1, y + 1 + M, f[i]) - y;
    for (int j = e[i]; j < f[i]; j++) L[d[i]][j] = R[d[i] - 1][j] = 1;
  }
  int x = px(0), y = py(0);
  BFS(x, y);
  if (mix == 1 || mxx == N || miy == 1 || mxy == M)
    puts("INF");
  else
    printf("%lld\n", res);
  return 0;
}
