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