Code not bieng accepted

A few guidelines first:

  1. Always format your code before posting. Link
  2. Tips to get faster response to your problem. Link.

Now, try running your solution locally on given test case. ie.

1
9

You are not taking 9 as input and 0 is being printed for this test. How can it proceed further ?