from itertools import chain
from bisect import bisect_left as bisect
from math import isfinite
import numpy as np

N,M = map(int,input().split())

hor = [tuple(map(int,input().split())) for _ in range(N)]
ver = [tuple(map(int,input().split())) for _ in range(M)]

X = sorted(set(chain((a for a,b,c in hor), (b for a,b,c in hor), (a for a,b,c in ver))))
X = tuple(chain((-float('inf'),),*zip(X,X),(float('inf'),)))

Y = sorted(set(chain((c for a,b,c in hor), (b for a,b,c in ver), (c for a,b,c in ver))))
Y = tuple(chain((-float('inf'),),*zip(Y,Y),(float('inf'),)))

grid = [[False]*(len(Y)-1) for _ in range(len(X)-1)]

for a,b,y in hor:
    ai,bi,yi = bisect(X,a),bisect(X,b),bisect(Y,y)
    for i in range(ai,bi+1):
        grid[i][yi] = True

for x,a,b in ver:
    xi,ai,bi = bisect(X,x),bisect(Y,a),bisect(Y,b)
    for i in range(ai,bi+1):
        grid[xi][i] = True



def dothething():
    x0,y0 = bisect(X,0), bisect(Y,0)
    stack = [(x0,y0)]
    grid[x0][y0] = True
    area = 0
    while stack:
        i,j = stack.pop()
        area += (X[i+1]-X[i])*(Y[j+1]-Y[j])
        if not isfinite(area):
            return None
        for di,dj in ((0,1),(0,-1),(1,0),(-1,0)):
            ii,jj = i+di,j+dj
            if not grid[ii][jj]:
                grid[ii][jj] = True
                stack.append((i+di, j+dj))
    return area

res = dothething()
print('INF' if res is None else res)
