#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
#define debug(x) cerr <<__LINE__<< ": " << #x << " -> " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" -> ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        int rx = root(x), ry = root(y);
        if (rx == ry) return false;
        if (size(rx) < size(ry)) swap(rx, ry);
        par[rx] += par[ry];
        par[ry] = rx;
        return true;
    }

    bool isSame(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par[root(x)];
    }
};

vector<int> X, Y, X1, X2, Y1, Y2;
vector<int> Xs, Ys;
bool L[4040][4040], U[4040][4040];

void solve() {
    int n, m;
    cin >> n >> m;
    Xs.pb(-INF);
    Xs.pb(0);
    Xs.pb(INF);
    Ys.pb(-INF);
    Ys.pb(0);
    Ys.pb(INF);
    rep(i, n) {
        int y1, y2, x;
        cin >> y1 >> y2 >> x;
        Y1.pb(y1);
        Y2.pb(y2);
        X.pb(x);
        Ys.pb(y1);
        Ys.pb(y2);
        Xs.pb(x);
    }
    rep(i, m) {
        int y, x1, x2;
        cin >> y >> x1 >> x2;
        Y.pb(y);
        X1.pb(x1);
        X2.pb(x2);
        Ys.pb(y);
        Xs.pb(x1);
        Xs.pb(x2);
    }
    sort(all(Xs));
    sort(all(Ys));
    Xs.erase(unique(all(Xs)), Xs.end());
    Ys.erase(unique(all(Ys)), Ys.end());
    rep(i, n) {
        X[i] = lower_bound(all(Xs), X[i]) - Xs.begin();
        Y1[i] = lower_bound(all(Ys), Y1[i]) - Ys.begin();
        Y2[i] = lower_bound(all(Ys), Y2[i]) - Ys.begin();
        REP(y, Y1[i], Y2[i]) L[y][X[i]] = 1;
    }
    rep(i, m) {
        Y[i] = lower_bound(all(Ys), Y[i]) - Ys.begin();
        X1[i] = lower_bound(all(Xs), X1[i]) - Xs.begin();
        X2[i] = lower_bound(all(Xs), X2[i]) - Xs.begin();
        REP(x, X1[i], X2[i]) U[Y[i]][x] = 1;
    }

    int sy = lower_bound(all(Ys), 0) - Ys.begin();
    int sx = lower_bound(all(Xs), 0) - Xs.begin();
    int H = Ys.size(), W = Xs.size();

    auto en = [&](int i, int j) { return i * W + j; };
    UnionFind uf(H * W);

    REP(i, 1, H) REP(j, 1, W) {
        if (!U[i][j]) uf.unite(en(i, j), en(i - 1, j));
        if (!L[i][j]) uf.unite(en(i, j), en(i, j - 1));
    }

    ll ans = 0;

    rep(i, H) rep(j, W) {
        if (uf.isSame(en(sy, sx), en(i, j))) {
            if (i == 0 || i == H - 1 || j == 0 || j == W - 1) {
                cout << "INF" << endl;
                return;
            } else {
                ans += 1LL * (Ys[i + 1] - Ys[i]) * (Xs[j + 1] - Xs[j]);
            }
        }
    }

    cout << ans << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 55960