My code is passing given test case but it shows wrong output on submission

smart keypad problem