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)

xdc=dict(enumerate(sorted(X)))
nx=len(xdc)
ydc=dict(enumerate(sorted(Y)))
ny=len(ydc)
 
h=dict(zip(xdc.values(),xdc.keys()))
w=dict(zip(ydc.values(),ydc.keys()))
 
V=[[0]*(nx+1+1)for i in r(ny+1+1)]
U=[i[:]for i in V]

for (a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for i in r(ny+1):
 for j in r(nx):
  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(nx+1):
 for i in r(ny):
  V[i+1][j]+=V[i][j]

v=[[0]*(nx+1) for i in r(ny+1)]
q=[(h[0],w[0])]
v[w[0]][h[0]]=1

a=0
while q:
    cx,cy=q.pop()
    a+=(xdc[cx]-xdc[cx+1])*(ydc[cy]-ydc[cy+1])
    for dx,dy in [(-1,0),(1,0),(0,1),(0,-1)]:
        k=0
        nbx=cx+dx
        nby=cy+dy
        if (0>nbx>=nx)or(0>nby>=ny)or v[nby][nbx]==1:
            continue
        if dy!=0:
            k=U[-~dy//2+cy][cx]==0
        else:
            if V[cy][-~dx//2+cx]==0:
                q.append((nbx,nby))
                v[nby][nbx]=1
        if k:q.append((nbx,nby));v[nby][nbx]=1

if a>=F:a='INF'
print(a)
