import math
import numpy as np
import queue
from collections import deque
import heapq
import time
start = time.time()
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:
    xs.append(i[0])
    xs.append(i[1])
    ys.append(i[2])
for i in yok:
    xs.append(i[0])
    ys.append(i[1])
    ys.append(i[2])
xs = list(set(xs))
ys = list(set(ys))
dcx = dict()
dcy = dict()
for i, xi in enumerate(xs):
    dcx[xi] = i
for i, yi in enumerate(ys):
    dcy[yi] = i

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

sx = [xs[i]-xs[i-1] for i in range(1,lx)]
sy = [ys[i]-ys[i-1] for i in range(1,ly)]

#座標の圧縮
cps = [[0 for i in range(ly*2)] for j in range(lx*2)]
for i in tat:
    yi = dcy[i[2]]
    for j in range(dcx[i[0]],dcx[i[1]]):
        cps[2*j+1][yi*2] = -1
for i in yok:
    xi = dcx[i[0]]
    for j in range(dcy[i[1]],dcy[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] = sx[i]*sy[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)
