import sys
readline = sys.stdin.readline

def compress(L):
    L2 = list(set(L))
    L2.sort()
    C = {v : k for k, v in enumerate(L2)}
    return L2, C

N, M = map(int, readline().split())
INF = 10**9+7

Wp = [tuple(map(int, readline().split())) for _ in range(N)]
Hp = [tuple(map(int, readline().split())) for _ in range(M)]

epx = [0, INF, -INF]
epy = [0, INF, -INF]

for X, st, en in Hp:
    epx.append(X)
    epy.append(st)
    epy.append(en)

for st, en, Y in Wp:
    epy.append(Y)
    epx.append(st)
    epx.append(en)
    

Elx, Cex = compress(epx)
Ely, Cey = compress(epy)
Lx = len(Elx)
Ly = len(Ely)

event = [[] for _ in range(Lx)]
for X, st, en in Hp:
    event[Cex[X]].append((0, Cey[st], Cey[en]))
for st, en, Y in Wp:
    event[Cex[st]].append((1, Cey[Y], 0))
    event[Cex[en]].append((-1, Cey[Y], 0))

geta = Ly

direc = [[1, -1, geta, -geta] for _ in range(Lx*Ly)]

table = [0]*Ly
for xi in range(Lx):
    for a, b, c in event[xi]:
        if a == 0:
            for yi in range(b, c):
                direc[(xi-1)*geta+yi].remove(geta)
                direc[xi*geta+yi].remove(-geta)
        elif a == 1:
            table[b] = 1
        else:
            table[b] = 0
    for i in range(Ly):
        if table[i]:
            direc[xi*geta+i].remove(-1)
            direc[xi*geta+i-1].remove(1)
                
ed = set()
for i in range(Lx):
    ed.add(i*geta)
    ed.add(i*geta+Ly-1)
for j in range(Ly):
    ed.add(j)
    ed.add((Lx-1)*geta+j)
used = set()
st = Cex[0]*geta+Cey[0]
stack = [st]

while stack:
    vn = stack.pop()
    if vn in ed:
        continue
    for d in direc[vn]:
        vf = vn+d
        if vf not in used:
            used.add(vf)
            stack.append(vf)

if ed&used:
    print('INF')
else:
    area = 0
    for k in used:
        x, y = divmod(k, geta)
        area += (Elx[x+1]-Elx[x])*(Ely[y+1]-Ely[y])
    print(area)
    

