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}}.transpose
  
  xmax,ymax = a[2].max,a[3].max

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

  puts f.size
  puts ymax if r==2
end