while true
  n,r = gets.split(" ").map{|s| s.to_i}

  cov = [[]]
  
  for i in 1..n
    x1,y1,x2,y2 = gets.split(" ").map{|s| s.to_i}
    for y in y1..y2-1
      cov[y] = (cov[y]+(x1..x2-1).to_a).uniq.sort rescue (x1..x2-1).to_a
    end
  end
 
  puts cov.compact.flatten.size

  puts cov.size if r == 2
end    