### BUGGY CODE ###

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)}

E = [[15]*nx for _ in [0]*ny]

E[0] = [7]*nx
E[-1] = [13]*nx
for i in range(ny):
    E[i][0] -= 4
    E[i][-1] -= 1

for a,b,c in ABC:
    y1 = Ydict[c]
    y0 = y1-1
    for x in range(Xdict[a],Xdict[b]):
        E[y0][x] &= 15-2
        E[y1][x] &= 15-8

for d,e,f in DEF:
    x1 = Xdict[d]
    x0 = x1-1
    for y in range(Ydict[e],Ydict[f]):
        E[y][x0] &= 15-1
        E[y][x1] &= 15-4

dX = [x2-x for x,x2 in zip(X,X[1:])]
dY = [y2-y for y,y2 in zip(Y,Y[1:])]
burst = False
x0 = Xdict[0]
y0 = Ydict[0]
ans = dX[x0]*dY[y0]
done = [[False]*nx for _ in [0]*ny]
done[y0][x0] = True
q = [(x0,y0)]
dxy = [(1,0),(0,1),(-1,0),(0,-1)]
while q:
    qq = []
    for x,y in q:
        e = E[y][x]
        for i in range(4):
            if (e>>i)&1 == 0 : continue
            dx,dy = dxy[i]
            jx = x+dx
            jy = y+dy
            if done[jy][jx]:continue
            done[jy][jx] = True

            if jx==0 or jx==nx-1 or jy==0 or jy==ny-1:
                burst = True
                ans = "INF"
                qq = []
                break
            ans += dX[jx]*dY[jy]
            qq.append((jx,jy))
        if burst:break
    q = qq

print(ans)

### FIXED CODE ###

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 = [[15]*nx for _ in [0]*ny]

E[0] = [7]*nx
E[-1] = [13]*nx
for i in range(ny):
    E[i][0] -= 4
    E[i][-1] -= 1

for a,b,c in ABC:
    y1 = Ydict[c]
    y0 = y1-1
    for x in range(Xdict[a],Xdict[b]):
        E[y0][x] &= 15-2
        E[y1][x] &= 15-8

for d,e,f in DEF:
    x1 = Xdict[d]
    x0 = x1-1
    for y in range(Ydict[e],Ydict[f]):
        E[y][x0] &= 15-1
        E[y][x1] &= 15-4

dX = [x2-x for x,x2 in zip(X,X[1:])]
dY = [y2-y for y,y2 in zip(Y,Y[1:])]
burst = False
x0 = Xdict[0]
y0 = Ydict[0]
ans = dX[x0]*dY[y0]
done = [[False]*nx for _ in [0]*ny]
done[y0][x0] = True
q = [(x0,y0)]
dxy = [(1,0),(0,1),(-1,0),(0,-1)]
while q:
    qq = []
    for x,y in q:
        e = E[y][x]
        for i in range(4):
            if (e>>i)&1 == 0 : continue
            dx,dy = dxy[i]
            jx = x+dx
            jy = y+dy
            if done[jy][jx]:continue
            done[jy][jx] = True

            if jx==0 or jx==nx-1 or jy==0 or jy==ny-1:
                burst = True
                ans = "INF"
                qq = []
                break
            ans += dX[jx]*dY[jy]
            qq.append((jx,jy))
        if burst:break
    q = qq

print(ans)