#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long long MAX_N = 200100;
set<long long> xaxis, yaxis;
vector<long long> itox, itoy;
bool xwall[3010][3010][2];
bool ywall[3010][3010][2];
bool grid[3010][3010];
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<pair<long long, pair<long long, long long>>> xinput;
  vector<pair<long long, pair<long long, long long>>> yinput;
  for (long long i = 0; i < N; i++) {
    long long a, b, y;
    cin >> a >> b >> y;
    yinput.push_back(make_pair(y, make_pair(a, b)));
    xaxis.emplace(a);
    xaxis.emplace(b);
    yaxis.emplace(y);
  }
  for (long long i = 0; i < M; i++) {
    long long x, e, f;
    cin >> x >> e >> f;
    xinput.push_back(make_pair(x, make_pair(e, f)));
    yaxis.emplace(e);
    yaxis.emplace(f);
    xaxis.emplace(x);
  }
  for (auto iter : xaxis) itox.emplace_back(iter);
  for (auto iter : yaxis) itoy.emplace_back(iter);
  for (long long i = 0; i < 3010; i++) {
    for (long long j = 0; j < 3010; j++) {
      for (long long k = 0; k < 2; k++) {
        xwall[j][i][k] = false;
        ywall[j][i][k] = false;
      }
    }
  }
  for (long long i = 0; i < N; i++) {
    long long y = yinput[i].first;
    long long xa = yinput[i].second.first;
    long long xb = yinput[i].second.second;
    y = lower_bound(itoy.begin(), itoy.end(), y) - itoy.begin();
    xa = lower_bound(itox.begin(), itox.end(), xa) - itox.begin();
    xb = lower_bound(itox.begin(), itox.end(), xb) - itox.begin();
    for (long long x = xa; x <= xb; x++) {
      if (x != xa) ywall[x][y][0] = true;
      if (x != xb) ywall[x][y][1] = true;
    }
  }
  for (long long i = 0; i < M; i++) {
    long long x = xinput[i].first;
    long long ya = xinput[i].second.first;
    long long yb = xinput[i].second.second;
    x = lower_bound(itox.begin(), itox.end(), x) - itox.begin();
    ya = lower_bound(itoy.begin(), itoy.end(), ya) - itoy.begin();
    yb = lower_bound(itoy.begin(), itoy.end(), yb) - itoy.begin();
    for (long long y = ya; y <= yb; y++) {
      if (y != ya) xwall[x][y][0] = true;
      if (y != yb) xwall[x][y][1] = true;
    }
  }
  long long start_x = lower_bound(itox.begin(), itox.end(), 0) - itox.begin();
  long long start_y = lower_bound(itoy.begin(), itoy.end(), 0) - itoy.begin();
  queue<pair<long long, long long>> q;
  q.push(make_pair(start_x, start_y));
  long long ans = 0;
  bool flg = false;
  while (!q.empty()) {
    long long x = q.front().first;
    long long y = q.front().second;
    if (x < 0 || y < 0 || x > itox.size() - 2 || y > itoy.size() - 2) {
      flg = true;
      break;
    }
    q.pop();
    if (grid[x][y]) continue;
    grid[x][y] = true;
    ans += (itox[x + 1] - itox[x]) * (itoy[y + 1] - itoy[y]);
    if (!(xwall[x][y][1] && xwall[x][y + 1][0])) q.push(make_pair(x - 1, y));
    if (!(xwall[x + 1][y][1] && xwall[x + 1][y + 1][0]))
      q.push(make_pair(x + 1, y));
    if (!(ywall[x][y][1] && ywall[x + 1][y][0])) q.push(make_pair(x, y - 1));
    if (!(ywall[x][y + 1][1] && ywall[x + 1][y + 1][0]))
      q.push(make_pair(x, y + 1));
  }
  if (flg)
    cout << "INF" << endl;
  else
    cout << ans << endl;
  return 0;
}
