def inf
  puts "INF"
  exit
end

n,m = gets.strip.split.map(&:to_i)
x = []
y = []
vxxy = []
n.times { |i|
  a,b,c = gets.strip.split.map(&:to_i)
  vxxy.append [a,b,c]
  x.append a
  x.append b
  y.append c
}
hxyy = []
m.times {
  a,b,c = gets.strip.split.map(&:to_i)
  hxyy.append [a,b,c]
  x.append a
  y.append b
  y.append c
}
x.append 0
y.append 0
x.uniq!
x.sort!
y.uniq!
y.sort!

mp = Array.new(x.size * 2 + 1){Array.new(y.size * 2 + 1)}
mpc = Array.new(x.size + 1){Array.new(y.size + 1)}
vxxy.each do |a,b,c|
  l = x.bsearch_index { |e| e >= a}
  m = x.bsearch_index { |e| e >= b}
  n = y.bsearch_index { |e| e >= c}
  (l*2+1).upto(m*2+1) {|i| mp[i][n*2+1] = true}
end 
hxyy.each do |a,b,c|
  l = x.bsearch_index { |e| e >= a}
  m = y.bsearch_index { |e| e >= b}
  n = y.bsearch_index { |e| e >= c}
  (m*2+1).upto(n*2+1) {|i| mp[l*2+1][i] = true}
end
ans = 0
xx = x.bsearch_index { |e| e >= 0}
yy = y.bsearch_index { |e| e >= 0}
q = [[xx,yy]]
mpc[xx][yy]=true
until q.empty?
  xx,yy = q.shift
  inf if xx==0 || xx==x.size || yy==0 || yy==y.size
  x2 = xx * 2
  y2 = yy * 2
  ans += (x[xx]-x[xx-1])*(y[yy]-y[yy-1])
  if !mp[x2+1][y2] && !mpc[xx+1][yy] then q.append [xx+1,yy]; mpc[xx+1][yy]=true end
  if !mp[x2-1][y2] && !mpc[xx-1][yy] then q.append [xx-1,yy]; mpc[xx-1][yy]=true end
  if !mp[x2][y2-1] && !mpc[xx][yy-1] then q.append [xx,yy-1]; mpc[xx][yy-1]=true end
  if !mp[x2][y2+1] && !mpc[xx][yy+1] then q.append [xx,yy+1]; mpc[xx][yy+1]=true end
end
p ans
