while true
  n,r = gets.split(" ").map{|s| s.to_i}
  break if (n==0 && r==0)
  
  x1s,y1s,x2s,y2s = Array.new(n){gets.split(" ").map{|s| s.to_i}}.transpose
  
  xmax = x2s.max
  ymax = y2s.max

  s = 0

  if r == 1
    a = []
    for i in 0..n-1
      for y in y1s[i]..y2s[i]-1
        for x in x1s[i]..x2s[i]-1
          s += 1 if a[y][x].nil?
          a[y][x] = 1
        end
      end
    end
    puts s
  end

  if  r == 2
    f = Array.new(ymax){|y|
          Array.new(xmax){|x|
            cov = false
            for i in 0..n-1
              cov = (x1s[i]<=x && x<x2s[i] && y1s[i]<=y && y<y2s[i])
              break if cov
            end
            s += 1 if cov
            cov ? 1 : 0
          }
        }
     puts s
     puts (f+f.transpose).inject(0){|sum,arr| sum += (arr.join.split("0")-[""]).size}*2
  end
end