import sys

sys.setrecursionlimit(10 ** 9)

n, m = map(int, input().split())

x = set([0])
y = set([0])
h, v = [], []
for _ in range(n):
    a, b, c = map(int, input().split())
    y.add(a)
    y.add(b)
    x.add(c)
    v.append((a, b, c))

for _ in range(m):
    d, e, f = map(int, input().split())
    y.add(d)
    x.add(e)
    x.add(f)
    h.append((d, e, f))

x, y = sorted(x), sorted(y)
lx, ly = len(x)*2, len(y)*2
dx, dy = {v:i*2 for i,v in enumerate(x)}, {v:i*2 for i, v in enumerate(y)}

m = [[0 for _ in range(lx)] for _ in range(ly)]

for a, b, c in v:
    xx = dx[c]
    for yy in range(dy[a], dy[b]+1):
        m[yy][xx] = 1

for d, e, f in h:
    yy = dy[d]
    for xx in range(dx[e], dx[f]+1):
        m[yy][xx] = 1

ans = 0
px = [1, 0, -1, 0]
py = [0, 1, 0, -1]

def _s(xx, yy):
    global ans
    m[yy][xx] = 1
    if xx == 0 or xx == lx-2 or yy == 0 or yy == ly-2:
        print('INF')
        exit(0)
    for i in range(4):
        xxx, yyy = xx+px[i], yy+py[i]
        if m[yyy][xxx] == 1:
            continue
        if xxx % 2 != 0 and yyy % 2 != 0:
            x1, y1 = xxx // 2, yyy // 2
            x2, y2 = x1+1, y1+1
            ans = ans + (x[x2]-x[x1]) * (y[y2]-y[y1])
        _s(xxx, yyy)


_s(dx[0], dy[0])
print(ans)
