while true
  n,r = gets.split(" ").map{|s| s.to_i}
  break if n==0&&r==0
  
  cov = [[]]
  
  n.times{
    x1,y1,x2,y2 = gets.split(" ").map{|s| s.to_i}
    for y in y1..y2-1      
      (cov[y] += (x1..x2-1).to_a) rescue (cov[y] = (x1..x2-1).to_a)
      cov[y].uniq
    end
  }
  
  puts(cov.compact.flatten.size)
  puts(123) if r == 2

end