while true
  n,r = gets.split(" ").map{|i| i.to_i}
  break if (n==0 && r==0)
    
  s = 0
  xi,yi,xf,yf = [],[],[],[]
  for i in 0..n-1
    xi[i],yi[i],xf[i],yf[i] = gets.split(" ").map{|j| j.to_i}
  end
  xmax,ymax = xf.max,yf.max

  field = Array.new(ymax){Array.new(xmax)}
  
  for i in 0..n-1
    for y in yi[i]..yf[i]-1
      for x in xi[i]..xf[i]-1
        (field[y][x] = 1 ; s+=1) if field[y][x].nil?
      end
    end
  end
  puts s
  
  if r == 2
    l = 0
    for y in 0..ymax-1
      for x in 0..xmax-1
        if field[y][x] == 1
          l+=1 if x==0||field[y][x-1].nil?
          l+=1 if x==xmax-1||field[y][x+1].nil? 
          l+=1 if y==0||field[y-1][x].nil?
          l+=1 if y==ymax-1||field[y+1][x].nil?
        end
      end
    end
    puts l
  end
end