# from collections import OrderedDict, deque
import bisect

N, M = map(int, input().split())
xs = set()
ys = set()

ABCs = []
for _ in range(N):
    a, b, c = map(int, input().split())
    ABCs.append([a, b, c])
    xs.add(a)
    xs.add(b)
    ys.add(c)
DEFs = []
for _ in range(M):
    d, e, f = map(int, input().split())
    DEFs.append([d, e, f])
    xs.add(d)
    ys.add(e)
    ys.add(f)

xs = list(xs)
xs.sort()
x_diff = [x1 - x0 for x1, x0 in zip(xs[1:], xs)]
ys = list(ys)
ys.sort()
y_diff = [y1 - y0 for y1, y0 in zip(ys[1:], ys)]

Q = [(bisect.bisect_left(xs, 0), bisect.bisect_left(ys, 0))]
xs = dict(zip(xs, range(len(xs))))
ys = dict(zip(ys, range(len(ys))))


ABC_saku = [[True for _ in range(len(ys))] for _ in range(len(xs) - 1)]
for a, b, c in ABCs:
    a = xs[a]
    b = xs[b]
    c = ys[c]
    for ab in range(a, b):
        ABC_saku[ab][c] = False
DEFs_saku = [[True for _ in range(len(ys) - 1)] for _ in range(len(xs))]
for d, e, f in DEFs:
    d = xs[d]
    e = ys[e]
    f = ys[f]
    for ef in range(e, f):
        DEFs_saku[d][ef] = False

# Q = deque([(xs[0], ys[0])])
visited = set(Q)
ans = 0


def check_add(new_point):
    if new_point not in visited:
        Q.append(new_point)
        visited.add(new_point)


if Q[0][0] < len(x_diff) and Q[0][1] < len(y_diff):
    while Q:
        # x, y = Q.popleft()
        x, y = Q.pop()
        ans += x_diff[x] * y_diff[y]
        # y--
        if ABC_saku[x][y]:
            if y - 1 >= 0:
                new_point = (x, y - 1)
                check_add(new_point)
            else:
                ans = "INF"
                break
        if ABC_saku[x][y + 1]:
            if y + 1 < len(y_diff):
                new_point = (x, y + 1)
                check_add(new_point)
            else:
                ans = "INF"
                break
        if DEFs_saku[x][y]:
            if x - 1 >= 0:
                new_point = (x - 1, y)
                check_add(new_point)
            else:
                ans = "INF"
                break
        if DEFs_saku[x + 1][y]:
            if x + 1 < len(x_diff):
                new_point = (x + 1, y)
                check_add(new_point)
            else:
                ans = "INF"
                break
else:
    ans = "INF"


print(ans)
pass
