#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &s, vector<T> vec) {
  for (int i = 0; i < (int)vec.size(); ++i) {
    if (i > 0) {
      s << " ";
    }
    s << vec[i];
  }
  return s << endl;
}
template <class T>
ostream &operator<<(ostream &s, vector<vector<T>> vec2) {
  for (int i = 0; i < (int)vec2.size(); ++i) {
    s << vec2[i];
  }
  return s;
}
template <typename T>
vector<T> compress(vector<T> &C1, vector<T> &C2) {
  vector<T> vals;
  int N = (int)C1.size();
  for (int i = 0; i < N; i++) {
    T tc1 = C1[i];
    T tc2 = C2[i];
    vals.push_back(tc1);
    vals.push_back(tc2);
  }
  sort(vals.begin(), vals.end());
  vals.erase(unique(vals.begin(), vals.end()), vals.end());
  for (int i = 0; i < N; i++) {
    C1[i] = lower_bound(vals.begin(), vals.end(), C1[i]) - vals.begin();
    C2[i] = lower_bound(vals.begin(), vals.end(), C2[i]) - vals.begin();
  }
  return vals;
}
using ll = long long;
int main() {
  int N, M;
  cin >> N >> M;
  vector<long long> X1, Y1, X2, Y2;
  for (int i = 0; i < N; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    X1.push_back(a);
    X2.push_back(b);
    Y1.push_back(c);
    Y2.push_back(c);
  }
  for (int i = 0; i < M; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    X1.push_back(a);
    X2.push_back(a);
    Y1.push_back(b);
    Y2.push_back(c);
  }
  X1.push_back(0);
  X2.push_back(0);
  Y1.push_back(0);
  Y2.push_back(0);
  vector<long long> X = compress(X1, X2);
  vector<long long> Y = compress(Y1, Y2);
  int H = X.size() * 2;
  int W = Y.size() * 2;
  vector<vector<int>> G(H, vector<int>(W));
  for (int i = 0; i < N; i++) {
    for (int x = X1[i] * 2; x <= X2[i] * 2; x++) {
      G[x][Y1[i] * 2] = -1;
    }
  }
  for (int i = N; i < N + M; i++) {
    for (int y = Y1[i] * 2; y <= Y2[i] * 2; y++) {
      G[X1[i] * 2][y] = -1;
    }
  }
  using P = pair<int, int>;
  P s(X1[N + M] * 2, Y1[N + M] * 2);
  G[s.first][s.second] = 1;
  queue<pair<int, int>> que;
  que.emplace(s);
  while (que.size() != 0) {
    pair<int, int> now = que.front();
    que.pop();
    int dx[4] = {1, -1, 0, 0};
    int dy[4] = {0, 0, 1, -1};
    for (int i = 0; i < 4; i++) {
      int nx = now.first + dx[i];
      int ny = now.second + dy[i];
      if (nx < 0 || ny < 0 || H <= nx || W <= ny) continue;
      if (G[nx][ny] != 0) continue;
      que.push(P(nx, ny));
      G[nx][ny] = 1;
    }
  }
  ll ans = 0;
  for (int x = 0; x < H; x++) {
    for (int y = 0; y < W; y++) {
      if (G[x][y] != 1) continue;
      if (x == 0 || H - 1 == x || y == 0 || W - 1 == y) {
        cout << "INF" << endl;
        return 0;
      }
      if (x % 2 == 0 || y % 2 == 0) continue;
      ans += (X[x / 2 + 1] - X[x / 2]) * (Y[x / 2 + 1] - Y[x / 2]);
    }
  }
  cout << ans << endl;
}
