#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
const long long INF =
    sizeof(long long) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const long long MOD = (long long)1e9 + 7;
const double EPS = 1e-9;
bool G[1010][1010][2];
bool checked[1010][1010];
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, M;
  cin >> N >> M;
  vector<pair<pair<long long, long long>, pair<long long, long long>>> XE(M),
      YE(N);
  for (long long i = (0), i_len = (N); i < i_len; i++) {
    cin >> YE[i].first.second >> YE[i].second.second >> YE[i].first.first;
    YE[i].second.first = YE[i].first.first;
  }
  for (long long i = (0), i_len = (M); i < i_len; i++) {
    cin >> XE[i].first.second >> XE[i].first.first >> XE[i].second.first;
    XE[i].second.second = XE[i].first.second;
  }
  vector<long long> XV, YV;
  XV.push_back(0), YV.push_back(0);
  for (long long i = (0), i_len = (M); i < i_len; i++) {
    XV.push_back(XE[i].first.first);
    XV.push_back(XE[i].second.first);
    YV.push_back(XE[i].first.second);
    YV.push_back(XE[i].second.second);
  }
  for (long long i = (0), i_len = (N); i < i_len; i++) {
    XV.push_back(YE[i].first.first);
    XV.push_back(YE[i].second.first);
    YV.push_back(YE[i].first.second);
    YV.push_back(YE[i].second.second);
  }
  sort(begin(XV), end(XV));
  sort(begin(YV), end(YV));
  XV.erase(unique(begin(XV), end(XV)), XV.end());
  YV.erase(unique(begin(YV), end(YV)), YV.end());
  long long H = ((long long)(YV).size()) - 1, W = ((long long)(XV).size()) - 1;
  for (long long i = (0), i_len = (M); i < i_len; i++) {
    long long lx =
        lower_bound(begin(XV), end(XV), XE[i].first.first) - XV.begin();
    long long rx =
        lower_bound(begin(XV), end(XV), XE[i].second.first) - XV.begin();
    long long y =
        lower_bound(begin(YV), end(YV), XE[i].first.second) - YV.begin();
    for (long long j = (lx), j_len = (rx); j < j_len; j++) {
      G[y][j][0] = true;
    }
  }
  for (long long i = (0), i_len = (N); i < i_len; i++) {
    long long x =
        lower_bound(begin(XV), end(XV), YE[i].first.first) - XV.begin();
    long long uy =
        lower_bound(begin(YV), end(YV), YE[i].first.second) - YV.begin();
    long long dy =
        lower_bound(begin(YV), end(YV), YE[i].second.second) - YV.begin();
    for (long long j = (uy), j_len = (dy); j < j_len; j++) {
      G[j][x][1] = true;
    }
  }
  queue<pair<long long, long long>> q;
  pair<long long, long long> sp;
  sp.first = lower_bound(begin(XV), end(XV), 0) - XV.begin();
  sp.second = lower_bound(begin(YV), end(YV), 0) - YV.begin();
  q.push(sp);
  const long long dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
  checked[sp.second][sp.first] = true;
  bool inf = false;
  while (!q.empty()) {
    auto p = q.front();
    q.pop();
    if (!G[p.second][p.first][1]) {
      if (p.first == 0) {
        inf = true;
        break;
      } else {
        if (!checked[p.second][p.first - 1]) {
          checked[p.second][p.first - 1] = true;
          q.push(make_pair(p.first - 1, p.second));
        }
      }
    }
    if (!G[p.second][p.first + 1][1]) {
      if (p.first == W - 1) {
        inf = true;
        break;
      } else {
        if (!checked[p.second][p.first + 1]) {
          checked[p.second][p.first + 1] = true;
          q.push(make_pair(p.first + 1, p.second));
        }
      }
    }
    if (!G[p.second][p.first][0]) {
      if (p.second == 0) {
        inf = true;
        break;
      } else {
        if (!checked[p.second - 1][p.first]) {
          checked[p.second - 1][p.first] = true;
          q.push(make_pair(p.first, p.second - 1));
        }
      }
    }
    if (!G[p.second + 1][p.first][0]) {
      if (p.second == H - 1) {
        inf = true;
        break;
      } else {
        if (!checked[p.second + 1][p.first]) {
          checked[p.second + 1][p.first] = true;
          q.push(make_pair(p.first, p.second + 1));
        }
      }
    }
  }
  if (inf) {
    cout << "INF" << endl;
  } else {
    long long ans = 0;
    for (long long i = (0), i_len = (H); i < i_len; i++)
      for (long long j = (0), j_len = (W); j < j_len; j++) {
        if (checked[i][j]) {
          ans += (XV[j + 1] - XV[j]) * (YV[i + 1] - YV[i]);
        }
      }
    cout << ans << endl;
  }
  return 0;
}
