#include <bits/stdc++.h>
using namespace std;
struct line {
  long long a;
  long long b;
  long long c;
};
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> x;
  vector<long long> y;
  map<long long, int> mx;
  map<long long, int> my;
  x.push_back(-1e10);
  x.push_back(1e10);
  y.push_back(-1e10);
  y.push_back(1e10);
  vector<line> vec(n);
  vector<line> vecb(m);
  for (int i = 0; i < n; i++) {
    cin >> vec[i].a >> vec[i].b >> vec[i].c;
    if (mx[vec[i].a] == 0) {
      x.push_back(vec[i].a);
      mx[vec[i].a]++;
    }
    if (mx[vec[i].b] == 0) {
      x.push_back(vec[i].b);
      mx[vec[i].b]++;
    }
    if (my[vec[i].c] == 0) {
      y.push_back(vec[i].c);
      my[vec[i].c]++;
    }
  }
  for (int i = 0; i < m; i++) {
    cin >> vecb[i].a >> vecb[i].b >> vecb[i].c;
    if (mx[vecb[i].a] == 0) {
      x.push_back(vecb[i].a);
      mx[vecb[i].a]++;
    }
    if (my[vecb[i].b] == 0) {
      y.push_back(vecb[i].b);
      my[vecb[i].b]++;
    }
    if (my[vecb[i].c] == 0) {
      y.push_back(vecb[i].c);
      my[vecb[i].c]++;
    }
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  map<int, long long> wherex;
  map<int, long long> wherey;
  int xsize = x.size();
  int ysize = y.size();
  for (int i = 0; i < xsize; i++) {
    wherex[x[i]] = i;
  }
  for (int i = 0; i < ysize; i++) {
    wherey[y[i]] = i;
  }
  vector<vector<long long>> grid(x.size() - 1, vector<long long>(y.size() - 1));
  queue<pair<int, int>> que;
  vector<vector<int>> gridx(x.size() - 1, vector<int>(y.size()));
  vector<vector<int>> gridy(x.size(), vector<int>(y.size() - 1));
  for (int i = 0; i < xsize - 1; i++) {
    for (int j = 0; j < ysize; j++) {
      gridx[i][j] = 0;
    }
  }
  for (int i = 0; i < xsize; i++) {
    for (int j = 0; j < ysize - 1; j++) {
      gridy[i][j] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    gridx[wherex[vec[i].a]][wherey[vec[i].c]]++;
    gridx[wherex[vec[i].b]][wherey[vec[i].c]]--;
  }
  for (int i = 1; i < xsize - 1; i++) {
    for (int j = 0; j < ysize; j++) {
      gridx[i][j] += gridx[i - 1][j];
    }
  }
  for (int i = 0; i < m; i++) {
    gridy[wherex[vecb[i].a]][wherey[vecb[i].b]]++;
    gridy[wherex[vecb[i].a]][wherey[vecb[i].c]]--;
  }
  for (int i = 0; i < xsize; i++) {
    for (int j = 1; j < ysize - 1; j++) {
      gridy[i][j] += gridy[i][j - 1];
    }
  }
  for (int i = 0; i < x.size() - 1; i++) {
    for (int j = 0; j < y.size(); j++) {
    }
  }
  for (int i = 0; i < x.size(); i++) {
    for (int j = 0; j < y.size() - 1; j++) {
    }
  }
  for (int i = 0; i < xsize - 1; i++) {
    for (int j = 0; j < ysize - 1; j++) {
      grid[i][j] = 0;
      if (x[i] <= 0 && 0 <= x[i + 1] && y[j] <= 0 && 0 <= y[j + 1]) {
        grid[i][j]++;
        que.push(make_pair(i, j));
      }
    }
  }
  while (!que.empty()) {
    pair<int, int> front = que.front();
    int nowx = front.first;
    int nowy = front.second;
    que.pop();
    for (int i = 0; i < 4; i++) {
      int next_x = nowx + dx[i];
      int next_y = nowy + dy[i];
      if (next_x < 0 || next_x >= x.size() - 1 || next_y < 0 ||
          next_y >= y.size() - 1)
        continue;
      if (grid[next_x][next_y] == 0) {
        if (nowx == next_x) {
          if (nowy < next_y) {
            if (gridx[next_x][next_y] != 0) {
              continue;
            }
          } else {
            if (gridx[nowx][nowy] != 0) {
              continue;
            }
          }
        }
        if (nowy == next_y) {
          if (nowx < next_x) {
            if (gridy[next_x][next_y] != 0) {
              continue;
            }
          } else {
            if (gridy[nowx][nowy] != 0) {
              continue;
            }
          }
        }
        que.push(make_pair(next_x, next_y));
        grid[next_x][next_y] = 1;
      }
    }
  }
  if (grid[0][0] != 0) {
    cout << "INF" << endl;
    return 0;
  }
  long long ans = 0;
  for (int i = 0; i < x.size() - 1; i++) {
    for (int j = 0; j < y.size() - 1; j++) {
      ans += abs(grid[i][j] * (x[i + 1] - x[i]) * (y[i + 1] - y[i]));
    }
  }
  cout << ans << endl;
}
