# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
read = sys.stdin.read
from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import product#accumulate, combinations, product
import bisect# lower_bound etc
import numpy as np
#from copy import deepcopy
from collections import deque
def run():
    N,M, *A2F = map(int, read().split())
    A = A2F[0:3*N:3]
    B = A2F[1:3*N+1:3]
    C = A2F[2:3*N+2:3]
    D = A2F[3*N::3]
    E = A2F[3*N+1::3]
    F = A2F[3*N+2::3]

    x_list, y_list = sorted(list(set(A+B+D))), sorted(list(set(C+E+F)))
    max_sq = (x_list[-1]-x_list[0]) * (y_list[-1] - y_list[0])
    #print(x_list)
    tmp1 = np.array([x_list[0]]+x_list)
    tmp2 = np.array(x_list+[x_list[-1]])
    x_grid = tmp2 - tmp1
    #print(x_grid)
    tmp1 = np.array([y_list[0]] + y_list)
    tmp2 = np.array(y_list + [y_list[-1]])
    y_grid = tmp2 - tmp1
    #print(y_list)
    #print(y_grid)
    grid = np.dot(x_grid.reshape(-1,1), y_grid.reshape(1,-1))
    seen = np.zeros_like(grid, dtype=np.bool)
    walls = np.zeros_like(grid, dtype=np.int32)
    for a,b,c in zip(A,B,C):
        a_i = bisect.bisect_left(x_list, a)
        b_i = bisect.bisect_left(x_list, b)
        c_i = bisect.bisect_left(y_list, c)
        walls[a_i+1:b_i+1, c_i] += 1 << 1
        walls[a_i+1:b_i+1, c_i+1] += 1 << 3
    for d,e,f in zip(D,E,F):
        d_i = bisect.bisect_left(x_list, d)
        e_i = bisect.bisect_left(y_list, e)
        f_i = bisect.bisect_left(y_list, f)
        walls[d_i,e_i+1:f_i+1] += 1 << 0
        walls[d_i+1,e_i+1:f_i+1] += 1 << 2

    start_x = bisect.bisect_left(x_list, 0)
    start_y = bisect.bisect_left(y_list, 0)

    queue = deque([])
    queue.append((start_x, start_y))
    seen[start_x, start_y] = True
    max_x = len(x_list)
    max_y = len(y_list)
    ret = grid[start_x, start_y]
    while queue:
        x, y = queue.popleft()
        for w_i, i,j in ((1,0,1), (3,0,-1), (0,1,0),(2,-1,0)):
            if x+i > max_x or y+j > max_y:
                continue
            if walls[x, y] & 1 << w_i:
                continue
            if not seen[x+i, y+j]:
                queue.append((x+i, y+j))
                seen[x+i,y+j] = True
                ret += grid[x+i, y+j]

    if ret == max_sq:
        print('INF')
    else:
        print(ret)
if __name__ == "__main__":
    run()
