#!/usr/bin/python3
from collections import defaultdict

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

xti = {}
yti = {}
xti[0] = -1
yti[0] = -1

lvs = []
for i in range(n):
    (a, b, c) = map(int, input().split())
    yti[a] = -1
    yti[b] = -1   
    xti[c] = -1
    lvs.append((a, b, c))

lhs = []
for i in range(m):
    (d, e, f) = map(int, input().split())
    yti[d] = -1
    xti[e] = -1   
    xti[f] = -1
    lhs.append((d, e, f))

xs = sorted(xti.keys())
for (i, x) in enumerate(xs):
    xti[x] = i

ys = sorted(yti.keys())
for (i, y) in enumerate(ys):
    yti[y] = i

fi = [ [ 0 for x in range(len(xs) * 2) ] for y in range(len(ys) * 2) ]

for (a, b, c) in lvs:
    x = xti[c] * 2
    for y in range(yti[a] * 2, yti[b] * 2 + 1):
        fi[y][x] = -1

for (d, e, f) in lhs:
    y = yti[d] * 2
    for x in range(xti[e] * 2, xti[f] * 2 + 1):
        fi[y][x] = -1

q = [(xti[0] * 2, yti[0] * 2)]

while q:
    (cx, cy) = q.pop(-1)
    if cx < 0 or cx >= len(xs) * 2 or cy < 0 or cy >= len(ys) * 2:
        continue
    
    if fi[cy][cx] != 0:
        continue

    fi[cy][cx] = 1
    q.append((cx, cy - 1))
    q.append((cx + 1, cy))
    q.append((cx, cy + 1))
    q.append((cx - 1, cy))

#for xl in fi:
#    print(xl)

s = 0
for y in range(len(ys) * 2):
    for x in range(len(xs) * 2):
        if fi[y][x] <= 0:
            continue
        if x == 0 or x == len(xs) * 2 - 1 or y == 0 or y == len(ys) * 2 - 1:
            print('INF')
            exit()

        s += (xs[(x + 1) // 2] - xs[x // 2]) * (ys[(y + 1) // 2] - ys[y // 2])

print(s)
