#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

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

  int N,M;
  cin>>N>>M;
  vector<ll> A(N),B(N),C(N);
  rep(i,N) cin>>A[i]>>B[i]>>C[i];
  vector<ll> D(M),E(M),F(M);
  rep(i,M) cin>>D[i]>>E[i]>>F[i];

  vector<ll> xs,ys;
  xs.push_back(0);
  ys.push_back(0);
  rep(i,N){
    xs.push_back(A[i]);
    xs.push_back(B[i]);
    ys.push_back(C[i]);
  }
  rep(i,M){
    xs.push_back(D[i]);
    ys.push_back(E[i]);
    ys.push_back(F[i]);
  }
  sort(xs.begin(),xs.end());
  xs.erase(unique(xs.begin(),xs.end()),xs.end());
  sort(ys.begin(),ys.end());
  ys.erase(unique(ys.begin(),ys.end()),ys.end());
  map<ll,int> xmp,ymp;
  int H=xs.size(),W=ys.size();
  rep(i,H) xmp[xs[i]]=i;
  rep(i,W) ymp[ys[i]]=i;

  vector<vector<int>> dp(2*H,vector<int> (2*W,0));
  rep(i,N){
    int u=xmp[A[i]]*2;
    int d=xmp[B[i]]*2;
    int a=ymp[C[i]]*2;
    for(int x=u;x<=d;x++) dp[x][a]=-1;
  }
  rep(i,M){
    int a=xmp[D[i]]*2;
    int l=ymp[E[i]]*2;
    int r=ymp[F[i]]*2;
    for(int y=l;y<=r;y++) dp[a][y]=-1;
  }

  queue<pair<int,int>> Q;
  int stx=xmp[0]*2+1,sty=ymp[0]*2+1;
  dp[stx][sty]=1;
  Q.push(mkp(stx,sty));
  while(!Q.empty()){
    auto f=Q.front();Q.pop();
    int x=f.first;
    int y=f.second;

    rep(k,4){
      int nx=x+dx[k];
      int ny=y+dy[k];
      if(nx<0||nx>=2*H|ny<0||ny>=2*W) continue;
      if(dp[nx][ny]!=0) continue;
      dp[nx][ny]=1;
      Q.push(mkp(nx,ny));
    }
  }

  ll ans=0;
  for(int i=0;i<2*H;i++) for(int j=0;j<2*W;j++){
    if(dp[i][j]!=1) continue;
    if(i==0||i==2*H-1||j==0||j==2*W-1){
      cout<<"INF"<<endl;
      return 0;
    }
    if(i%2==0||j%2==0) continue;
    
    ll ex=xs[i/2+1]-xs[i/2];
    ll ey=ys[j/2+1]-ys[j/2];
    ans+=ex*ey;
  }

  cout<<ans<<endl;

  return 0;
}
