#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long long MAX_N = 200100;
long long xaxis[1010];
long long yaxis[1010];
bool xwall[1010][1010];
bool ywall[1010][1010];
bool grid[1010][1010];
signed main() {
  long long N, M;
  cin >> N >> M;
  vector<pair<long long, pair<long long, long long>>> xinput;
  vector<pair<long long, pair<long long, long long>>> yinput;
  for (long long i = 0; i < N; i++) {
    long long a, b, y;
    cin >> a >> b >> y;
    yinput.push_back(make_pair(y, make_pair(a, b)));
  }
  for (long long i = 0; i < M; i++) {
    long long x, e, f;
    cin >> x >> e >> f;
    xinput.push_back(make_pair(x, make_pair(e, f)));
  }
  sort((xinput).begin(), (xinput).end());
  sort((yinput).begin(), (yinput).end());
  for (long long i = 0; i < N; i++) {
    yaxis[i] = yinput[i].first;
  }
  for (long long i = 0; i < M; i++) {
    xaxis[i] = xinput[i].first;
  }
  for (long long i = 0; i < 1010; i++) {
    for (long long j = 0; j < 1010; j++) {
      xwall[j][i] = false;
      ywall[j][i] = false;
    }
  }
  for (long long i = 0; i < N; i++) {
    long long xa = yinput[i].second.first;
    long long xb = yinput[i].second.second;
    xa = lower_bound(xaxis, xaxis + M, xa) - xaxis;
    xb = upper_bound(xaxis, xaxis + M, xb) - xaxis;
    for (long long x = xa; x <= xb - 1; x++) {
      ywall[x][i] = true;
    }
  }
  for (long long i = 0; i < M; i++) {
    long long ya = xinput[i].second.first;
    long long yb = xinput[i].second.second;
    ya = lower_bound(yaxis, yaxis + N, ya) - yaxis;
    yb = upper_bound(yaxis, yaxis + N, yb) - yaxis;
    for (long long y = ya; y <= yb - 1; y++) {
      xwall[i][y] = true;
    }
  }
  long long start_x = upper_bound(xaxis, xaxis + M, 0) - xaxis - 1;
  long long start_y = upper_bound(yaxis, yaxis + N, 0) - yaxis - 1;
  queue<pair<long long, long long>> q;
  q.push(make_pair(start_x, start_y));
  long long ans = 0;
  while (!q.empty()) {
    long long x = q.front().first;
    long long y = q.front().second;
    q.pop();
    if (grid[x][y]) continue;
    grid[x][y] = true;
    ans += (xaxis[x + 1] - xaxis[x]) * (yaxis[y + 1] - yaxis[y]);
    if (!(xwall[x][y] && xwall[x][y + 1])) {
      if (x == 0) {
        cout << "INF" << endl;
        return 0;
      } else {
        if (!grid[x - 1][y]) q.push(make_pair(x - 1, y));
      }
    }
    if (!(xwall[x + 1][y] && xwall[x + 1][y + 1])) {
      if (x == M - 2) {
        cout << "INF" << endl;
        return 0;
      } else {
        if (!grid[x + 1][y]) q.push(make_pair(x + 1, y));
      }
    }
    if (!(ywall[x][y] && ywall[x + 1][y])) {
      if (y == 0) {
        cout << "INF" << endl;
        return 0;
      } else {
        if (!grid[x][y - 1]) q.push(make_pair(x, y - 1));
      }
    }
    if (!(ywall[x][y + 1] && ywall[x + 1][y + 1])) {
      if (y == N - 2) {
        cout << "INF" << endl;
        return 0;
      } else {
        if (!grid[x][y + 1]) q.push(make_pair(x, y + 1));
      }
    }
  }
  cout << ans << endl;
  return 0;
}
