#include <bits/stdc++.h>
const bool debug = false;
using namespace std;
const long long MOD = 1000000007;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n), b(n), c(n), d(m), e(m), f(m);
  set<long long> st;
  st.insert(0);
  long long lim = 1e+10;
  st.insert(lim);
  st.insert(-lim);
  for (int(i) = 0; (i) < (n); (i)++) {
    cin >> a[i] >> b[i] >> c[i];
    st.insert(a[i]);
    st.insert(b[i]);
    st.insert(c[i]);
  }
  for (int(i) = 0; (i) < (m); (i)++) {
    cin >> d[i] >> e[i] >> f[i];
    st.insert(d[i]);
    st.insert(e[i]);
    st.insert(f[i]);
  }
  map<long long, long long> comp, compinv;
  long long num = 0;
  for (auto x : st) {
    comp[x] = num;
    compinv[num++] = x;
  }
  long long c_size = comp.size();
  vector<vector<vector<bool>>> mat(
      c_size, vector<vector<bool>>(c_size, vector<bool>(2, false)));
  for (int(i) = 0; (i) < (n); (i)++) {
    for (int(j) = (comp[a[i]]); (j) < (comp[b[i]]); (j)++) {
      mat[j][comp[c[i]]][0] = true;
    }
  }
  for (int(i) = 0; (i) < (m); (i)++) {
    for (int(j) = (comp[e[i]]); (j) < (comp[f[i]]); (j)++) {
      mat[comp[d[i]]][j][1] = true;
    }
  }
  queue<pair<long long, long long>> que;
  que.emplace(comp[0], comp[0]);
  long long res = 0;
  vector<vector<long long>> chk(c_size, vector<long long>(c_size, true));
  chk[comp[0]][comp[0]] = false;
  while (!que.empty()) {
    long long x = que.front().first;
    long long y = que.front().second;
    que.pop();
    res += (compinv[x + 1] - compinv[x]) * (compinv[y + 1] - compinv[y]);
    if (x == 0 || y == 0 || x == c_size - 2 || y == c_size - 2) {
      cout << "Inf" << endl;
      return 0;
    }
    if (!mat[x][y][0] && chk[x][y - 1]) {
      que.emplace(x, y - 1);
      chk[x][y - 1] = false;
    }
    if (!mat[x][y][1] && chk[x - 1][y]) {
      que.emplace(x - 1, y);
      chk[x - 1][y] = false;
    }
    if (!mat[x][y + 1][0] && chk[x][y + 1]) {
      que.emplace(x, y + 1);
      chk[x][y + 1] = false;
    }
    if (!mat[x + 1][y][1] && chk[x + 1][y]) {
      que.emplace(x + 1, y);
      chk[x + 1][y] = false;
    }
  }
  cout << res << endl;
  return 0;
}
