N,M = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in [0]*N ]
DEF = [list(map(int,input().split())) for _ in [0]*M ]

X = [0]*3003
Y = [0]*3003
INF = 10**9 + 10
X[-1] = -INF
Y[-1] = -INF
X[-2] = INF
Y[-2] = INF
i = 0
j = 0
for a,b,c in ABC:
    X[i] = a
    X[i+1] = b
    Y[j] = c
    i += 2
    j += 1
for d,e,f in DEF:
    X[i] = d
    Y[j] = e
    Y[j+1] = f
    i += 1
    j += 2
X = sorted(set(X))
Y = sorted(set(Y))
Xdict = {x:i for i,x in enumerate(X)}
Ydict = {y:i for i,y in enumerate(Y)}

nx = len(X)
ny = len(Y)
nxy = nx * ny
E = {(x,y):{(X[i-1],y),(X[i+1],y),(x,Y[j-1]),(x,Y[j+1])} for i,x in enumerate(X[1:-1],1) for j,y in enumerate(Y[1:-1],1)}

x0 = X[0]
x1 = X[-1]
for y in Y:
    E[(x0,y)] = set()
    E[(x1,y)] = set()
y0 = Y[0]
y1 = Y[-1]
for x in X:
    E[(x,y0)] = set()
    E[(x,y1)] = set()

for a,b,c in ABC:
    y = Y[Ydict[c]-1]
    for x in X[Xdict[a]:Xdict[b]]:
        E[(x,c)].discard((x,y))
        E[(x,y)].discard((x,c))

for d,e,f in DEF:
    x = X[Xdict[d]-1]
    for y in Y[Ydict[e]:Ydict[f]]:
        E[(d,y)].discard((x,y))
        E[(x,y)].discard((d,y))

dX = {x:x2-x for x,x2 in zip(X[:-1],X[1:])}
dY = {y:y2-y for y,y2 in zip(Y[:-1],Y[1:])}
burst = False
ans = 0
done = {(0,0)}
q = [(0,0)]
while q:
    qq = []
    for i in q:
        di = d[i]
        for j in E[i]:
            if j in done:continue
            done.add(j)
            x,y = j
            if abs(x)==INF or abs(y)==INF:
                burst = True
                ans = "INF"
                qq = []
                break
            ans += dX[x]*dY[y]
            qq.append(j)
        if burst:break
    q = qq

print(ans)