import math
import numpy as np
import queue
from collections import deque
import heapq
drc = [(-1,0),(1,0),(0,-1),(0,1)]

n, m = map(int,input().split())
tat = [list(map(int,input().split())) for i in range(n)]
yok = [list(map(int,input().split())) for i in range(m)]
xs = []
ys = []
for i in tat:
    if not i[0] in xs:
        xs.append(i[0])
    if not i[1] in xs:
        xs.append(i[1])
    if not i[2] in ys:
        ys.append(i[2])
for i in yok:
    if not i[0] in xs:
        xs.append(i[0])
    if not i[1] in ys:
        ys.append(i[1])
    if not i[2] in ys:
        ys.append(i[2])

xs.sort()
ys.sort()
lx = len(xs)
ly = len(ys)

#座標の圧縮
cps = [[0 for i in range(ly*2)] for j in range(lx*2)]
for i in tat:
    yi = ys.index(i[2])
    for j in range(xs.index(i[0]),xs.index(i[1])):
        cps[2*j+1][yi*2] = -1
for i in yok:
    xi = xs.index(i[0])
    for j in range(ys.index(i[1]),ys.index(i[2])):
        cps[xi*2][2*j+1] = -1
for i in range(lx-1):
    for j in range(ly-1):
        cps[2*i+1][2*j+1] = (xs[i+1]-xs[i])*(ys[j+1]-ys[j])
for i in range(lx):
    cps[i][-1] = -2
for j in range(ly):
    cps[-1][j] = -2


x0 = -1
y0 = -1
for i,x in enumerate(xs):
    if x > 0:
        x0 = i-1
        break
for i,y in enumerate(ys):
    if y > 0:
        y0 = i-1
        break

if x0 < 0 or y0 < 0:
    print("INF")
    exit()

ans = cps[x0*2+1][y0*2+1]
'''
cps[x0*2+1][y0*2+1] = -1
q = queue.Queue()
q.put((x0*2+1,y0*2+1))
while not q.empty():
    x,y = q.get()
    for dx,dy in drc:
        if cps[x+dx][y+dy] == 0:
            if cps[x+dx*2][y+dy*2] > 0:
                q.put((x+dx*2,y+dy*2))
                ans += cps[x+dx*2][y+dy*2]
                cps[x+dx*2][y+dy*2] = -1
            elif cps[x+dx*2][y+dy*2] == -2:
                print("INF")
                exit()
'''
print(ans)
