#include <bits/stdc++.h>

using namespace std;

set <long long int> sx,sy;
map <long long int,int> mx,my;
long long int compx[8005],compy[8005];
int n,m;
long long int a,b,c;
vector <pair<pair<long long int,long long int>,pair<long long int,long long int>>> l;
bool visited[8005][8005];
bool board[8005][8005];
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};

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

	cin >> n >> m;

	for(int i=0;i<n;i++)
	{
		cin >> a >> b >> c;
		l.push_back(make_pair(make_pair(a,c),make_pair(b,c)));
		sy.insert(a);
		sy.insert(b);
		sx.insert(c);
	}
	for(int i=0;i<m;i++)
	{
		cin >> a >> b >> c;
		l.push_back(make_pair(make_pair(a,b),make_pair(a,c)));
		sy.insert(a);
		sx.insert(b);
		sx.insert(c);
	}
	sx.insert(0);
	sy.insert(0);
	sx.insert(-1e18);
	sx.insert(1e18);
	sy.insert(-1e18);
	sy.insert(1e18);

	int idxx = 0;
	int idxy = 0;

	for(auto it : sy)
	{
		my[it] = idxy;
		compy[idxy] = it;
		idxy+=2;
	}
	for(auto it : sx)
	{
		mx[it] = idxx;
		compx[idxx] = it;
		idxx+=2;
	}

	memset(board,true,sizeof(board));

	for(int i=0;i<l.size();i++)
	{
		int y1 = my[l[i].first.first];
		int x1 = mx[l[i].first.second];
		int y2 = my[l[i].second.first];
		int x2 = mx[l[i].second.second];

		if(y1==y2)
		{
			for(int j=x1;j<=x2;j++)
			{
				board[y1][j] = false;
			}
		}
		else
		{
			for(int j=y1;j<=y2;j++)
			{
				board[j][x1] = false;
			}
		}
	}

	memset(visited,false,sizeof(visited));
	queue <pair<int,int>> que;
	for(int ny=-1;ny<=1;ny+=2)
	{
		for(int nx=-1;nx<=1;nx+=2)
		{
			que.push(make_pair(my[0]+ny,mx[0]+nx));
			//cout << my[0]+ny << ' ' << mx[0] + nx << '\n';
			visited[my[0] + ny][mx[0] + nx] = true;
		}
	}

	while(!que.empty())
	{
		int y = que.front().first;
		int x = que.front().second;
		que.pop();
		//cout << y << ' ' << x << '\n';
		if(y<=0 || y>=idxy-2 || x<=0 || x>=idxx-2)
		{
			cout << "INF" << '\n';
			return 0;
		}

		for(int i=0;i<4;i++)
		{
			int ny = y + 2*dy[i];
			int nx = x + 2*dx[i];
			if(ny<0 || ny>=idxy || nx<0 || nx>=idxx)
			{
				continue;
			}
			int checky = (ny + y)/2;
			int checkx = (nx + x)/2;
			if(board[checky][checkx]==false)
			{
				continue;
			}
			if(visited[ny][nx]==false)
			{
				visited[ny][nx] = true;
				que.push(make_pair(ny,nx));
			}
		}
	}

	long long int res = 0;

	/*
	for(int y=0;y<idxy;y++)
	{
		for(int x=0;x<idxx;x++)
		{
			cout << board[y][x];
		}
		cout << '\n';
	}
	*/

	for(int y=1;y<idxy;y+=2)
	{
		for(int x=1;x<idxx;x+=2)
		{
			if(visited[y][x])
			{
				long long int dy = compy[y+1] - compy[y-1];
				long long int dx = compx[x+1] - compx[x-1];
				res += dy*dx;
			}
		}
	}

	cout << res << '\n';

	return 0;
}