from bisect import *
n, m = map(int, input().split())
A, B, C = zip(*(map(int, input().split()) for _ in range(n)))
D, E, F = zip(*(map(int, input().split()) for _ in range(m)))
X = sorted(set(C + E + F))
Y = sorted(set(A + B + D))
H = len(Y)-1
W = len(X)-1
def TX(i):
    return bisect(X, i)-1
def TY(i):
    return bisect(Y, i)-1
U = [[True]*W for _ in range(H+1)]
for d, e, f in zip(D, E, F):
    d, e, f = TY(d), TX(e), TX(f)
    for i in range(e, f):
        U[d][i] = False 
L = [[True]*(W+1) for _ in range(H)]
for a ,b, c in zip(A, B, C):
    a, b, c = TY(a), TY(b), TX(c)
    for i in range(a, b):
        L[i][c] = False
i = TY(0)
j = TX(0)
s = [(i,j)]
v = set()
r = 0
while s:
    i, j = s.pop()
    if (i,j) in v:
        continue
    v.add((i,j))
    if not (0<=i<H and 0<=j<W):
        print('INF')
        break
    r += (Y[i+1]-Y[i])*(X[j+1]-X[j])
    if U[i][j]:
        s.append((i-1,j))
    if U[i+1][j]:
        s.append((i+1,j))
    if L[i][j]:
        s.append((i,j-1))
    if L[i][j+1]:
        s.append((i,j+1))
else:
    print(r)