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}}
  
  xmax,ymax =100
  
  begin
    f = Array.new(100){|y| Array.new(100){|x|
        for i in 0..n-1
          x1,y1,x2,y2 = a[i]
          (xmax = x2 ; raise) if xmax<x2
          (ymax = y2 ; raise) if ymax<y2
          inc = (y1<=y && y<y2 && x1<=x && x<x2)
          break if inc
        end
        inc ? 1 : 0
      }
    }
  rescue
    f = Array.new(ymax){|y| Array.new(xmax){|x|
        for i in 0..n-1
          x1,y1,x2,y2 = a[i]
          (xmax = x2 ; raise) if xmax<x2
          (ymax = y2 ; raise) if ymax<y2
          inc = (y1<=y && y<y2 && x1<=x && x<x2)
          break if inc
        end
        inc ? 1 : 0
      }
    }
  end

  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