#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 = 1145141919LL * 2;
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] * 2);
    xs.push_back(b[i] * 2);
    ys.push_back(c[i] * 2);
  }
  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] * 2);
    ys.push_back(e[i] * 2);
    ys.push_back(f[i] * 2);
  }
  map<ll, int> dummy;
  int sz_x = compress(xs, dummy);
  int sz_y = compress(ys, dummy);
  auto xs2 = xs, ys2 = ys;
  for (int i = 1; i < sz_x; i++) {
    xs2.push_back((xs[i] + xs[i - 1]) / 2);
  }
  for (int i = 1; i < sz_y; i++) {
    ys2.push_back((ys[i] + ys[i - 1]) / 2);
  }
  xs = move(xs2);
  ys = move(ys2);
  xs.push_back(-INF);
  xs.push_back(INF);
  ys.push_back(-INF);
  ys.push_back(INF);
  map<ll, int> zip_x, zip_y;
  sz_x = compress(xs, zip_x);
  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] * 2];
    int x2 = zip_x[b[i] * 2];
    int y = zip_y[c[i] * 2];
    ++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] * 2];
    int y1 = zip_y[e[i] * 2];
    int y2 = zip_y[f[i] * 2];
    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));
  stack<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.top();
    s.pop();
    bool flag = false;
    for (int i = 0; i < 4; i++) {
      if (!ban[p.first][p.second]) break;
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (nx < 0 || nx >= sz_x || ny < 0 || ny >= sz_y) continue;
      int nx2 = p.first + dx[(i + 2) % 4];
      int ny2 = p.second + dy[(i + 2) % 4];
      if (nx2 < 0 || nx2 >= sz_x || ny2 < 0 || ny2 >= sz_y) continue;
      if (ban[nx][ny] && ban[nx2][ny2]) {
        flag = true;
        break;
      }
    }
    if (flag) continue;
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (nx < 0 || nx >= sz_x || ny < 0 || ny >= sz_y) continue;
      if (xs[nx] == INF || xs[nx] == -INF || ys[ny] == INF || ys[ny] == -INF) {
        cout << "INF\n";
        return 0;
      }
      if (visit[nx][ny]) continue;
      int x1 = p.first;
      int x2 = p.first;
      int y1 = p.second;
      int y2 = p.second;
      if (i < 2) {
        ++y1;
        --y2;
        if (x1 >= 0 && x1 < sz_x && x2 >= 0 && x2 < sz_x && y1 >= 0 &&
            y1 < sz_y && y2 >= 0 && y2 < sz_y) {
          if ((ban[p.first][p.second] >= 10000) && (ban[x1][y1] >= 10000) &&
              (ban[x2][y2] >= 10000))
            continue;
        }
      } else {
        ++x1;
        --x2;
        if (x1 >= 0 && x1 < sz_x && x2 >= 0 && x2 < sz_x && y1 >= 0 &&
            y1 < sz_y && y2 >= 0 && y2 < sz_y) {
          if ((ban[p.first][p.second] % 10000 > 0) &&
              (ban[x1][y1] % 10000 > 0) && (ban[x2][y2] % 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] && visit[i - 1][j] && visit[i - 1][j - 1] &&
          visit[i][j - 1]) {
        ans += (xs[i] - xs[i - 1]) * (ys[j] - ys[j - 1]);
      }
    }
  }
  ans /= 4;
  cout << ans << newl;
  return 0;
}
