#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, M;
ll U[1000], D[1000], X[1000];
ll Y[1000], L[1000], R[1000];

vector<ll> zY, zX;
int tate[4000][4000] ={};
int yoko[4000][4000] ={};

bool canEnter[4000][4000];
queue<pair<int, int>> que;

signed main(){
    cin >> N >> M;
    rep(i, N){
        cin >> U[i] >> D[i] >> X[i];
        zY.pb(U[i]); zY.pb(D[i]);
        zX.pb(X[i]);
    }
    rep(i, M){
        cin >> Y[i] >> L[i] >> R[i];
        zX.pb(L[i]); zX.pb(R[i]);
        zY.pb(Y[i]);
    }
    sort(all(zX));
    zX.erase(unique(all(zX)), zX.end());
    sort(all(zY));
    zY.erase(unique(all(zY)), zY.end());

    rep(i, N){
        tate[lower_bound(all(zX), X[i])-zX.begin()][lower_bound(all(zY), U[i])-zY.begin()]++;
        tate[lower_bound(all(zX), X[i])-zX.begin()][lower_bound(all(zY), D[i])-zY.begin()]--;
    }
    rep(i, zX.size()){
        rep(j, zY.size()-1){
            tate[i][j+1] += tate[i][j];
        }
    }
    rep(i, M){
        yoko[lower_bound(all(zY), Y[i])-zY.begin()][lower_bound(all(zX), L[i])-zX.begin()]++;
        yoko[lower_bound(all(zY), Y[i])-zY.begin()][lower_bound(all(zX), R[i])-zX.begin()]--;
    }
    rep(i, zY.size()){
        rep(j, zX.size()-1){
            yoko[i][j+1] += yoko[i][j];
        }
    }

    int x = lower_bound(all(zX), 0) - zX.begin();
    int y = lower_bound(all(zY), 0) - zY.begin();
    canEnter[x][y] = true;
    que.push({ x,y });
    while(!que.empty()){
        int x = que.front().first;
        int y = que.front().second;
        que.pop();
        if(x == 0 || y == 0 || x == zX.size() || y == zY.size()){
            cout << "INF" << endl;
            return 0;
        }
        if(!tate[x-1][y-1] && !canEnter[x-1][y]){
            canEnter[x-1][y] = true;
            que.push({ x-1,y });
        }
        if(!tate[x][y-1] && !canEnter[x+1][y]){
            canEnter[x+1][y] = true;
            que.push({ x+1,y });
        }
        if(!yoko[y-1][x-1] && !canEnter[x][y-1]){
            canEnter[x][y-1] = true;
            que.push({ x,y-1 });
        }
        if(!yoko[y][x-1] && !canEnter[x][y+1]){
            canEnter[x][y+1] = true;
            que.push({ x,y+1 });
        }
    }

    ll ans = 0;
    rep(i, zX.size()-1){
        rep(j, zY.size()-1){
            if(canEnter[i+1][j+1]){
                ans += (zX[i+1]-zX[i]) * (zY[j+1]-zY[j]);
            }
        }
    }
    cout << ans << endl;
}