#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int main() {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  vector<pair<pair<long long, long long>, long long> > tate;
  vector<pair<pair<long long, long long>, long long> > yoko;
  vector<long long> Xs({0});
  vector<long long> Ys({0});
  for (long long(i) = (0); (i) < (n); ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    Ys.push_back(a);
    Ys.push_back(b);
    Xs.push_back(c);
    tate.emplace_back(make_pair(a, b), c);
  }
  for (long long(i) = (0); (i) < (m); ++i) {
    long long a, b, c;
    cin >> a >> b >> c;
    Xs.push_back(b);
    Xs.push_back(c);
    Ys.push_back(a);
    yoko.emplace_back(make_pair(b, c), a);
  }
  sort(Xs.begin(), Xs.end());
  sort(Ys.begin(), Ys.end());
  Xs.erase(unique(Xs.begin(), Xs.end()), Xs.end());
  Ys.erase(unique(Ys.begin(), Ys.end()), Ys.end());
  vector<vector<char> > mp(2 * Ys.size() + 1,
                           vector<char>(2 * Xs.size() + 1, '.'));
  for (long long(i) = (0); (i) < (n); ++i) {
    long long y_from =
        2 * (lower_bound(Ys.begin(), Ys.end(), tate[i].first.first) -
             Ys.begin()) +
        1;
    long long y_to =
        2 * (lower_bound(Ys.begin(), Ys.end(), tate[i].first.second) -
             Ys.begin()) +
        1;
    long long x =
        2 * (lower_bound(Xs.begin(), Xs.end(), tate[i].second) - Xs.begin()) +
        1;
    for (long long y = y_from; y <= y_to; y++) mp[y][x] = '#';
  }
  for (long long(i) = (0); (i) < (m); ++i) {
    long long x_from =
        2 * (lower_bound(Xs.begin(), Xs.end(), yoko[i].first.first) -
             Xs.begin()) +
        1;
    long long x_to =
        2 * (lower_bound(Xs.begin(), Xs.end(), yoko[i].first.second) -
             Xs.begin()) +
        1;
    long long y =
        2 * (lower_bound(Ys.begin(), Ys.end(), yoko[i].second) - Ys.begin()) +
        1;
    for (long long x = x_from; x <= x_to; x++) mp[y][x] = '#';
  }
  long long h = mp.size();
  long long w = mp[0].size();
  queue<pair<long long, long long> > q;
  long long ys = 2 * (lower_bound(Ys.begin(), Ys.end(), 0) - Ys.begin()) + 1;
  long long xs = 2 * (lower_bound(Xs.begin(), Xs.end(), 0) - Xs.begin()) + 1;
  q.push(make_pair(ys, xs));
  while (!q.empty()) {
    long long y = q.front().first;
    long long x = q.front().second;
    q.pop();
    mp[y][x] = 'o';
    for (long long(i) = (0); (i) < (4); ++i) {
      long long yy = y + dy[i];
      long long xx = x + dx[i];
      if (yy < 0 || xx < 0 || yy >= h || xx >= w) continue;
      if (mp[yy][xx] != '.') continue;
      q.push(make_pair(yy, xx));
    }
  }
  if (mp[0][0] == 'o') {
    cout << "INF" << endl;
    return 0;
  }
  long long ans = 0;
  for (long long(i) = (0); (i) < (h); ++i)
    for (long long(j) = (0); (j) < (w); ++j) {
      if (mp[i][j] != 'o') continue;
      if (i % 2 || j % 2) continue;
      long long H = Ys[i / 2 + 1] - Ys[i / 2];
      long long W = Xs[j / 2 + 1] - Xs[j / 2];
      ans += H * W;
    }
  cout << ans << endl;
  return 0;
}
