n, m = map(int, input().split())
NS = []
X_num = set()
EW = []
Y_num = set()

INF = 10 ** 36

X_num.add(INF)
X_num.add(0)
X_num.add(-INF)
Y_num.add(INF)
Y_num.add(0)
Y_num.add(-INF)

cant_inc_x = [[0] * 3300 for i in range(3300)]
cant_dec_x = [[0] * 3300 for i in range(3300)]
cant_inc_y = [[0] * 3300 for i in range(3300)]
cant_dec_y = [[0] * 3300 for i in range(3300)]

for i in range(n):
    a, b, c = map(int, input().split())
    X_num.add(a)
    X_num.add(b)
    Y_num.add(c)
    NS.append((a,b,c))

for i in range(m):
    d, e, f = map(int, input().split())
    X_num.add(d)
    Y_num.add(e)
    Y_num.add(f)
    EW.append((d,e,f))

X_dict = {}
Y_dict = {}

X_num = sorted(list(X_num))
Y_num = sorted(list(Y_num))


for xp, x in enumerate(X_num):
    X_dict[x] = xp
    xp += 1

for yp, y in enumerate(Y_num):
    Y_dict[y] = yp
    yp += 1

#(a,b) (a,c)
for a, b, c in NS:
    a = X_dict[a]
    b = X_dict[b]
    c = Y_dict[c]
    cant_dec_y[a][c] += 1
    cant_dec_y[b][c] -= 1
    cant_inc_y[a][c-1] += 1
    cant_inc_y[b][c-1] -= 1
    

#(d,e) (d,f)
for d, e, f in EW:
    d = X_dict[d]
    e = Y_dict[e]
    f = Y_dict[f]
    cant_dec_x[d][e] += 1
    cant_dec_x[d][f] -= 1
    cant_inc_x[d-1][e] += 1
    cant_inc_x[d-1][f] -= 1

for i in range(3300):
    for j in range(3300):
        if(j):cant_dec_x[i][j] += cant_dec_x[i][j-1]
        if(j):cant_inc_x[i][j] += cant_inc_x[i][j-1]
        if(i):cant_dec_y[i][j] += cant_dec_y[i-1][j]
        if(i):cant_inc_y[i][j] += cant_inc_y[i-1][j]

from collections import deque
q = deque()
q.append((X_dict[0], Y_dict[0]))
done = [[False] * 3300 for _ in range(3300)]

ans = 0


while len(q) != 0:
    (nowx, nowy) = q.popleft()
    if nowx < 0 or nowy < 0 or nowx+1 >= len(X_num) or nowy+1 >= len(Y_num):
        continue
    if done[nowx][nowy]:continue
    done[nowx][nowy] = True
    ans += (X_num[nowx+1] - X_num[nowx]) * (Y_num[nowy+1] - Y_num[nowy])
    if cant_dec_x[nowx][nowy] == 0:q.append((nowx-1, nowy))
    if cant_dec_y[nowx][nowy] == 0:q.append((nowx, nowy-1))
    if cant_inc_x[nowx][nowy] == 0:q.append((nowx+1, nowy))
    if cant_inc_y[nowx][nowy] == 0:q.append((nowx, nowy+1))

if ans > INF:
    print("INF")
else:    
    print(ans)