output_description: If the area of the region the cow can reach is infinite, print `INF`;
  otherwise, print an integer representing the area in \mathrm{cm^2}.
  
  (Under the constraints, it can be proved that the area of the region is always
  an integer if it is not infinite.)
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
      A_1 B_1 C_1
      :
      A_N B_N C_N
      D_1 E_1 F_1
      :
      D_M E_M F_M
attempt: import bisect
  import os
  
  import sys
  
  if os.getenv("LOCAL"):
      sys.stdin = open("_in.txt", "r")
  
  sys.setrecursionlimit(10**9)
  INF = float("inf")
  IINF = 10**18
  MOD = 10**9 + 7
  # MOD = 998244353
  
  
  N, M = list(map(int, sys.stdin.buffer.readline().split()))
  ABX = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]
  YEF = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(M)]
  
  # X, Y を列挙して四角をいっぱい作る
  X = []
  Y = []
  
  for a, b, x in ABX:
      X.append(x)
      Y.append(a)
      Y.append(b)
  for y, e, f in YEF:
      X.append(e)
      X.append(f)
      Y.append(y)
  
  X = [-INF] + list(sorted(set(X))) + [INF, INF]
  Y = [-INF] + list(sorted(set(Y))) + [INF, INF]
  
  lines = []
  for a, b, x in ABX:
      l = bisect.bisect_left(Y, min(a, b))
      r = bisect.bisect_left(Y, max(a, b))
      xi = bisect.bisect_left(X, x)
      for yi in range(l, r):
          lines.append((xi, xi, yi, yi + 1))
  for y, e, f in YEF:
      l = bisect.bisect_left(X, min(e, f))
      r = bisect.bisect_left(X, max(e, f))
      yi = bisect.bisect_left(Y, y)
      for xi in range(l, r):
          lines.append((xi, xi + 1, yi, yi))
  lines = set(lines)
  
  # (0, 0) を含む場所を適当に選ぶ
  xi = bisect.bisect_left(X, 0)
  yi = bisect.bisect_left(Y, 0)
  s = 0
  seen = {(xi, yi)}
  stack = [(xi, yi)]
  while stack and s < INF:
      xi, yi = stack.pop()
      s += (X[xi + 1] - X[xi]) * (Y[yi + 1] - Y[yi])
      # print(X[xi], X[xi + 1], Y[yi], Y[yi + 1], (X[xi + 1] - X[xi]) * (Y[yi + 1] - Y[yi]))
      for dx, dy in ((0, 1), (1, 0), (0, -1), (-1, 0)):
          xj, yj = xi + dx, yi + dy
          if (xj, yj) in seen:
              continue
          if dx == 1:
              key = (xi + 1, xi + 1, yi, yi + 1)
              blocked = key in lines
          elif dx == -1:
              key = (xi, xi, yi, yi + 1)
              blocked = key in lines
          elif dy == 1:
              key = (xi, xi + 1, yi + 1, yi + 1)
              blocked = key in lines
          elif dy == -1:
              key = (xi, xi + 1, yi, yi)
              blocked = key in lines
          if blocked:
              continue
          seen.add((xj, yj))
          stack.append((xj, yj))
  
  if s < INF:
      print(s)
  else:
      print("INF")
  
problem_description: Statement
  
  There is a grass field that stretches infinitely.
  
  In this field, there is a negligibly small cow. Let (x, y) denote the point
  that is x\ \mathrm{cm} south and y\ \mathrm{cm} east of the point where the
  cow stands now. The cow itself is standing at (0, 0).
  
  There are also N north-south lines and M east-west lines drawn on the field.
  The i-th north-south line is the segment connecting the points (A_i, C_i) and
  (B_i, C_i), and the j-th east-west line is the segment connecting the points
  (D_j, E_j) and (D_j, F_j).
  
  What is the area of the region the cow can reach when it can move around as
  long as it does not cross the segments (including the endpoints)? If this area
  is infinite, print `INF` instead.
samples: [{"input": "5 6\n    1 2 0\n    0 1 1\n    0 2 2\n    -3 4 -1\n    -2 6 3\n    1 0 1\n    0 1 2\n    2 0 2\n    -1 -4 5\n    3 -2 4\n    1 2 4", "output": "13\n    \n\nThe area of the region the cow can reach is 13\\ \\mathrm{cm^2}.\n\n![Sample 1](https://img.atcoder.jp/abc168/education.png)\n\n* * *"}, {"input": "6 1\n    -3 -1 -2\n    -3 -1 1\n    -2 -1 2\n    1 4 -2\n    1 4 -1\n    1 4 1\n    3 1 4", "output": "INF\n    \n\nThe area of the region the cow can reach is infinite."}]