#include <bits/stdc++.h>
using namespace std;
template <typename T>
using reversed_priority_queue =
    std::priority_queue<T, std::vector<T>, std::greater<T> >;
class UnionFind {
 public:
  int n;
  std::vector<int> par;
  std::vector<int> num;
  explicit UnionFind(int n) {
    this->n = n;
    this->par.resize(n);
    this->num.resize(n, 1);
    for (int i = 0; i < n; i++) {
      this->par[i] = i;
    }
  }
  int root(int i) {
    if (par[i] == i)
      return i;
    else
      return par[i] = root(par[i]);
  }
  bool same(int i, int j) { return root(i) == root(j); }
  bool unite(int i, int j) {
    int t = root(i);
    int k = root(j);
    if (t == k) return false;
    par[t] = k;
    num[k] += num[t];
    return true;
  }
  int size(int i) { return num[root(i)]; }
};
long long int cellID(long long int tx, long long int ty) {
  return tx * 4000 + ty;
}
UnionFind uf(4000 * 4000);
struct T1 {
  long long int x0, x1;
  long long int y;
  T1(long long int x0, long long int x1, long long int y)
      : x0(x0), x1(x1), y(y) {}
};
struct T2 {
  long long int y0, y1;
  long long int x;
  T2(long long int y0, long long int y1, long long int x)
      : y0(y0), y1(y1), x(x) {}
};
long long int N, M, X, Y;
vector<T1> hline;
vector<T2> vline;
set<long long int> xs, ys;
map<long long int, long long int> ox, tx;
map<long long int, long long int> oy, ty;
const long long int U = 0, D = 1, L = 2, R = 3;
const long long int dx[4] = {0, 0, -1, 1};
const long long int dy[4] = {-1, 1, 0, 0};
bool block[4000][4000][4];
const long long int INF = LLONG_MAX;
unsigned long long int area[4000][4000];
unsigned long long int total_area[4000 * 4000];
signed main() {
  cin >> N >> M;
  xs.insert(0);
  ys.insert(0);
  for (long long int i = static_cast<long long int>(0);
       i < static_cast<long long int>(N); ++i) {
    long long int x0, x1, y;
    cin >> x0 >> x1 >> y;
    hline.emplace_back(x0, x1, y);
    xs.insert(x0);
    xs.insert(x1);
    ys.insert(y);
  }
  for (long long int i = static_cast<long long int>(0);
       i < static_cast<long long int>(M); ++i) {
    long long int x, y0, y1;
    cin >> x >> y0 >> y1;
    vline.emplace_back(y0, y1, x);
    xs.insert(x);
    ys.insert(y0);
    ys.insert(y1);
  }
  {
    long long int i = 0;
    for (auto t : xs) {
      ox[i] = t;
      tx[t] = i;
      i++;
    }
    X = i;
    i = 0;
    for (auto t : ys) {
      oy[i] = t;
      ty[t] = i;
      i++;
    }
    Y = i;
  }
  for (long long int i = static_cast<long long int>(0);
       i < static_cast<long long int>(N); ++i) {
    auto [x0, x1, y0] = hline[i];
    long long int tx0 = tx[x0], tx1 = tx[x1], ty0 = ty[y0];
    for (long long int tx = tx0; tx < tx1; tx++) {
      if (ty0 - 1 >= 0) block[tx][ty0 - 1][D] = true;
      if (ty0 < Y - 1) block[tx][ty0][U] = true;
    }
  }
  for (long long int i = static_cast<long long int>(0);
       i < static_cast<long long int>(M); ++i) {
    auto [y0, y1, x0] = vline[i];
    long long int ty0 = ty[y0], ty1 = ty[y1], tx0 = tx[x0];
    for (long long int ty = ty0; ty < ty1; ty++) {
      if (tx0 - 1 >= 0) block[tx0 - 1][ty][R] = true;
      if (tx0 < X - 1) block[tx0][ty][L] = true;
    }
  }
  for (long long int tx = static_cast<long long int>(0);
       tx < static_cast<long long int>(X - 1); ++tx) {
    for (long long int ty = static_cast<long long int>(0);
         ty < static_cast<long long int>(Y - 1); ++ty) {
      long long int l = ox[tx], r = ox[tx + 1];
      long long int u = ox[ty], d = ox[ty + 1];
      area[tx][ty] = (r - l) * (d - u);
      long long int cid1 = cellID(tx, ty);
      for (long long int k = static_cast<long long int>(0);
           k < static_cast<long long int>(4); ++k) {
        if (block[tx][ty][k]) continue;
        long long int tx2 = tx + dx[k];
        long long int ty2 = ty + dy[k];
        if (tx2 < 0 || ty2 < 0 || tx2 > X - 2 || ty2 > Y - 2) {
          area[tx][ty] = INF;
        } else {
          long long int cid2 = cellID(tx2, ty2);
          uf.unite(cid1, cid2);
        }
      }
    }
  }
  for (long long int tx = static_cast<long long int>(0);
       tx < static_cast<long long int>(X - 1); ++tx) {
    for (long long int ty = static_cast<long long int>(0);
         ty < static_cast<long long int>(Y - 1); ++ty) {
      long long int cid = cellID(tx, ty);
      if (total_area[uf.root(cid)] == INF || area[tx][ty] == INF)
        total_area[uf.root(cid)] = INF;
      else
        total_area[uf.root(cid)] += area[tx][ty];
    }
  }
  long long int cid = cellID(tx[0], ty[0]);
  long long int ans = total_area[uf.root(cid)];
  if (ans == INF) {
    cout << "INF" << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}
