#include <bits/stdc++.h>
struct line_t {
  std::pair<int, int> range;
  int pos;
  bool xaxis;
  line_t() {}
  line_t(std::pair<int, int> range, int pos, bool xaxis)
      : range(range), pos(pos), xaxis(xaxis) {}
};
int main() {
  size_t n, m;
  std::cin >> n >> m;
  std::vector<int> xs, ys;
  std::vector<line_t> lines;
  for (size_t i = 0; i < n; i++) {
    int a, b, c;
    std::cin >> a >> b >> c;
    xs.push_back(a);
    xs.push_back(b);
    ys.push_back(c);
    lines.emplace_back(std::make_pair(a, b), c, true);
  }
  for (size_t i = 0; i < m; i++) {
    int d, e, f;
    std::cin >> d >> e >> f;
    xs.push_back(d);
    ys.push_back(e);
    ys.push_back(f);
    lines.emplace_back(std::make_pair(e, f), d, false);
  }
  xs.push_back(2e+9);
  xs.push_back(0);
  xs.push_back(-2e+9);
  ys.push_back(2e+9);
  xs.push_back(0);
  ys.push_back(-2e+9);
  std::sort(xs.begin(), xs.end());
  std::sort(ys.begin(), ys.end());
  xs.erase(std::unique(xs.begin(), xs.end()), xs.end());
  ys.erase(std::unique(ys.begin(), ys.end()), ys.end());
  std::vector<std::vector<int>> hng(xs.size(), std::vector<int>(ys.size()));
  auto wng = hng;
  auto cont = hng;
  for (size_t i = 0; i < xs.size(); i++) {
    for (size_t j = 0; j < ys.size(); j++) {
      cont[i][j] = ys.size() * i + j;
    }
  }
  for (auto&& line : lines) {
    if (line.xaxis) {
      int ix1 =
          std::lower_bound(xs.begin(), xs.end(), line.range.first) - xs.begin();
      int ix2 = std::lower_bound(xs.begin(), xs.end(), line.range.second) -
                xs.begin();
      int iy = std::lower_bound(ys.begin(), ys.end(), line.pos) - ys.begin();
      hng[ix1][iy] = 1;
      hng[ix2][iy] = -1;
    }
    if (!line.xaxis) {
      int iy1 =
          std::lower_bound(ys.begin(), ys.end(), line.range.first) - ys.begin();
      int iy2 = std::lower_bound(ys.begin(), ys.end(), line.range.second) -
                ys.begin();
      int ix = std::lower_bound(xs.begin(), xs.end(), line.pos) - xs.begin();
      wng[ix][iy1] = 1;
      wng[ix][iy2] = -1;
    }
  }
  for (size_t i = 0; i < xs.size(); i++) {
    for (size_t j = 0; j < ys.size(); j++) {
      if (i > 0) hng[i][j] += hng[i - 1][j];
      if (j > 0) wng[i][j] += wng[i][j - 1];
      if (wng[i][j] == 0 && i > 0) {
        cont[i][j] = std::min(cont[i - 1][j], cont[i][j]);
        cont[i - 1][j] = std::min(cont[i - 1][j], cont[i][j]);
      }
      if (hng[i][j] == 0 && j < (ys.size() - 1)) {
        cont[i][j + 1] = std::min(cont[i][j], cont[i][j + 1]);
        cont[i][j] = std::min(cont[i][j], cont[i][j + 1]);
      }
    }
  }
  std::queue<std::pair<int, int>> search;
  std::pair<int, int> zero = {
      std::lower_bound(xs.begin(), xs.end(), 0) - xs.begin(),
      std::lower_bound(ys.begin(), ys.end(), 0) - ys.begin()};
  if (cont[0][0] == cont[zero.first][zero.second]) {
    std::cout << "INF\n";
    return 0;
  }
  search.push(zero);
  std::map<std::pair<int, int>, bool> flag;
  flag[zero] = true;
  long long area = 0;
  for (size_t i = 0; i < xs.size(); i++) {
    for (size_t j = 0; j < ys.size(); j++) {
      if (cont[i][j] == cont[zero.first][zero.second]) {
        area += (long long)(xs[i + 1] - xs[i]) * (ys[i + 1] - ys[i]);
      }
    }
  }
  std::cout << area << "\n";
  return 0;
}
