#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;
}
template <class T>
struct Zip {
  vector<T> val;
  unordered_map<T, long long> idx;
  void add(const T v) { val.emplace_back(v); }
  void zip() {
    sort(val.begin(), val.end());
    val.erase(unique(val.begin(), val.end()), val.end());
    for (long long i = 0; i < val.size(); i++) idx[val[i]] = i;
  }
  long long operator[](const T v) { return idx[v]; }
  T operator()(const long long i) { return val[i]; }
  long long size() { return val.size(); }
};
struct Box {
  bool left;
  bool right;
  bool top;
  bool down;
  bool v;
  Box() {
    left = right = top = down = true;
    v = false;
  }
};
Box mas[4000][4000];
struct Num {
  long long a, b, c, d, e, f;
};
Zip<long long> tate, yoko;
long long dfs(long long i, long long j) {
  if (mas[i][j].v) return 0;
  if (i == 0 || i == tate.size() - 1 || j == 0 || j == yoko.size() - 1) {
    cout << "INF" << endl;
    exit(0);
  }
  mas[i][j].v = true;
  long long ans = (tate(i) - tate(i - 1)) * (yoko(j) - yoko(j - 1));
  if (mas[i][j].left) ans += dfs(i, j - 1);
  if (mas[i][j].right) ans += dfs(i, j + 1);
  if (mas[i][j].top) ans += dfs(i + 1, j);
  if (mas[i][j].down) ans += dfs(i - 1, j);
  return ans;
}
signed main() {
  long long n, m;
  cin >> n >> m;
  Num t[1010], y[1010];
  for (long long i = 0; i < n; i++) {
    cin >> t[i].a >> t[i].b >> t[i].c;
    tate.add(t[i].a);
    tate.add(t[i].b);
    yoko.add(t[i].c);
  }
  for (long long i = 0; i < m; i++) {
    cin >> y[i].d >> y[i].e >> y[i].f;
    tate.add(y[i].d);
    yoko.add(y[i].e);
    yoko.add(y[i].f);
  }
  tate.add(INT_MIN);
  yoko.add(INT_MIN);
  tate.add(INT_MAX);
  yoko.add(INT_MAX);
  tate.add(0);
  yoko.add(0);
  tate.zip();
  yoko.zip();
  for (long long i = 0; i < n; i++) {
    long long idx = yoko[t[i].c];
    long long l = tate[t[i].a];
    long long r = tate[t[i].b];
    for (long long j = l + 1; j <= r; j++) {
      mas[j][idx].right = false;
      mas[j][idx + 1].left = false;
    }
  }
  for (long long i = 0; i < m; i++) {
    long long idx = tate[y[i].d];
    long long l = yoko[y[i].e];
    long long r = yoko[y[i].f];
    for (long long j = l + 1; j <= r; j++) {
      mas[idx][j].top = false;
      mas[idx + 1][j].down = false;
    }
  }
  long long ans = dfs(tate[0], yoko[0]);
  cout << ans << endl;
  return 0;
}
