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