def main():
    import sys
    input = lambda : sys.stdin.readline().rstrip()
    sys.setrecursionlimit(max(1000, 10**9))
    write = lambda x: sys.stdout.write(x+"\n")


    n,m = map(int, input().split())

    lx = [None] * n
    ly = [None] * m
    sx = set([-10**10, 0, 10**10])
    sy = set([-10**10, 0, 10**10])
    ix = 0
    iy = 0
    for i in range(n):
        t = tuple(map(int, input().split()))
        lx[i] = t
        sx.add(t[0])
        sx.add(t[1])
        sy.add(t[2])

    for i in range(m):
        t = tuple(map(int, input().split()))
        ly[i] = t
        sx.add(t[0])
        sy.add(t[1])
        sy.add(t[2])

    xs = list(sx)
    ys = list(sy)
    xs.sort(); ys.sort()

    wx = len(xs)*2
    wy = len(ys)*2
    bs = [[1]*wy for _ in range(wx)]
    import bisect
    for i, (x0, x1, y) in enumerate(lx):
        ix0 = bisect.bisect_left(xs, x0)*2
        ix1 = bisect.bisect_left(xs, x1)*2
        iy = bisect.bisect_left(ys, y)*2
        for ii in range(ix0+1, ix1, 2):
            bs[ii][iy] = -1
    for i, (x, y0, y1) in enumerate(ly):
        ix = bisect.bisect_left(xs, x)*2
        iy0 = bisect.bisect_left(ys, y0)*2
        iy1 = bisect.bisect_left(ys, y1)*2
        for ii in range(iy0+1, iy1, 2):
            bs[ix][ii] = -1

    xx = bisect.bisect_left(xs, 0)*2+1
    yy = bisect.bisect_left(ys, 0)*2+1
    s = [(xx,yy)]
    dx = [-1,0,1,0]
    dy = [0,-1,0,1]
    ans = 0
    end = False
    while s:
        ix,iy = s.pop()
        for x, y in zip(dx,dy):
            ixx = ix + x
            iyy = iy + y
            if bs[ixx][iyy]!=1:
                continue
            ixx += x
            iyy += y
            if bs[ixx][iyy]!=1:
                continue
            if ixx<0 or ixx>=wx-1 or iyy<0 or iyy>=wy-1:
                print("INF")
                s = []
                end = True
                break
            bs[ixx][iyy] = 2
            ans += (xs[ixx//2+1] - xs[ixx//2]) * (ys[iyy//2+1] - ys[iyy//2])
            s.append((ixx, iyy))

    if not end:
        print(ans)
main()