#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template <class T>
inline bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}
template <class T>
inline bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
struct Line {
  int a, b, c;
  Line(int a_, int b_, int c_) : a(a_), b(b_), c(c_) {}
};
void answer() {
  int n, m;
  cin >> n >> m;
  vector<Line> vs, hs;
  map<int, int> mapX, mapY;
  mapX[0] = 0;
  mapY[0] = 0;
  for (int i = (int)(0); i < (int)((n)); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    vs.emplace_back(Line(a, b, c));
    mapX[a] = mapX[b] = mapY[c] = 0;
  }
  for (int i = (int)(0); i < (int)((m)); i++) {
    int a, b, c;
    cin >> c >> a >> b;
    hs.emplace_back(Line(a, b, c));
    mapY[a] = mapY[b] = mapX[c] = 0;
  }
  vector<int> xs, ys;
  for (auto& mx : mapX) {
    mx.second = xs.size();
    xs.emplace_back(mx.first);
  }
  for (auto& my : mapY) {
    my.second = ys.size();
    ys.emplace_back(my.first);
  }
  int xsz = xs.size(), ysz = ys.size();
  vector<vector<int> > dist(xsz * 2, vector<int>(ysz * 2, 0));
  for (const auto& l : vs) {
    for (int x = mapX[l.a]; x <= mapX[l.b]; x++) {
      dist[x * 2 + 0][mapY[l.c] * 2] = -1;
      if (x < mapX[l.b]) dist[x * 2 + 1][mapY[l.c] * 2] = -1;
    }
  }
  for (const auto& l : hs) {
    for (int y = mapY[l.a]; y <= mapY[l.b]; y++) {
      dist[mapX[l.c] * 2][y * 2 + 0] = -1;
      if (y < mapY[l.b]) dist[mapX[l.c] * 2][y * 2 + 1] = -1;
    }
  }
  queue<pair<int, int> > que;
  que.emplace(make_pair(mapX[0] * 2 + 1, mapY[0] * 2 + 1));
  int dx[] = {0, 1, 0, -1};
  int dy[] = {1, 0, -1, 0};
  ll ans = 0;
  while (!que.empty()) {
    int x = que.front().first;
    int y = que.front().second;
    que.pop();
    if (dist[x][y] == -1) continue;
    if (dist[x][y] == 1) continue;
    dist[x][y] = 1;
    if (x % 2 && y % 2) {
      ans += abs(xs[x / 2] - xs[x / 2 + 1]) * abs(ys[y / 2] - ys[y / 2 + 1]);
    }
    for (int d = (int)(0); d < (int)((4)); d++) {
      int nx = x + dx[d], ny = y + dy[d];
      if (dist[nx][ny] == -1) continue;
      if (dist[nx][ny] == 1) continue;
      if (nx == 0 || nx == xsz * 2 - 1 || ny == 0 || ny == ysz * 2 - 1) {
        cout << "INF\n";
        return;
      }
      que.push(make_pair(nx, ny));
    }
  }
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}
