#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &A) {
  for (long long i = 0; i < A.size(); i++) os << A[i] << " ";
  os << endl;
  return os;
}
template <>
ostream &operator<<(ostream &os, const vector<vector<long long> > &A) {
  long long N = A.size();
  for (long long i = 0; i < N; i++) {
    for (long long j = 0; j < A[i].size(); j++) os << A[i][j] << " ";
    os << endl;
  }
  return os;
}
struct edge {
  long long from, to, d, c;
  edge(long long _from = 0, long long _to = 0, long long _d = 0,
       long long _c = 0) {
    from = _from;
    to = _to;
    d = _d;
    c = _c;
  }
  bool operator<(const edge &rhs) const {
    return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
  }
};
struct aabb {
  long long x1, y1, x2, y2;
  aabb(long long x1, long long y1, long long x2, long long y2)
      : x1(x1), y1(y1), x2(x2), y2(y2) {}
};
struct flow {
  long long to, cap, rev, cost;
  flow(long long to = 0, long long cap = 0, long long rev = 0,
       long long cost = 0)
      : to(to), cap(cap), rev(rev), cost(cost) {}
};
const long long di[4] = {0, -1, 0, 1};
const long long dj[4] = {-1, 0, 1, 0};
const long long ci[5] = {0, 0, -1, 0, 1};
const long long cj[5] = {0, -1, 0, 1, 0};
const long long LINF = LLONG_MAX / 2;
const long long INF = INT_MAX / 2;
const long double PI = acos(-1);
long long pow2(long long n) { return 1LL << n; }
template <typename T, typename U>
bool chmin(T &x, const U &y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template <typename T, typename U>
bool chmax(T &x, const U &y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}
struct initializer {
  initializer() { cout << fixed << setprecision(20); }
};
initializer _____;
long long N, M, K, T, Q, H, W;
signed main() {
  cin >> N >> M;
  vector<long long> A(N), B(N), C(N);
  vector<long long> D(M), E(M), F(M);
  for (long long i = 0; i < (long long)(N); i++) cin >> A[i] >> B[i] >> C[i];
  for (long long i = 0; i < (long long)(M); i++) cin >> D[i] >> E[i] >> F[i];
  vector<long long> x, y;
  for (long long i = 0; i < (long long)(N); i++) {
    x.push_back(A[i]);
    x.push_back(B[i]);
    y.push_back(C[i]);
  }
  for (long long i = 0; i < (long long)(M); i++) {
    x.push_back(D[i]);
    y.push_back(E[i]);
    y.push_back(F[i]);
  }
  sort(x.begin(), x.end());
  x.erase(unique(x.begin(), x.end()), x.end());
  sort(y.begin(), y.end());
  y.erase(unique(y.begin(), y.end()), y.end());
  W = x.size();
  H = y.size();
  K = (H + 1) * (W + 1);
  vector<vector<long long> > G(K, vector<long long>(K, 1));
  for (long long i = 0; i < (long long)(K); i++) G[i][i] = 0;
  vector<long long> S(K);
  for (long long i = 0; i < (long long)(H + 1); i++)
    for (long long j = 0; j < (long long)(W + 1); j++) {
      if (i == 0 || i == H || j == 0 || j == W) {
        S[i * W + j] = LINF;
      } else {
        S[i * W + j] = (y[i] - y[i - 1]) * (x[j] - x[j - 1]);
      }
    }
  for (long long i = 0; i < (long long)(N); i++) {
    long long Y = lower_bound(y.begin(), y.end(), C[i]) - y.begin();
    long long j = lower_bound(x.begin(), x.end(), A[i]) - x.begin();
    while (x[j] < B[i]) {
      long long a = Y * W + j + 1;
      long long b = (Y + 1) * W + j + 1;
      G[a][b] = 0;
      G[b][a] = 0;
      j++;
    }
  }
  for (long long i = 0; i < (long long)(M); i++) {
    long long X = lower_bound(x.begin(), x.end(), D[i]) - x.begin();
    long long j = lower_bound(y.begin(), y.end(), E[i]) - y.begin();
    while (y[j] < F[i]) {
      long long a = (j + 1) * W + X;
      long long b = (j + 1) * W + X + 1;
      G[a][b] = 0;
      G[b][a] = 0;
      j++;
    }
  }
  long long ans = 0;
  long long sx = lower_bound(x.begin(), x.end(), 0) - x.begin();
  long long sy = lower_bound(y.begin(), y.end(), 0) - y.begin();
  long long s = sy * W + sx;
  vector<long long> done(K, 0);
  queue<long long> q;
  done[s] = 1;
  q.push(s);
  while (!q.empty()) {
    long long a = q.front();
    q.pop();
    if (S[a] == LINF) {
      cout << "INF" << endl;
      return 0;
    } else {
      ans += S[a];
    }
    long long x = a % W;
    long long y = a / W;
    for (long long k = 0; k < (long long)(4); k++) {
      long long nx = x + dj[k];
      long long ny = y + di[k];
      long long j = ny * W + nx;
      if (0 <= nx && nx < W + 1 && 0 <= ny && ny < H + 1 && G[a][j] &&
          (!done[j])) {
        done[j] = 1;
        q.push(j);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
