#include <bits/stdc++.h>
using namespace std;
int N, M;
int X1[1010], X2[1010], Y[1010];
int X[1010], Y1[1010], Y2[1010];
int HNG[4040][4040];
int VNG[4040][4040];
template <int um>
class UF {
 public:
  vector<int> par, rank, cnt;
  UF() {
    par = rank = vector<int>(um, 0);
    cnt = vector<int>(um, 1);
    for (int i = 0; i < um; i++) par[i] = i;
  }
  void reinit() {
    int i;
    for (i = 0; i < (um); i++) rank[i] = 0, cnt[i] = 1, par[i] = i;
  }
  int operator[](int x) {
    return (par[x] == x) ? (x) : (par[x] = operator[](par[x]));
  }
  int count(int x) { return cnt[operator[](x)]; }
  int operator()(int x, int y) {
    if ((x = operator[](x)) == (y = operator[](y))) return x;
    cnt[y] = cnt[x] = cnt[x] + cnt[y];
    if (rank[x] > rank[y]) return par[x] = y;
    rank[x] += rank[x] == rank[y];
    return par[y] = x;
  }
};
UF<4000 * 4000> uf;
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N >> M;
  vector<int> Xs, Ys;
  Xs.push_back(-1 << 30);
  Xs.push_back(0);
  Xs.push_back(1 << 30);
  Ys.push_back(-1 << 30);
  Ys.push_back(0);
  Ys.push_back(1 << 30);
  for (i = 0; i < (N); i++) {
    cin >> Y1[i] >> Y2[i] >> X[i];
    Xs.push_back(X[i]);
    Ys.push_back(Y1[i]);
    Ys.push_back(Y2[i]);
  }
  for (i = 0; i < (M); i++) {
    cin >> Y[i] >> X1[i] >> X2[i];
    Xs.push_back(X1[i]);
    Xs.push_back(X2[i]);
    Ys.push_back(Y[i]);
  }
  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 (i = 0; i < (N); i++) {
    X[i] = lower_bound((Xs.begin()), (Xs.end()), X[i]) - Xs.begin();
    Y1[i] = lower_bound((Ys.begin()), (Ys.end()), Y1[i]) - Ys.begin();
    Y2[i] = lower_bound((Ys.begin()), (Ys.end()), Y2[i]) - Ys.begin();
    VNG[Y1[i]][X[i]]++;
    VNG[Y2[i]][X[i]]--;
  }
  for (i = 0; i < (M); i++) {
    X1[i] = lower_bound((Xs.begin()), (Xs.end()), X1[i]) - Xs.begin();
    X2[i] = lower_bound((Xs.begin()), (Xs.end()), X2[i]) - Xs.begin();
    Y[i] = lower_bound((Ys.begin()), (Ys.end()), Y[i]) - Ys.begin();
    HNG[Y[i]][X1[i]]++;
    HNG[Y[i]][X2[i]]--;
  }
  for (y = 0; y < (Ys.size()); y++)
    for (x = 0; x < (Xs.size()); x++)
      if (x) HNG[y][x] += HNG[y][x - 1];
  for (x = 0; x < (Xs.size()); x++)
    for (y = 0; y < (Ys.size()); y++)
      if (y) VNG[y][x] += VNG[y - 1][x];
  for (x = 0; x < (Xs.size()); x++)
    for (y = 0; y < (Ys.size()); y++) {
      if (x && VNG[y][x] == 0) uf(y * 4000 + x, y * 4000 + x - 1);
      if (y && HNG[y][x] == 0) uf(y * 4000 + x, (y - 1) * 4000 + x);
    }
  int rx, ry;
  rx = lower_bound((Xs.begin()), (Xs.end()), 0) - Xs.begin();
  ry = lower_bound((Ys.begin()), (Ys.end()), 0) - Ys.begin();
  if (uf[ry * 4000 + rx] == uf[0]) return (void)printf("INF\n");
  signed long long ret = 0;
  for (x = 0; x < (Xs.size() - 1); x++)
    for (y = 0; y < (Ys.size() - 1); y++)
      if (uf[ry * 4000 + rx] == uf[y * 4000 + x]) {
        ret += 1LL * (Ys[y + 1] - Ys[y]) * (Ys[x + 1] - Ys[x]);
      }
  cout << ret << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
