while true
  n,r = gets.split(" ").map{|i| i.to_i}
  break if (n==0 && r==0)
    
  s = 0
  rectangles = Array.new(n){gets.split(" ").map{|j| j.to_i}}
  xmax, ymax = rectangles.zip[3..4].map{|arr| arr.max}
  field = Array.new(ymax){Array.new(xmax)}
  
  for i in 0..n-1
    x1,y1,x2,y2 = rectangles[i]
    for x in x1..x2-1
      for y in y1..y2-1
        (field[y][x] = 1 ; s+=1) if field[y][x].nil?
      end
    end
  end
  puts s
  
  if r == 2
    l = 0
    for x in 0..xmax-1
      for y in 0..ymax-1
        if field[y][x] == 1
          x==0 ? l+=1 : (l+=1 if field[y][x-1]==0)
          x==xmax-1 ? l+=1 : (l+=1 if field[y][x+1]==0) 
          y==0 ? l+=1 : (l+=1 if field[y-1][x]==0)
          y==ymax-1 ? l+=1 : (l+=1 if field[y+1][x]==0)
        end
      end
    end
    puts l
  end
end