#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(in) in.begin(),in.end()
using ll = long long;
using namespace std;

vector<ll> compress(vector<ll> &vals) {
    sort(vals.begin(), vals.end());
    vals.erase(unique(vals.begin(), vals.end()), vals.end());
    return vals;
}

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

int main(){
    int n, m; cin >> n >> m;
    vector<ll> x, y;
    vector<ll> a(n), b(n), c(n), d(m), e(m), f(m);

    rep(i,n){
        cin >> a[i] >> b[i] >> c[i];
        x.push_back(a[i]);
        x.push_back(b[i]);
        y.push_back(c[i]);
    }
    rep(i,m){
        cin >> d[i] >> e[i] >> f[i];
        x.push_back(d[i]);
        y.push_back(e[i]);
        y.push_back(f[i]);
    }
    x.push_back(1001001001ll);
    x.push_back(-1001001001ll);
    x.push_back(0ll);
    y.push_back(1001001001ll);
    y.push_back(-1001001001ll);
    y.push_back(0ll);
  
    auto xx = compress(x);
    auto yy = compress(y);
    int nx = (int)xx.size() * 2 - 1;
    int ny = (int)yy.size() * 2 - 1;

    vector<vector<pair<ll,ll>>> data(nx,vector<pair<ll,ll>>(ny,make_pair(1ll,0ll)));
    rep(i,(int)xx.size()-1) rep(j,(int)yy.size()-1) {
        data[i*2+1][j*2+1].second = (xx[i+1] - xx[i]) * (yy[j+1] - yy[j]);
    }
    rep(i,n){
        int id = lower_bound(all(yy),c[i]) - yy.begin();
        int from = lower_bound(all(xx),a[i]) - xx.begin();
        int to = lower_bound(all(xx),b[i]) - xx.begin();
        for(int j = from * 2; j <= to * 2; j++) data[j][id*2].first = 0;
    }
    rep(i,m){
        int id = lower_bound(all(xx),d[i]) - xx.begin();
        int from = lower_bound(all(yy),e[i]) - yy.begin();
        int to = lower_bound(all(yy),f[i]) - yy.begin();
        for(int j = from * 2; j <= to * 2; j++) data[id*2][j].first = 0;
    }
    int sx = (lower_bound(all(xx),0ll) - xx.begin()) * 2;
    int sy = (lower_bound(all(yy),0ll) - yy.begin()) * 2;

    queue<pair<int,int>> que;
    que.push(make_pair(sx,sy));
    ll ans = 0;
    while(!que.empty()){
        auto p = que.front();
        que.pop();
        rep(i,4){
            int nnx = p.first + dx[i], nny = p.second + dy[i];
            if(0 <= nnx && nnx < nx && 0 <= nny && nny < ny){
                if(!data[nnx][nny].first) continue;
                if(nnx == 0 || nnx == nx || nny == 0 || nny == ny){
                    cout << "INF" << endl;
                    return 0;
                }
                else{
                    data[nnx][nny].first = 0;
                    ans += data[nnx][nny].second;
                    que.push(make_pair(nnx,nny));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}