Item allocation algorithm