#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int MAXN = 4010, INF = 1e9 + 7;
int n, m;
vector<int> a, b, c, d, e, f, xs, ys;
vector<vector<int> > u(MAXN, vector<int>(MAXN, 0)),
    dd(MAXN, vector<int>(MAXN, 0)), r(MAXN, vector<int>(MAXN, 0)),
    l(MAXN, vector<int>(MAXN, 0)), v(MAXN, vector<int>(MAXN, 0));
int dir[][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
void bfs(int x, int y) {
  v[x][y] = 1;
  queue<pair<int, int> > q;
  q.push({x, y});
  while (q.size()) {
    int x = q.front().first, y = q.front().second;
    q.pop();
    for (int i = 0; i < 4; i++) {
      if (i == 0 && u[x][y]) continue;
      if (i == 1 && dd[x][y]) continue;
      if (i == 2 && r[x][y]) continue;
      if (i == 3 && l[x][y]) continue;
      int xx = x + dir[i][0];
      int yy = y + dir[i][1];
      if (xx < 0 || yy < 0) continue;
      if (xx >= xs.size() - 1 || yy >= ys.size() - 1) continue;
      if (v[xx][yy]) continue;
      v[xx][yy] = 1;
      q.push({xx, yy});
    }
  }
}
void solve() {
  cin >> n >> m;
  xs.push_back(-INF);
  xs.push_back(INF);
  ys.push_back(-INF);
  ys.push_back(INF);
  for (int i = 0; i < n; i++) {
    int aa, bb, cc;
    cin >> aa >> bb >> cc;
    a.push_back(aa);
    b.push_back(bb);
    c.push_back(cc);
    xs.push_back(a[i]);
    xs.push_back(b[i]);
    ys.push_back(c[i]);
  }
  for (int i = 0; i < m; i++) {
    int dd, ee, first;
    cin >> dd >> ee >> first;
    d.push_back(dd);
    e.push_back(ee);
    f.push_back(first);
    xs.push_back(d[i]);
    ys.push_back(e[i]);
    ys.push_back(f[i]);
  }
  sort((xs).begin(), (xs).end());
  sort((ys).begin(), (ys).end());
  xs.resize(unique((xs).begin(), (xs).end()) - xs.begin());
  ys.resize(unique((ys).begin(), (ys).end()) - ys.begin());
  int x = lower_bound((xs).begin(), (xs).end(), 0) - xs.begin();
  int y = lower_bound((ys).begin(), (ys).end(), 0) - ys.begin();
  x--, y--;
  for (int i = 0; i < n; i++) {
    int aa = lower_bound((xs).begin(), (xs).end(), a[i]) - xs.begin();
    int bb = lower_bound((xs).begin(), (xs).end(), b[i]) - xs.begin();
    int cc = lower_bound((ys).begin(), (ys).end(), c[i]) - ys.begin();
    for (int j = aa; j < bb; j++) {
      u[j][cc - 1] = 1;
      dd[j][cc] = 1;
    }
  }
  for (int i = 0; i < n; i++) {
    int ddd = lower_bound((xs).begin(), (xs).end(), d[i]) - xs.begin();
    int ee = lower_bound((ys).begin(), (ys).end(), e[i]) - ys.begin();
    int first = lower_bound((ys).begin(), (ys).end(), f[i]) - ys.begin();
    for (int j = ee; j < first; j++) {
      r[ddd - 1][j] = 1;
      l[ddd][j] = 1;
    }
  }
  bfs(x, y);
  if (v[0][0] || v[xs.size() - 1][ys.size() - 1]) {
    cout << "INF" << endl;
    return;
  }
  ll ans = 0;
  for (int i = 0; i < xs.size() - 1; i++) {
    for (int j = 0; j < ys.size() - 1; j++) {
      if (v[i][j]) {
        ans += (ll)(xs[i + 1] - xs[i]) * (ys[j + 1] - ys[j]);
      }
    }
  }
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
