import sys
from bisect import bisect_left

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

INF = 10**9 + 1

N, M = map(int, readline().split())
m = map(int, read().split())
A, B, C = zip(*zip(m, m, m))

D = A[N:]
E = B[N:]
F = C[N:]
A = A[:N]
B = B[:N]
C = C[:N]

X = sorted(set(A + B + D + (0, -INF, INF)))
Y = sorted(set(C + E + F + (0, -INF, INF)))
DX = [y - x for x, y in zip(X, X[1:])]
DY = [y - x for x, y in zip(Y, Y[1:])]

A = [bisect_left(X, x) for x in A]
B = [bisect_left(X, x) for x in B]
D = [bisect_left(X, x) for x in D]
C = [bisect_left(Y, x) for x in C]
E = [bisect_left(Y, x) for x in E]
F = [bisect_left(Y, x) for x in F]

H, W = len(X), len(Y)
N = H * W

ng = [[] for _ in range(N)]
for a, b, c in zip(A, B, C):
    for x in range(a, b):
        v = x * W + c
        ng[v].append(v - 1)
        if c != 0:
            ng[v - 1].append(v)
for d, e, f in zip(D, E, F):
    for y in range(e, f):
        v = d * W + y
        ng[v].append(v - W)
        if d != 0:
            ng[v - W].append(v)

x0, y0 = bisect_left(X, 0), bisect_left(Y, 0)
v0 = x0 * W + y0

visited = [0] * N
visited[v0] = 1
stack = [v0]
answer = DX[x0] * DY[y0]
while stack:
    v = stack.pop()
    ngv = ng[v]
    for dv in (-W, W, 1, -1):
        w = v + dv
        if w in ngv:
            continue
        x, y = divmod(w, W)
        if x in (0, H - 1) or y in (0, W - 1):
            print('INF')
            exit()
        elif visited[w]:
            continue
        else:
            answer += DX[x] * DY[y]
            stack.append(w)
            visited[w] = 1

print(answer)