# Original solution
#!usr/bin/env python3
import sys
import bisect
from collections import deque
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LIR(n):
    return [LI() for i in range(n)]

M = 3*10**9+1
M2 = (M-10**9)**2
def solve():
    n,m = LI()
    p = LIR(n)
    q = LIR(m)
    fx = set([-M,0,M])
    fy = set([-M,0,M])
    for i in range(n):
        p[i][0] <<= 1
        p[i][1] <<= 1
        p[i][2] <<= 1
        a,b,c = p[i]
        fy.add(a)
        fy.add(b)
        fy.add(b+1)
        fx.add(c)
        fx.add(c+1)

    for i in range(m):
        q[i][0] <<= 1
        q[i][1] <<= 1
        q[i][2] <<= 1
        d,e,f = q[i]
        fy.add(d)
        fy.add(d+1)
        fx.add(e)
        fx.add(f)
        fx.add(f+1)
    fy = list(fy)
    fx = list(fx)
    fy.sort()
    fx.sort()
    h = len(fy)+1
    w = len(fx)+1
    s = [0]*h*w
    for a,b,c in p:
        ai = bisect.bisect_left(fy,a)
        bi = bisect.bisect_left(fy,b)
        ci = bisect.bisect_left(fx,c)
        ka = ai*w
        kb = (bi+1)*w
        s[ka+ci] += 1
        s[kb+ci] -= 1
        s[ka+ci+1] -= 1
        s[kb+ci+1] += 1
    for d,e,f in q:
        di = bisect.bisect_left(fy,d)
        ei = bisect.bisect_left(fx,e)
        fi = bisect.bisect_left(fx,f)
        kd = di*w
        kdd = kd+w
        s[kd+ei] += 1
        s[kd+fi+1] -= 1
        s[kdd+ei] -= 1
        s[kdd+fi+1] += 1
    for i in range(h):
        for j in range(len(fx)):
            ind = i*w+j
            s[ind+1] += s[ind]
    for i in range(len(fy)):
        for j in range(w):
            ind = i*w+j
            s[ind+w] += s[ind]
    sx = bisect.bisect_left(fx,0)
    sy = bisect.bisect_left(fy,0)
    nh,nw = len(fy)-1,len(fx)-1
    for i in range(nw-1):
        fx[i+1] >>= 1
        fx[i] = fx[i+1]-fx[i]
    for i in range(nh-1):
        fy[i+1] >>= 1
        fy[i] = fy[i+1]-fy[i]
    ans = fx[sx]*fy[sy]
    q = deque()
    q.append((sy,sx))
    f = [1]*nh*nw
    f[sy*nw+sx] = 0
    d = [(1,0),(-1,0),(0,1),(0,-1)]
    while q:
        y,x = q.popleft()
        i = y*nw+x
        for dy,dx in d:
            ny,nx = y+dy,x+dx
            if 0 <= ny < nh and 0 <= nx < nw:
                ind = i+dy*nw+dx
                if f[ind] and not s[ind+(ny<<1)]:
                    if ny < 1 or nx < 1 or ny+1 >= nh or nx+1 >= nw:
                        print("INF")
                        return
                    k = fx[nx]*fy[ny]
                    ans += k
                    f[ind] = 0
                    q.append((ny,nx))
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


# Optimized solution
#!usr/bin/env python3
import sys
import bisect
from collections import deque
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LIR(n):
    return [LI() for i in range(n)]

M = 3*10**9+1
M2 = (M-10**9)**2
def solve():
    n,m = LI()
    p = LIR(n)
    q = LIR(m)
    fx = set([-M,0,M])
    fy = set([-M,0,M])
    for i in range(n):
        p[i][0] <<= 1
        p[i][1] <<= 1
        p[i][2] <<= 1
        a,b,c = p[i]
        fy.add(a)
        fy.add(b)
        fy.add(b+1)
        fx.add(c)
        fx.add(c+1)

    for i in range(m):
        q[i][0] <<= 1
        q[i][1] <<= 1
        q[i][2] <<= 1
        d,e,f = q[i]
        fy.add(d)
        fy.add(d+1)
        fx.add(e)
        fx.add(f)
        fx.add(f+1)
    fy = list(fy)
    fx = list(fx)
    fy.sort()
    fx.sort()
    h = len(fy)+1
    w = len(fx)+1
    s = [0]*h*w
    for a,b,c in p:
        ai = bisect.bisect_left(fy,a)
        bi = bisect.bisect_left(fy,b)
        ci = bisect.bisect_left(fx,c)
        ka = ai*w
        kb = (bi+1)*w
        s[ka+ci] += 1
        s[kb+ci] -= 1
        s[ka+ci+1] -= 1
        s[kb+ci+1] += 1
    for d,e,f in q:
        di = bisect.bisect_left(fy,d)
        ei = bisect.bisect_left(fx,e)
        fi = bisect.bisect_left(fx,f)
        kd = di*w
        kdd = kd+w
        s[kd+ei] += 1
        s[kd+fi+1] -= 1
        s[kdd+ei] -= 1
        s[kdd+fi+1] += 1
    for i in range(h):
        for j in range(len(fx)):
            ind = i*w+j
            s[ind+1] += s[ind]
    for i in range(len(fy)):
        for j in range(w):
            ind = i*w+j
            s[ind+w] += s[ind]
    sx = bisect.bisect_left(fx,0)
    sy = bisect.bisect_left(fy,0)
    nh,nw = len(fy)-1,len(fx)-1
    for i in range(nw-1):
        fx[i+1] >>= 1
        fx[i] = fx[i+1]-fx[i]
    for i in range(nh-1):
        fy[i+1] >>= 1
        fy[i] = fy[i+1]-fy[i]
    ans = fx[sx]*fy[sy]
    q = deque()
    q.append((sy,sx))
    f = [1]*nh*nw
    f[sy*nw+sx] = 0
    d = [(1,0),(-1,0),(0,1),(0,-1)]
    while q:
        y,x = q.popleft()
        for dy,dx in d:
            ny,nx = y+dy,x+dx
            if 0 <= ny < nh and 0 <= nx < nw:
                ind = ny*nw+nx
                if f[ind] and not s[ind+(ny<<1)]:
                    if ny < 1 or nx < 1 or ny+1 >= nh or nx+1 >= nw:
                        print("INF")
                        return
                    ans += fx[nx]*fy[ny]
                    f[ind] = 0
                    q.append((ny,nx))
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()