#include <bits/stdc++.h>
using namespace std;
set<int> ver, hor;
unordered_map<int, int> posH, posV;
unordered_map<int, int> mapaH, mapaV;
set<int> adj[3100][3100];
vector<pair<pair<long long, long long>, long long> > arrV;
vector<pair<long long, pair<long long, long long> > > arrH;
long long grid[3100][3100];
bool vis[3100][3100];
int movX[] = {1, 0, -1, 0};
int movY[] = {0, 1, 0, -1};
int f(long long x, long long y) { return 3110 * x + y; }
pair<long long, bool> dfs(long long x, long long y) {
  vis[x][y] = true;
  if (grid[x][y] == -1) return make_pair(-1, false);
  long long x1, y1;
  pair<long long, bool> rpta = make_pair(grid[x][y], true), aux;
  for (long long i = (long long)(0); i < (long long)(4); i++) {
    x1 = x + movX[i];
    y1 = y + movY[i];
    if (!vis[x1][y1] && !(adj[x][y].count(f(x1, y1)))) {
      aux = dfs(x1, y1);
      rpta.first += aux.first;
      rpta.second &= aux.second;
    }
  }
  return rpta;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  memset(vis, 0, sizeof(vis));
  int n, m;
  long long a, b, c, d, e, f1;
  cin >> n >> m;
  hor.insert(0);
  ver.insert(0);
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    cin >> a >> b >> c;
    hor.insert(a);
    hor.insert(b);
    ver.insert(c);
    arrV.push_back(make_pair(make_pair(a, b), c));
  }
  for (long long j = (long long)(0); j < (long long)(m); j++) {
    cin >> d >> e >> f1;
    hor.insert(d);
    ver.insert(e);
    ver.insert(f1);
    arrH.push_back(make_pair(d, make_pair(e, f1)));
  }
  int indH = 0;
  for (set<int>::iterator it = hor.begin(); it != hor.end(); it++) {
    int x = *it;
    posH[x] = indH;
    mapaH[indH++] = x;
  }
  int indV = 0;
  for (set<int>::iterator it = ver.begin(); it != ver.end(); it++) {
    int x = *it;
    posV[x] = indV;
    mapaV[indV++] = x;
  }
  long long val, dy, dx;
  for (long long i = (long long)(0); i < (long long)(indH + 1); i++) {
    for (long long j = (long long)(0); j < (long long)(indV + 1); j++) {
      if (i == 0 || i == indH)
        val = -1;
      else if (j == 0 || j == indV)
        val = -1;
      else {
        dy = mapaV[j] - mapaV[j - 1];
        dx = mapaH[i] - mapaH[i - 1];
        val = dy * dx;
      }
      grid[i][j] = val;
    }
  }
  long long p, q, h1, h2, v;
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    h1 = posH[arrV[i].first.first];
    h2 = posH[arrV[i].first.second];
    v = posV[arrV[i].second];
    for (long long j = (long long)(h1 + 1); j < (long long)(h2 + 1); j++) {
      p = f(j, v);
      q = f(j, v + 1);
      adj[j][v].insert(q);
      adj[j][v + 1].insert(p);
    }
  }
  long long h, v1, v2;
  for (long long i = (long long)(0); i < (long long)(m); i++) {
    h = posH[arrH[i].first];
    v1 = posV[arrH[i].second.first];
    v2 = posV[arrH[i].second.second];
    for (long long j = (long long)(v1 + 1); j < (long long)(v2 + 1); j++) {
      p = f(h, j);
      q = f(h + 1, j);
      adj[h][j].insert(q);
      adj[h + 1][j].insert(p);
    }
  }
  pair<long long, bool> rpta = dfs(posH[0], posV[0]);
  if (rpta.second)
    cout << rpta.first << endl;
  else
    cout << "INF" << endl;
  return 0;
}
