from collections import deque

N, M = map(int, input().split())
Vs = []
Hs = []
Xs = {0}
Ys = {0}

for _ in range(N):
    x1, x2, y = map(int, input().split())
    Xs.add(x1)
    Xs.add(x2)
    Ys.add(y)
    Vs.append((x1, x2, y))
for _ in range(M):
    x, y1, y2 = map(int, input().split())
    Xs.add(x)
    Ys.add(y1)
    Ys.add(y2)
    Hs.append((x, y1, y2))

Xs = list(Xs)
Ys = list(Ys)
Xs.sort()
Ys.sort()

def area(ix, iy):
    if ix % 2 == 0 or iy % 2 == 0:
        return 0
    ix = (ix-1) // 2
    iy = (iy-1) // 2

    wx = Xs[ix+1] - Xs[ix]
    wy = Ys[iy+1] - Ys[iy]
    return wx * wy

# True := can move to
W = 2*len(Xs)-1
H = 2*len(Ys)-1
Gs = [[True]*H for _ in range(W)]
for (x1, x2, y) in Vs:
    ix1 = Xs.index(x1)
    ix2 = Xs.index(x2)
    iy = Ys.index(y)
    for x in range(2*ix1, 2*ix2+1):
        Gs[x][2*iy] = False
for (x, y1, y2) in Hs:
    ix = Xs.index(x)
    iy1 = Ys.index(y1)
    iy2 = Ys.index(y2)
    for y in range(2*iy1, 2*iy2+1):
        Gs[2*ix][y] = False

sp = (2*Xs.index(0), 2*Ys.index(0))

# bfs
res = 0
queue = deque([sp])
visited = [[False]*H for _ in range(W)]
while queue:
    x, y = queue.popleft()
    if Gs[x][y] and (not visited[x][y]):
        res += area(x, y)
    else:
        continue

    visited[x][y] = True

    if 0 < x and x < W-1:
        queue.append((x-1, y)) 
        queue.append((x+1, y)) 
    else:
        print('INF')
        break
    if 0 < y and y < H-1:
        queue.append((x, y-1)) 
        queue.append((x, y+1)) 
    else:
        print('INF')
        break
else:
    print(res)
