Solution for random test of queue