import bisect
import os
import sys
import numpy as np
if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, M = list(map(int, sys.stdin.buffer.readline().split()))
ABX = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]
YEF = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]

cdef long long a, b, x
cdef int l, r, xi, yi, xj, yj, dx, dy, xk, yk
cdef long long s;
cdef list X, Y, stack
cdef int[:, :] v_lines, h_lines, seen, lines

# X, Y を列挙して四角をいっぱい作る

X = []
Y = []

for a, b, x in ABX:
    X.append(x)
    Y.append(a)
    Y.append(b)
for y, e, f in YEF:
    X.append(e)
    X.append(f)
    Y.append(y)

X = [-INF] + list(sorted(set(X))) + [INF, INF]
Y = [-INF] + list(sorted(set(Y))) + [INF, INF]

v_lines = np.zeros((len(X), len(Y)), dtype=np.int32)
h_lines = np.zeros((len(X), len(Y)), dtype=np.int32)
for a, b, x in ABX:
    l = bisect.bisect_left(Y, min(a, b))
    r = bisect.bisect_left(Y, max(a, b))
    xi = bisect.bisect_left(X, x)
    for yi in range(l, r):
        v_lines[xi][yi] = 1
for y, e, f in YEF:
    l = bisect.bisect_left(X, min(e, f))
    r = bisect.bisect_left(X, max(e, f))
    yi = bisect.bisect_left(Y, y)
    for xi in range(l, r):
        h_lines[xi][yi] = 1

# (0, 0) を含む場所を適当に選ぶ
xi = bisect.bisect_right(X, 0) - 1
yi = bisect.bisect_right(Y, 0) - 1
s = 0
seen = np.zeros((len(X), len(Y)), dtype=np.int32)
seen[xi][yi] = 1
stack = [(xi, yi)]
try:
    while stack and s < INF:
        xi, yi = stack.pop()
        s += (X[xi + 1] - X[xi]) * (Y[yi + 1] - Y[yi])
        for dx, dy, lines, xk, yk in (
                (0, 1, h_lines, xi, yi + 1),
                (1, 0, v_lines, xi + 1, yi),
                (0, -1, h_lines, xi, yi),
                (-1, 0, v_lines, xi, yi)):
            xj, yj = xi + dx, yi + dy
            if seen[xj][yj] or lines[xk][yk]:
                continue

            seen[xj][yj] = 1
            stack.append((xj, yj))
    print(int(s))
except:
    print('INF')
