#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ull = unsigned long long;
using ld = long double;
template <typename T>
void _(const char* s, T h) {
  cerr << s << " = " << h << "\n";
}
template <typename T, typename... Ts>
void _(const char* s, T h, Ts... t) {
  int b = 0;
  while (((b += *s == '(') -= *s == ')') != 0 || *s != ',') cerr << *s++;
  cerr << " = " << h << ",";
  _(s + 1, t...);
}
struct init {
  init() {
    cin.tie(0);
    iostream::sync_with_stdio(0);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(5);
  }
  ~init() {}
} init;
template <typename T, typename U>
void upx(T& x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
void upn(T& x, U y) {
  if (x > y) x = y;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll D = 4, dx[] = {+1, 0, -1, 0}, dy[] = {0, +1, 0, -1};
const ll N = 3030;
struct ot {
  ll x1, x2, y;
};
ot h[N], w[N];
ll ax[N], ay[N], first[N][N], p[N * N], rk[N * N], ar[N * N];
bool inf[N * N];
ll get(ll x) { return x == p[x] ? x : (p[x] = get(p[x])); }
bool un(ll x, ll y) {
  if ((x = get(x)) == (y = get(y))) return 0;
  if (rk[x] < rk[y]) swap(x, y);
  inf[x] |= inf[y];
  ar[x] += ar[y];
  rk[x] += (rk[x] == rk[y]);
  p[y] = x;
  return 1;
}
vector<pll> onx[N], ony[N];
int32_t main() {
  ll n, m;
  cin >> n >> m;
  ll xs = 0, ys = 0;
  for (ll i = 0; i < (n); ++i) {
    cin >> h[i].x1 >> h[i].x2 >> h[i].y;
    ax[xs++] = h[i].x1;
    ax[xs++] = h[i].x2;
    ay[ys++] = h[i].y;
  }
  for (ll i = 0; i < (m); ++i) {
    cin >> w[i].y >> w[i].x1 >> w[i].x2;
    ay[ys++] = w[i].x1;
    ay[ys++] = w[i].x2;
    ax[xs++] = w[i].y;
  }
  sort(ax, ax + xs);
  xs = unique(ax, ax + xs) - ax;
  sort(ay, ay + ys);
  ys = unique(ay, ay + ys) - ay;
  for (ll i = 0; i < (n); ++i) {
    ll x1 = lower_bound(ax, ax + xs, h[i].x1) - ax;
    ll x2 = lower_bound(ax, ax + xs, h[i].x2) - ax;
    ll y = lower_bound(ay, ay + ys, h[i].y) - ay;
    ony[y].emplace_back(x1, x2);
  }
  for (ll i = 0; i < (m); ++i) {
    ll y1 = lower_bound(ay, ay + ys, w[i].x1) - ay;
    ll y2 = lower_bound(ay, ay + ys, w[i].x2) - ay;
    ll x = lower_bound(ax, ax + xs, w[i].y) - ax;
    onx[x].emplace_back(y1, y2);
  }
  if (xs <= 1 || ys <= 1) {
    cout << "INF\n";
    return 0;
  }
  ll z = 0;
  for (ll i = 0; i < (xs - 1); ++i) {
    for (ll j = 0; j < (ys - 1); ++j) {
      first[i][j] = z;
      p[z] = z;
      rk[z] = 0;
      ar[z] = (ax[i + 1] - ax[i]) * (ay[j + 1] - ay[j]);
      inf[z] = 0;
      z++;
    }
  }
  {
    ll pr = 0;
    for (pll p : onx[0]) {
      ll l = p.first, r = p.second;
      for (ll j = pr; j < l; ++j) inf[first[0][j]] = 1;
      pr = r;
    }
    for (ll j = pr; j < ys - 1; ++j) inf[first[0][j]] = 1;
  }
  {
    ll pr = 0;
    for (pll p : onx[xs - 1]) {
      ll l = p.first, r = p.second;
      for (ll j = pr; j < l; ++j) inf[first[xs - 2][j]] = 1;
      pr = r;
    }
    for (ll j = pr; j < ys - 1; ++j) inf[first[xs - 2][j]] = 1;
  }
  {
    ll pr = 0;
    for (pll p : ony[0]) {
      ll l = p.first, r = p.second;
      for (ll j = pr; j < l; ++j) inf[first[j][0]] = 1;
      pr = r;
    }
    for (ll j = pr; j < xs - 1; ++j) inf[first[j][0]] = 1;
  }
  {
    ll pr = 0;
    for (pll p : ony[ys - 1]) {
      ll l = p.first, r = p.second;
      for (ll j = pr; j < l; ++j) inf[first[j][ys - 2]] = 1;
      pr = r;
    }
    for (ll j = pr; j < xs - 1; ++j) inf[first[j][ys - 2]] = 1;
  }
  for (ll i = 1; i < xs - 1; ++i) {
    ll pr = 0;
    for (pll p : onx[i]) {
      ll l = p.first, r = p.second;
      for (ll j = pr; j < l; ++j) un(first[i - 1][j], first[i][j]);
      pr = r;
    }
    for (ll j = pr; j < ys - 1; ++j) un(first[i - 1][j], first[i][j]);
  }
  for (ll i = 1; i < ys - 1; ++i) {
    ll pr = 0;
    for (pll p : ony[i]) {
      ll l = p.first, r = p.second;
      for (ll j = pr; j < l; ++j) un(first[j][i - 1], first[j][i]);
      pr = r;
    }
    for (ll j = pr; j < xs - 1; ++j) un(first[j][i - 1], first[j][i]);
  }
  if (0 <= ax[0] || 0 >= ax[xs - 1] || 0 <= ay[0] || 0 >= ay[ys - 1]) {
    cout << "INF\n";
    return 0;
  }
  ll xpos = upper_bound(ax, ax + xs, 0) - ax - 1;
  ll ypos = upper_bound(ay, ay + ys, 0) - ay - 1;
  ll pos = get(first[xpos][ypos]);
  if (inf[pos])
    cout << "INF\n";
  else
    cout << ar[pos] << '\n';
  return 0;
}
