#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N,M;
int A[1000],B[1000],C[1000];
int D[1000],E[1000],F[1000];
bool vis[3010][3010];
int wx[3010][3010],wy[3010][3010];
int main()
{
	cin>>N>>M;
	vector<long>X,Y;
	X.push_back(0);
	Y.push_back(0);
	for(int i=0;i<N;i++)
	{
		cin>>A[i]>>B[i]>>C[i];
		X.push_back(A[i]);
		X.push_back(B[i]);
		Y.push_back(C[i]);
	}
	for(int i=0;i<M;i++)
	{
		cin>>D[i]>>E[i]>>F[i];
		X.push_back(D[i]);
		Y.push_back(E[i]);
		Y.push_back(F[i]);
	}
	sort(X.begin(),X.end());
	X.erase(unique(X.begin(),X.end()),X.end());
	sort(Y.begin(),Y.end());
	Y.erase(unique(Y.begin(),Y.end()),Y.end());
	for(int i=0;i<N;i++)
	{
		A[i]=lower_bound(X.begin(),X.end(),A[i])-X.begin();
		B[i]=lower_bound(X.begin(),X.end(),B[i])-X.begin();
		C[i]=lower_bound(Y.begin(),Y.end(),C[i])-Y.begin();
		wx[A[i]][C[i]]++;
		wx[B[i]][C[i]]--;
	}
	for(int i=0;i<M;i++)
	{
		D[i]=lower_bound(X.begin(),X.end(),D[i])-X.begin();
		E[i]=lower_bound(Y.begin(),Y.end(),E[i])-Y.begin();
		F[i]=lower_bound(Y.begin(),Y.end(),F[i])-Y.begin();
		wy[D[i]][E[i]]++;
		wy[D[i]][F[i]]--;
	}
	for(int i=0;i<=X.size();i++)for(int j=0;j<=Y.size();j++)
	{
		wx[i+1][j]+=wx[i][j];
		wy[i][j+1]+=wy[i][j];
	}
	queue<pair<int,int> >P;
	int sx=lower_bound(X.begin(),X.end(),0)-X.begin();
	int sy=lower_bound(Y.begin(),Y.end(),0)-Y.begin();
	for(int x=sx-1;x<=sx;x++)for(int y=sy-1;y<=sy;y++)
	{
		vis[x][y]=true;
		P.push(make_pair(x,y));
	}
	long ans=0;
	while(!P.empty())
	{
		int x=P.front().first,y=P.front().second;
		P.pop();
		if(x==-1||y==-1||x+1==X.size()||y+1==Y.size())
		{
			cout<<"INF"<<endl;
			return 0;
		}
		ans+=(X[x+1]-X[x])*(Y[y+1]-Y[y]);
		if(!wy[x][y]&&!vis[x-1][y])
		{
			vis[x-1][y]=true;
			P.push(make_pair(x-1,y));
		}
		if(!wx[x][y]&&!vis[x][y-1])
		{
			vis[x][y-1]=true;
			P.push(make_pair(x,y-1));
		}
		if(!wy[x+1][y]&&!vis[x+1][y])
		{
			vis[x+1][y]=true;
			P.push(make_pair(x+1,y));
		}
		if(!wx[x][y+1]&&!vis[x][y+1])
		{
			vis[x][y+1]=true;
			P.push(make_pair(x,y+1));
		}
	}
	cout<<ans<<endl;
}