#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1LL << 60;
long long mod_pow(long long, long long, long long);
long long mod_fact(long long, long long);
long long mod_inv(long long, long long);
long long gcd(long long, long long);
long long lcm(long long, long long);
struct L {
  int lend, rend, on;
  L(int on, int lend, int rend) : on(on), lend(lend), rend(rend){};
};
int bis(vector<int>& vec, int val) {
  int left = -1;
  int right = vec.size();
  while (right - left != 1) {
    int middle = (left + right) / 2;
    if (vec[middle] > val)
      right = middle;
    else
      left = middle;
  }
  return left;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
void dfs(const vector<vector<bool>>& map, vector<vector<bool>>& reach, int y,
         int x, int ymax, int xmax) {
  if (map[y][x] || reach[y][x]) return;
  reach[y][x] = true;
  for (int i = 0; i < 4; i++) {
    int cx = x + dx[i];
    int cy = y + dy[i];
    if (cx < 0 || cy < 0 || cy > ymax || cx > xmax) continue;
    dfs(map, reach, cy, cx, ymax, xmax);
  }
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<L> lv, lh;
  vector<int> x, y;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    lv.emplace_back(c, a, b);
    x.push_back(c);
    y.push_back(a);
    y.push_back(b);
  }
  for (int i = 0; i < m; i++) {
    int d, e, f;
    cin >> d >> e >> f;
    lh.emplace_back(d, e, f);
    y.push_back(d);
    x.push_back(e);
    x.push_back(f);
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  vector<vector<bool>> is_wall(2 * y.size() + 1,
                               vector<bool>(2 * x.size() + 1));
  for (auto itr : lv) {
    int onidx = 2 * bis(x, itr.on) + 1;
    for (int i = 2 * bis(y, itr.lend) + 1; i <= 2 * bis(y, itr.rend) + 1; i++) {
      is_wall[i][onidx] = true;
    }
  }
  for (auto itr : lh) {
    int onidx = 2 * bis(y, itr.on) + 1;
    for (int i = 2 * bis(x, itr.lend) + 1; i <= 2 * bis(x, itr.rend) + 1; i++) {
      is_wall[onidx][i] = true;
    }
  }
  vector<vector<bool>> reach(2 * y.size() + 1, vector<bool>(2 * x.size() + 1));
  bool flag = false;
  for (int i = 0; i <= (int)2 * x.size(); i++) {
    if (reach[0][i] || reach[2 * y.size()][i]) flag = true;
  }
  for (int i = 0; i <= (int)2 * y.size(); i++) {
    if (reach[i][0] || reach[i][2 * x.size()]) flag = true;
  }
  if (flag) {
    cout << "INF"
         << "\n";
    return 0;
  }
  vector<long long> ylength((int)2 * y.size() + 1);
  vector<long long> xlength((int)2 * x.size() + 1);
  for (int i = 0; i < (int)y.size() - 1; i++) {
    ylength[2 * (i + 1)] = y[i + 1] - y[i];
  }
  for (int i = 0; i < (int)x.size() - 1; i++) {
    xlength[2 * (i + 1)] = x[i + 1] - x[i];
  }
  long long area = 0;
  for (int i = 0; i <= (int)2 * y.size(); i++) {
    for (int j = 0; j <= (int)2 * x.size(); j++) {
      if (reach[i][j]) area += ylength[i] * xlength[j];
    }
  }
  cout << area << "\n";
}
