
from collections import deque
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
n,m = map(int,input().split())
xl = set([0])
yl = set([0])
nl = []
ml = []
for i in range(n):
    a,b,c = map(int,input().split())
    xl |= set([a,b])
    yl.add(c)
    nl.append([a,b,c])
for i in range(m):
    c,a,b = map(int,input().split())
    yl |= set([a,b])
    xl.add(c)
    ml.append([a,b,c])
def compress(L):
    L2 = list(set(L))
    L2.sort()
    C = {v : k for k, v in enumerate(L2)}
    return L2, C
xl ,dx = compress(xl)
yl, dy = compress(yl)

h = len(xl)*2
w = len(yl)*2
d = [[0]*w for i in range(h)]

for a,b,c in nl:
    s = dx[a]*2
    g = dx[b]*2
    t = dy[c]*2
    
    for x in range(s,g+1):
        d[x][t] = -1

for a,b,c in ml:
    s = dy[a]*2
    g = dy[b]*2
    t = dx[c]*2
    
    for y in range(s,g+1):
        d[t][y] = -1


def bfs(x,y):
    ans = 0
    dtx = [1,-1,0,0]
    dty = [0,0,1,-1]

    sx = dx[x]*2
    sy = dy[y]*2
    q = deque([])
    q.append((sx,sy))
    d[sx][sy] = 1
    while q:
        bx,by = q.popleft()

        for i in range(4):
            nx = bx+dtx[i]
            ny = by+dty[i]

            if 0 <= nx < h and 0 <= ny < w and d[nx][ny] == 0:
                if nx == 0 or ny == 0 or nx == h-1 or ny == w-1:
                    print("INF")
                    exit()
                d[nx][ny] = 1
                if nx%2 != 0 and ny%2 != 0:
                    ax = xl[nx//2+1]-xl[nx//2]
                    ay = yl[ny//2+1]-yl[ny//2]
                    ans += ax*ay
                q.append((nx,ny))
    print(ans)

bfs(0,0)

