#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
template <typename T>
struct Compress {
  vector<T> xs;
  Compress() = default;
  Compress(const vector<T> &vs) { add(vs); }
  Compress(const initializer_list<vector<T> > &vs) {
    for (auto &p : vs) add(p);
  }
  void add(const vector<T> &vs) { copy(begin(vs), end(vs), back_inserter(xs)); }
  void add(const T &x) { xs.emplace_back(x); }
  void build() {
    sort(begin(xs), end(xs));
    xs.erase(unique(begin(xs), end(xs)), end(xs));
  }
  vector<int> get(const vector<T> &vs) const {
    vector<int> ret;
    transform(begin(vs), end(vs), back_inserter(ret), [&](const T &x) {
      return lower_bound(begin(xs), end(xs), x) - begin(xs);
    });
    return ret;
  }
  int get(const T &x) const {
    return lower_bound(begin(xs), end(xs), x) - begin(xs);
  }
  const T &operator[](int k) const { return xs[k]; }
};
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n), b(n), c(n);
  for (long long i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
  vector<long long> d(m), e(m), f(m);
  for (long long i = 0; i < m; i++) cin >> d[i] >> e[i] >> f[i];
  Compress<long long> X, Y;
  X.add(d);
  Y.add(c);
  const long long INF = 1e9 + 1;
  X.add(0);
  X.add(INF);
  X.add(-INF);
  Y.add(0);
  Y.add(INF);
  Y.add(-INF);
  X.build();
  Y.build();
  bool wall[m + 10][n + 10][4];
  for (long long i = 0; i < m + 10; i++)
    for (long long j = 0; j < n + 10; j++)
      for (long long k = 0; k < 4; k++) wall[i][j][k] = false;
  for (long long i = 0; i < n; i++) {
    long long y = Y.get(c[i]);
    long long x1, x2;
    x1 = X.get(a[i]);
    x2 = X.get(b[i]);
    for (long long j = x1; j < x2; j++) {
      wall[j][y - 1][2] = true;
      wall[j][y][3] = true;
    }
  }
  for (long long i = 0; i < m; i++) {
    long long x = X.get(d[i]);
    long long y1, y2;
    y1 = Y.get(e[i]);
    y2 = Y.get(f[i]);
    for (long long j = y1; j < y2; j++) {
      wall[x - 1][j][0] = true;
      wall[x][j][1] = true;
    }
  }
  bool visited[m + 10][n + 10];
  for (long long i = 0; i < m + 10; i++)
    for (long long j = 0; j < n + 10; j++) visited[i][j] = false;
  using P = pair<long long, long long>;
  queue<P> q;
  q.push(make_pair(X.get(0), Y.get(0)));
  visited[q.front().first][q.front().second] = true;
  long long ans = 0;
  while (!q.empty()) {
    P cur = q.front();
    q.pop();
    ans +=
        (X[cur.first + 1] - X[cur.first]) * (Y[cur.second + 1] - Y[cur.second]);
    for (long long i = 0; i < 4; i++) {
      P nxt = cur;
      if (wall[cur.first][cur.second][i]) continue;
      nxt.first += dx[i];
      nxt.second += dy[i];
      if (nxt.first == X.get(-INF) or nxt.second == X.get(INF) - 1 or
          nxt.second == Y.get(-INF) or nxt.second == Y.get(INF) - 1) {
        cout << "INF" << endl;
        return 0;
      }
      if (visited[nxt.first][nxt.second]) continue;
      visited[nxt.first][nxt.second] = true;
      q.push(nxt);
    }
  }
  cout << ans << endl;
}
