N, M = map(int, input().split())
INF = 10**20 + 1

X = [0]
Y = [0]
X_line = []
Y_line = [] 

for i in range(N):
  A, B, C = map(int, input().split())
  if A > B:
    A, B = B, A
  X.append(A)
  X.append(B)
  Y.append(C)
  X_line.append((A,B,C)) 
  
for j in range(M):
  D, E, F = map(int, input().split())
  if E > F:
    E, F = F, E
  X.append(D)
  Y.append(E)
  Y.append(F)
  Y_line.append((D,E,F)) 

X.sort()
Y.sort()
X = list(set(X))
Y = list(set(Y))
X.sort()
Y.sort()

X_dict = {}
Y_dict = {}

i = 0
for x in X:
  X_dict[x] = 2 * i + 1
  i += 1
j = 0
for y in Y:
  Y_dict[y] = 2 * j + 1
  j += 1

G = []
for i in range(2*len(X)+1):
  G.append([])
  for j in range(2*len(Y)+1):
    if i % 2 == 1 or j % 2 == 1:
      G[i].append(0) #奇数の箇所が面積0の要素を表す
    else:
      if 1 <= i//2 < len(X) and 1 <= j//2 < len(Y):
        G[i].append( (X[i//2]-X[i//2-1])*(Y[j//2]-Y[j//2-1]) )
      else:
        G[i].append(INF)#各ノードが持つ面積を記録、最外殻は面積無限大 
        
for (A, B, C) in X_line:
  xd = X_dict[A]
  yd = Y_dict[C] 
  #print(xd, yd, X_dict[B], len(X), len(Y))
  while xd <= X_dict[B]:
    #print(xd, yd, X_dict[B], len(X), len(Y))
    G[xd][yd] = -1 #壁は面積-1で区別
    xd += 1
    
for (D, E, F) in Y_line:
  xd = X_dict[D]
  yd = Y_dict[E] 
  while yd <= Y_dict[F]:
    G[xd][yd] = -1 #壁は面積-1で区別
    yd += 1
    
#探索により面積導出
ans = 0
que = []
if G[X_dict[0]][Y_dict[0]] >= 0:
  #print(X_dict[0], Y_dict[0])
  que.append((X_dict[0],Y_dict[0]))

    
if ans >= INF:
  print("INF")
else:
  print(ans)
  

    