#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = 1e-9;
const long long INF = 1e9 + 10;
const long long MOD = 1e9 + 7;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
vector<long long> A(1001), B(1001), C(1001), D(1001), E(1001), F(1001);
vector<long long> AA(1001), BB(1001), CC(1001), DD(1001), EE(1001), FF(1001);
vector<long long> xs, ys;
vector<long long> xl(3006), yl(3006);
bool fld[3006][3006][4];
bool v[3006][3006];
int main() {
  long long N, M, x0, y0;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i] >> C[i];
    xs.push_back(A[i]);
    xs.push_back(B[i]);
    ys.push_back(C[i]);
  }
  for (int i = 0; i < M; i++) {
    cin >> D[i] >> E[i] >> F[i];
    xs.push_back(D[i]);
    ys.push_back(E[i]);
    ys.push_back(F[i]);
  }
  sort(xs.begin(), xs.end()), sort(ys.begin(), ys.end());
  xs.push_back(xs[xs.size() - 1] + 1);
  xs.push_back(xs[0] - 1);
  ys.push_back(ys[ys.size() - 1] + 1);
  ys.push_back(ys[0] - 1);
  sort(xs.begin(), xs.end()), sort(ys.begin(), ys.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  ys.erase(unique(ys.begin(), ys.end()), ys.end());
  for (int i = 0; i < xs.size() - 1; i++) {
    xl[i] = xs[i + 1] - xs[i];
    if (xs[i] <= 0 && xs[i + 1] >= 0) {
      x0 = i - 1;
    }
  }
  xl[xs.size() - 1] = 1;
  for (int i = 0; i < ys.size() - 1; i++) {
    yl[i] = ys[i + 1] - ys[i];
    if (ys[i] <= 0 && ys[i + 1] >= 0) {
      y0 = i - 1;
    }
  }
  yl[ys.size() - 1] = 1;
  for (int i = 0; i < N; i++) {
    AA[i] = find(xs.begin(), xs.end(), A[i]) - xs.begin();
    BB[i] = find(xs.begin(), xs.end(), B[i]) - xs.begin();
    CC[i] = find(ys.begin(), ys.end(), C[i]) - ys.begin();
    for (int j = AA[i]; j < BB[i]; j++) {
      fld[j][CC[i] - 1][0] = true;
      fld[j][CC[i]][2] = true;
    }
  }
  for (int i = 0; i < M; i++) {
    DD[i] = find(xs.begin(), xs.end(), D[i]) - xs.begin();
    EE[i] = find(ys.begin(), ys.end(), E[i]) - ys.begin();
    FF[i] = find(ys.begin(), ys.end(), F[i]) - ys.begin();
    for (int j = EE[i]; j < FF[i]; j++) {
      fld[DD[i] - 1][j][1] = true;
      fld[DD[i]][j][3] = true;
    }
  }
  long long ans = 0;
  queue<pair<long long, long long> > que;
  que.push(make_pair(x0, y0));
  while (!que.empty()) {
    long long qx = que.front().first, qy = que.front().second;
    que.pop();
    if (qx == 0 || qx == xs.size() - 1 || qy == 0 || qy == ys.size() - 1) {
      cout << "INF";
      return 0;
    }
    if (v[qx][qy]) {
      continue;
    }
    v[qx][qy] = true;
    ans += xl[qx] * yl[qy];
    for (int j = 0; j < 4; j++) {
      if (qx >= 1 && qx < xs.size() - 1 && qy >= 1 && qy < ys.size() - 1 &&
          !fld[qx][qy][j]) {
        if (j == 0) que.push(make_pair(qx, qy + 1));
        if (j == 1) que.push(make_pair(qx + 1, qy));
        if (j == 2) que.push(make_pair(qx, qy - 1));
        if (j == 3) que.push(make_pair(qx - 1, qy));
      }
    }
  }
  cout << ans;
  return 0;
}
