#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr char newl = '\n';
constexpr int dx[] = {1, -1, 0, 0};
constexpr int dy[] = {0, 0, 1, -1};
constexpr ll INF = 1145141919;
int compress(vector<ll>& unzip, map<ll, int>& zip) {
  sort(unzip.begin(), unzip.end());
  unzip.erase(unique(unzip.begin(), unzip.end()), unzip.end());
  for (int i = 0; i < unzip.size(); i++) {
    zip[unzip[i]] = i;
  }
  return unzip.size();
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<ll> xs, ys;
  xs.push_back(0);
  ys.push_back(0);
  vector<ll> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i] >> c[i];
    xs.push_back(a[i]);
    xs.push_back(b[i]);
    ys.push_back(c[i]);
  }
  vector<ll> d(m), e(m), f(m);
  for (int i = 0; i < m; i++) {
    cin >> d[i] >> e[i] >> f[i];
    xs.push_back(d[i]);
    ys.push_back(e[i]);
    ys.push_back(f[i]);
  }
  xs.push_back(-INF);
  xs.push_back(INF);
  ys.push_back(-INF);
  ys.push_back(INF);
  map<ll, int> zip_x, zip_y;
  int sz_x = compress(xs, zip_x);
  int sz_y = compress(ys, zip_y);
  vector<vector<int> > ban(sz_x + 1, vector<int>(sz_y + 1, 0));
  for (int i = 0; i < n; i++) {
    int x1 = zip_x[a[i]];
    int x2 = zip_x[b[i]];
    int y = zip_y[c[i]];
    ++ban[x1][y];
    --ban[x2 + 1][y];
    --ban[x1][y + 1];
    ++ban[x2 + 1][y + 1];
  }
  for (int i = 0; i < m; i++) {
    int x = zip_x[d[i]];
    int y1 = zip_y[e[i]];
    int y2 = zip_y[f[i]];
    ban[x][y1] += 10000;
    ban[x][y2 + 1] -= 10000;
    ban[x + 1][y1] -= 10000;
    ban[x + 1][y2 + 1] += 10000;
  }
  for (int i = 0; i < sz_x; i++) {
    for (int j = 1; j < sz_y; j++) {
      ban[i][j] += ban[i][j - 1];
    }
  }
  for (int i = 1; i < sz_x; i++) {
    for (int j = 0; j < sz_y; j++) {
      ban[i][j] += ban[i - 1][j];
    }
  }
  vector<vector<int> > visit(sz_x, vector<int>(sz_y, false));
  queue<P> s;
  {
    int x = zip_x[0];
    int y = zip_y[0];
    s.emplace(x, y);
    visit[x][y] = true;
  }
  while (!s.empty()) {
    P p = s.front();
    s.pop();
    int cx = p.first;
    int cy = p.second;
    for (int i = 0; i < 4; i++) {
      int nx = cx + dx[i];
      int ny = cy + dy[i];
      if (nx <= 0 || nx >= sz_x || ny <= 0 || ny >= sz_y) continue;
      if (visit[nx][ny]) continue;
      if (i == 0) {
        if ((ban[cx][cy - 1] >= 10000) && (ban[cx][cy] >= 10000)) continue;
      } else if (i == 1) {
        if ((ban[cx - 1][cy - 1] >= 10000) && (ban[cx - 1][cy] >= 10000))
          continue;
      } else if (i == 2) {
        if ((ban[cx - 1][cy] % 10000 > 0) && (ban[cx][cy] % 10000 > 0))
          continue;
      } else {
        if ((ban[cx - 1][cy - 1] % 10000 > 0) && (ban[cx][cy - 1] % 10000 > 0))
          continue;
      }
      visit[nx][ny] = true;
      s.emplace(nx, ny);
    }
  }
  ll ans = 0;
  for (int i = 1; i < sz_x; i++) {
    for (int j = 1; j < sz_y; j++) {
      if (visit[i][j]) {
        if (abs(xs[i]) == INF || abs(xs[i - 1]) == INF || abs(ys[i]) == INF ||
            abs(ys[i - 1]) == INF) {
          cout << "INF\n";
          return 0;
        }
        ans += (xs[i] - xs[i - 1]) * (ys[j] - ys[j - 1]);
      }
    }
  }
  cout << ans << newl;
  return 0;
}
