while true
  n,r = gets.split(" ").map{|i| i.to_i}
  break if (n==0 && r==0)
    
  field = []

  for i in 0..n-1
    x1,y1,x2,y2 = gets.split(" ").map{|j| j.to_i}
    for y in y1..y2-1
      for x in x1..x2-1
        field += [[x,y]]
      end
    end
  end
  puts field.uniq.size
  puts 2 if r == 2
end