import sys
input = sys.stdin.readline

N,M=map(int,input().split())
TATE=[tuple(map(int,input().split())) for i in range(N)]
YOKO=[tuple(map(int,input().split())) for i in range(M)]


T=[-1<<60,0,1<<60]
Y=[-1<<60,0,1<<60]

for a,b,c in TATE:
    T.append(a)
    T.append(b)
    Y.append(c)

for d,e,f in YOKO:
    T.append(d)
    Y.append(e)
    Y.append(f)

T=sorted(set(T))
Y=sorted(set(Y))

BT=[T[0]]
BY=[Y[0]]

for i in range(1,len(T)):
    BT.append(T[i]-T[i-1])
    BT.append(T[i])

for i in range(1,len(Y)):
    BY.append(Y[i]-Y[i-1])
    BY.append(Y[i])

TDICT=dict()
YDICT=dict()

for i in range(len(BT)):
    if i%2==0:
        TDICT[BT[i]]=i

for i in range(len(BY)):
    if i%2==0:
        YDICT[BY[i]]=i

MAP=[[0]*len(BY) for i in range(len(BT))]

for a,b,c in TATE:
    t0=TDICT[a]
    t1=TDICT[b]
    y=YDICT[c]

    for k in range(t0,t1+1):
        MAP[k][y]=1

for d,e,f in YOKO:
    t=TDICT[d]
    y0=YDICT[e]
    y1=YDICT[f]

    for k in range(y0,y1+1):
        MAP[t][k]=1

#for m in MAP:
#    print(*m)

Q=[(TDICT[0],YDICT[0])]
ANS=0

while Q:
    x,y=Q.pop()
    for z,w in [(x+1,y),(x-1,y),(x,y-1),(x,y+1)]:
        if 0<=z<len(BT) and 0<=w<len(BY) and MAP[z][w]==0:
            MAP[z][w]=1
            Q.append((z,w))
            if z%2==1 and w%2==1:
                ANS+=BT[z]*BY[w]

if ANS>1<<60:
    print("INF")
else:
    print(ANS)