#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long i, j, k, n, m, ans = 0, a, b, t, nowx, nowy;
  scanf("%lld%lld", &n, &m);
  set<long long> x, y;
  set<long long>::iterator it;
  pair<long long, pair<long long, long long> > vx[m], vy[n];
  for (i = 0; i < n; ++i) {
    scanf("%lld%lld%lld", &vy[i].second.first, &vy[i].second.second,
          &vy[i].first);
    x.insert(vy[i].second.first), x.insert(vy[i].second.second);
    y.insert(vy[i].first);
  }
  for (i = 0; i < m; ++i) {
    scanf("%lld%lld%lld", &vx[i].first, &vx[i].second.first,
          &vx[i].second.second);
    y.insert(vx[i].second.first), y.insert(vx[i].second.second);
    x.insert(vx[i].first);
  }
  a = x.size(), b = y.size();
  long long px[a], py[b];
  long long lx[a][b], ly[a][b], flg[a][b];
  for (i = 0, it = x.begin(); it != x.end(); ++i, ++it) px[i] = *it;
  for (i = 0, it = y.begin(); it != y.end(); ++i, ++it) py[i] = *it;
  for (i = 0; i < a; ++i)
    for (j = 0; j < b; ++j) lx[i][j] = ly[i][j] = flg[i][j] = true;
  for (i = 0; i < m; ++i) {
    t = lower_bound(px, px + a, vx[i].first) - px;
    for (j = lower_bound(py, py + b, vx[i].second.first) - py;
         j < b && py[j] < vx[i].second.second; ++j)
      lx[t][j] = false;
  }
  for (i = 0; i < n; ++i) {
    t = lower_bound(py, py + b, vy[i].first) - py;
    for (j = lower_bound(px, px + a, vy[i].second.first) - px;
         j < a && px[j] < vy[i].second.second; ++j)
      ly[j][t] = false;
  }
  queue<pair<long long, long long> > q;
  nowx = lower_bound(px, px + a, 0) - px - 1,
  nowy = lower_bound(py, py + b, 0) - py - 1;
  flg[nowx][nowy] = false;
  q.push(make_pair(nowx, nowy));
  while (q.size()) {
    nowx = q.front().first, nowy = q.front().second;
    q.pop();
    if (nowx < 0 || nowx > a - 2 || nowy < 0 || nowy > b - 2) {
      printf("INF");
      return 0;
    }
    ans += (px[nowx + 1] - px[nowx]) * (py[nowy + 1] - py[nowy]);
    if (nowx && lx[nowx][nowy] && flg[nowx - 1][nowy])
      q.push(make_pair(nowx - 1, nowy)), flg[nowx - 1][nowy] = false;
    if (nowy && ly[nowx][nowy] && flg[nowx][nowy - 1])
      q.push(make_pair(nowx, nowy - 1)), flg[nowx][nowy - 1] = false;
    if (lx[nowx + 1][nowy] && flg[nowx + 1][nowy])
      q.push(make_pair(nowx + 1, nowy)), flg[nowx + 1][nowy] = false;
    if (ly[nowx][nowy + 1] && flg[nowx][nowy + 1])
      q.push(make_pair(nowx, nowy + 1)), flg[nowx][nowy + 1] = false;
  }
  printf("%lld", ans);
  return 0;
}
