N, M = gets.split.map(&:to_i)
ABCs = N.times.map{gets.split.map(&:to_i)}
DEFs = M.times.map{gets.split.map(&:to_i)}

y1, y2 = ABCs.select{|a, b, _| a*b < 0}.map{_1[2]}.sort_by(&:abs).take(2).sort
x1, x2 = DEFs.select{|_, e, f| e*f < 0}.map{_1[0]}.sort_by(&:abs).take(2).sort
(puts 'INF'; exit) if y2.nil? || x2.nil?
is = []
ABCs.product(DEFs).map do |(a, b, c), (d, e, f)|
  is << [d, c] if (a - d)*(b - d) <= 0 && (e - c)*(f - c) <= 0
end.compact
ans = (x2 - x1)*(y2 - y1)
is.sort.chunk(&:first).map{|y, a| [y, a.map(&:last)]}.each_cons(2) do |(_, a1), (_, a2)|
  b = a1 & a2
  ans += b.minmax.inject(:-) unless b.empty?
end
puts ans