while true
  n,r = gets.split(" ").map{|s| s.to_i}
  break if (n==0 && r==0)
  
  a = Array.new(n){gets.split(" ").map{|s| s.to_i}}

  b = a.transpose
  xmax = b[2].max
  ymax = b[3].max

  f = Array.new(ymax){|y| Array.new(xmax){|x|
           for i in 0..n-1
             x1,y1,x2,y2 = a[i]
             inc = (y1<=y && y<y2 && x1<=x && x<x2)
             break if inc
           end
           inc ? 1 : 0
        }
      }

  puts f.map{|arr| (arr.to_s.split("0")-[""]).map{|str| str.size}}.inject(:+)
  puts (f+f.transpose).map{|arr| (arr.to_s.split("0")-[""]).size}.inject(:+)*2 if r==2
end