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}}
  

  f = Array.new(1000){|y| Array.new(1000){|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.size
  puts f.size if r==2
end