import bisect
import os

import sys

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)]

# 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]

lines = []
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):
        lines.append((xi, xi, yi, 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):
        lines.append((xi, xi + 1, yi, yi))
lines = set(lines)

# (0, 0) を含む場所を適当に選ぶ
xi = bisect.bisect_right(X, 0) - 1
yi = bisect.bisect_right(Y, 0) - 1
s = 0
seen = {(xi, yi)}
stack = [(xi, yi)]
while stack and s < INF:
    xi, yi = stack.pop()
    s += (X[xi + 1] - X[xi]) * (Y[yi + 1] - Y[yi])
    # print(X[xi], X[xi + 1], Y[yi], Y[yi + 1], (X[xi + 1] - X[xi]) * (Y[yi + 1] - Y[yi]))
    for dx, dy, key in (
            (0, 1, (xi, xi + 1, yi + 1, yi + 1)),
            (1, 0, (xi + 1, xi + 1, yi, yi + 1)),
            (0, -1, (xi, xi + 1, yi, yi)),
            (-1, 0, (xi, xi, yi, yi + 1))):
        xj, yj = xi + dx, yi + dy
        if (xj, yj) in seen or key in lines:
            continue
        seen.add((xj, yj))
        stack.append((xj, yj))

if s < INF:
    print(s)
else:
    print('INF')
