I=lambda:[int(i)for i in input().split()];F=1<<65;r=range;n,m=I();X=set([0,F,-F]);Y=set(X);R=[((-F,F),F),((-F,F),-F)];H=[(F,(-F,F)),(-F,(-F,F))]
for i in r(n):a,b,c=I();R.append(((a,b),c));Y.add(c);X.add(a);X.add(b)
for i in r(m):a,b,c=I();H.append((a,(b,c)));X.add(a);Y.add(b);Y.add(c)
s=dict(enumerate(sorted(X)));K=len(s);t=dict(enumerate(sorted(Y)));L=len(t);h=dict((s[i],i)for i in s);w=dict((t[i],i)for i in t)
V=[[0]*-~K for i in r(L+1)];U=[i[:]for i in V];v=[i[:]for i in V];q=[(h[0],w[0])];v[w[0]][h[0]]=1;z=0
for (a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for i in r(L+1):
 for j in r(K):
  U[i][j+1]+=U[i][j]
for d,(e,f) in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for j in r(K+1):
 for i in r(L):
  V[i+1][j]+=V[i][j]
while q:
 x,y=q.pop();z+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  k=0;c=x+e;d=y+f
  if(0<=c<K)*(0<=d<L)*v[d][c]==0:k=U[-~f//2+y][x]==0if f!=0else V[y][-~e//2+x]==0
  if k:q.append((c,d));v[d][c]=1
if z>F:z='INF'
print(z)