#include <bits/stdc++.h>
using namespace std;
class compress {
 private:
  std::vector<long long> E;
  std::map<long long, long long> G;

 public:
  void init(std::vector<long long> A) {
    E.clear();
    sort(A.begin(), A.end());
    for (long long i = 0; i < A.size(); i++) {
      if (i == 0 || A[i] != A[i - 1]) {
        E.push_back(A[i]);
        G[A[i]] = (long long)E.size();
      }
    }
  }
  long long size() { return (long long)E.size(); }
  long long value(long long x) {
    if (0 <= x && x < (long long)E.size()) {
      return E[x];
    } else {
      return 0;
    }
  }
  long long index(long long X) {
    return (upper_bound(E.begin(), E.end(), X)) - E.begin() - 1;
  }
};
signed main(void) {
  long long N, M;
  vector<long long> A, B, C, D, E, F;
  vector<long long> x, y;
  cin >> N >> M;
  for (long long i = 0; i < (N); ++i) {
    long long a;
    cin >> a;
    A.push_back(a);
    x.push_back(a);
    cin >> a;
    B.push_back(a);
    x.push_back(a);
    cin >> a;
    C.push_back(a);
    y.push_back(a);
  }
  for (long long i = 0; i < (M); ++i) {
    long long a;
    cin >> a;
    D.push_back(a);
    x.push_back(a);
    cin >> a;
    E.push_back(a);
    y.push_back(a);
    cin >> a;
    F.push_back(a);
    y.push_back(a);
  }
  x.push_back(-1145141919810893364);
  x.push_back(1145141919810893364);
  y.push_back(-1145141919810893364);
  y.push_back(1145141919810893364);
  compress X, Y;
  X.init(x);
  Y.init(y);
  const long long MEM = 320;
  bool wallx[MEM][MEM] = {}, wally[MEM][MEM] = {};
  for (long long i = 0; i < (N); ++i) {
    long long a = X.index(A[i]);
    long long b = X.index(B[i]);
    long long c = Y.index(C[i]);
    for (long long i = a; i < b; i++) {
      wally[c][i] = true;
    }
  }
  for (long long i = 0; i < (M); ++i) {
    long long d = X.index(D[i]);
    long long e = Y.index(E[i]);
    long long f = Y.index(F[i]);
    for (long long i = e; i < f; i++) {
      wallx[i][d] = true;
    }
  }
  long long Ans = 0;
  queue<pair<long long, long long>> que;
  bool Map[MEM][MEM];
  long long xs = X.index(0), ys = Y.index(0);
  que.push({xs, ys});
  Map[xs][ys] = true;
  bool infinity = false;
  long long dx[4] = {1, 0, -1, 0};
  long long dy[4] = {0, 1, 0, -1};
  while (!que.empty()) {
    long long s = que.front().first;
    long long t = que.front().second;
    que.pop();
    long long Xe = (X.value(s + 1) - X.value(s));
    long long Ye = (Y.value(t + 1) - Y.value(t));
    if (X.value(s + 1) == 1145141919810893364 ||
        X.value(s) == -1145141919810893364) {
      infinity = true;
    }
    if (Y.value(t + 1) == 1145141919810893364 ||
        Y.value(t) == -1145141919810893364) {
      infinity = true;
    }
    Ans += Xe * Ye;
    for (long long k = 0; k < (4); ++k) {
      if (s + dx[k] < 0 || X.size() <= s + dx[k]) {
        continue;
      }
      if (t + dy[k] < 0 || Y.size() <= t + dy[k]) {
        continue;
      }
      if (k == 0 && wallx[t][s + 1]) {
        continue;
      }
      if (k == 1 && wally[t + 1][s]) {
        continue;
      }
      if (k == 2 && wallx[t][s]) {
        continue;
      }
      if (k == 3 && wally[t][s]) {
        continue;
      }
      if (!Map[s + dx[k]][t + dy[k]]) {
        Map[s + dx[k]][t + dy[k]] = true;
        que.push({s + dx[k], t + dy[k]});
      }
    }
  }
  if (infinity) {
    cout << "INF" << endl;
  } else {
    cout << Ans << endl;
  }
  return 0;
}
