I think I got it. Passed first 8 test cases.