Small Airport-Discrete Event Simulation

Could somebody explain me the first test case for the problem

I had implemented the code using heaps.But I don’t know what happens when p=0 and q=0?

Here is my implementation:

//