#include <bits/stdc++.h>
using namespace std;
const long long N = 3e3 + 100;
const long long INF = 1e18;
int w, h;
long long area[N][N];
long long ans;
int movx[4] = {0, 1, 0, -1};
int movy[4] = {1, 0, -1, 0};
bool block[N][N][4];
bool vis[N][N];
void dfs(int i, int j) {
  if (i < 0 || i >= h || j < 0 || j >= w) {
    cout << "INF" << endl;
    exit(0);
  }
  vis[i][j] = 1;
  ans += area[i][j];
  for (long long k = long long(0); k < long long(4); ++k)
    if (!block[i][j][k]) {
      int nxti = i + movy[k];
      int nxtj = j + movx[k];
      if (!vis[nxti][nxtj]) dfs(nxti, nxtj);
    }
}
vector<pair<pair<long long, long long>, long long> > vert, hor;
vector<long long> coordx, coordy;
unordered_map<long long, long long> idx, idy;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (long long i = long long(0); i < long long(n); ++i) {
    long long d, u, x;
    cin >> d >> u >> x;
    vert.push_back(make_pair(make_pair(d, u), x));
    coordx.push_back(x);
    coordy.push_back(d);
    coordy.push_back(u);
  }
  for (long long i = long long(0); i < long long(m); ++i) {
    long long y, l, r;
    cin >> y >> l >> r;
    hor.push_back(make_pair(make_pair(l, r), y));
    coordy.push_back(y);
    coordx.push_back(l);
    coordx.push_back(r);
  }
  coordx.push_back(0);
  coordy.push_back(0);
  sort((coordx).begin(), (coordx).end());
  coordx.resize(unique((coordx).begin(), (coordx).end()) - coordx.begin());
  w = long long((coordx).size());
  for (long long i = long long(0); i < long long(w); ++i) idx[coordx[i]] = i;
  sort((coordy).begin(), (coordy).end());
  coordy.resize(unique((coordy).begin(), (coordy).end()) - coordy.begin());
  h = long long((coordy).size());
  for (long long i = long long(0); i < long long(h); ++i) idy[coordy[i]] = i;
  w--, h--;
  for (long long i = long long(0); i < long long(h); ++i)
    for (long long j = long long(0); j < long long(w); ++j)
      area[i][j] = (coordy[i + 1] - coordy[i]) * (coordx[j + 1] - coordx[j]);
  for (auto l : vert) {
    int d = l.first.first, u = l.first.second, x = l.second;
    int izq = idx[x] - 1, der = idx[x];
    int i = idy[d];
    int fin = idy[u];
    while (i < fin) {
      if (izq >= 0) block[i][izq][1] = 1;
      if (der < w) block[i][der][3] = 1;
      i++;
    }
  }
  for (auto elem : hor) {
    int l = elem.first.first, r = elem.first.second, y = elem.second;
    int down = idy[y] - 1, up = idy[y];
    int j = idx[l];
    int fin = idx[r];
    while (j < fin) {
      if (down >= 0) block[down][j][0] = 1;
      if (up < h) block[up][j][2] = 1;
      j++;
    }
  }
  dfs(idy[0], idx[0]);
  cout << ans << endl;
  return 0;
}
