import numpy as np
from bisect import *
n, m = map(int, input().split())
a, b, c = zip(*(map(int, input().split()) for _ in range(n)))
d, e, f = zip(*(map(int, input().split()) for _ in range(m)))
x = sorted(set(c + e + f))
y = sorted(set(a + b + d))
h = len(y)-1
w = len(x)-1
def tx(i):
    return bisect(x, i)-1
def ty(i):
    return bisect(y, i)-1
u = np.ones((h+1, w))
for d, e, f in zip(d, e, f):
    d, e, f = ty(d), tx(e), tx(f)
    u[d, e:f] = false
l = np.ones((h, w+1))
for a ,b, c in zip(a, b, c):
    a, b, c = ty(a), ty(b), tx(c)
    l[a:b, c] = false
s = np.outer(np.diff(y), np.diff(x)) 
i = bisect(y, 0)-1
j = bisect(x, 0)-1
s = [(i,j)]
v = set()
r = 0
while s:
    i, j = s.pop()
    if (i,j) in v:
        continue
    v.add((i,j))
    if not (0<=i<h and 0<=j<w):
        print('inf')
        break
    r += s[i][j]
    if u[i][j]:
        s.append((i-1,j))
    if u[i+1][j]:
        s.append((i+1,j))
    if l[i][j]:
        s.append((i,j-1))
    if l[i][j+1]:
        s.append((i,j+1))
else:
    print(r)