from itertools import chain
from bisect import bisect_left as bisect
from math import isfinite

N,M = map(int,input().split())

hor = [tuple(map(int,input().split())) for _ in range(N)]
ver = [tuple(map(int,input().split())) for _ in range(M)]

X = sorted(set(chain((a for a,b,c in hor), (b for a,b,c in hor), (a for a,b,c in ver))))
X = tuple(chain((-float('inf'),),*zip(X,X),(float('inf'),)))

Y = sorted(set(chain((c for a,b,c in hor), (b for a,b,c in ver), (c for a,b,c in ver))))
Y = tuple(chain((-float('inf'),),*zip(Y,Y),(float('inf'),)))

grid = [[True]*(len(Y)-1) for _ in range(len(X)-1)]

for x in range(len(X)-1):
    grid[x][0] = None
    grid[x][-1] = None
for y in range(len(Y)-1):
    grid[0][y] = None
    grid[-1][y] = None

for a,b,y in hor:
    ai,bi,yi = bisect(X,a),bisect(X,b),bisect(Y,y)
    for i in range(ai,bi+1):
        grid[i][yi] = False

for x,a,b in ver:
    xi,ai,bi = bisect(X,x),bisect(Y,a),bisect(Y,b)
    for i in range(ai,bi+1):
        grid[xi][i] = False
def dothething():
    x0,y0 = bisect(X,0), bisect(Y,0)
    stack = [(x0,y0)]
    if not grid[x0][y0]:
        print(grid[x0][y0])
        return float('nan')
    grid[x0][y0] = False
    def it():
        while stack:
            i,j = stack.pop()
            yield (X[i+1]-X[i])*(Y[j+1]-Y[j])
            for di,dj in ((0,1),(0,-1),(1,0),(-1,0)):
                ii,jj = i+di,j+dj
                if grid[ii][jj]:
                    grid[ii][jj] = False
                    stack.append((ii, jj))
                elif grid[ii][jj] is None:
                    yield float('nan')
                    return
    return sum(it())

res = dothething()
print(res if isfinite(res) else 'INF')
