Please help me in resolving my doubt

accorfing to me there is printing mistake for any test case like if we dont find the node then we have to print zero and i am not getting how to do that ?

you need to print answer in sorted order.