Hostel visit no output

sir it is showing no output for both the test cases .can u plzz tell why?? link:https://ide.codingblocks.com/s/119701

@khushi91200 In line number 13…in for loop change i<9 to i<q and then check. Also the constraints are large so use long long int.

now it is giving wrong answer for both test cases link:https://ide.codingblocks.com/s/119732

@khushi91200 https://ide.codingblocks.com/s/119758
I have made some changes. You were missing some cases.Check it out.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.