It is not passing the test cases?

hello @Ak07
your code is correct but it is not printing output in required order.
to print it in required order call statement in line number 15 before line no 13.