Giving wrong answer

my code passes the sample test case correctly shows wrong answer in test cases
https://ide.codingblocks.com/s/233577

@mayank10

  1. Give space between numbers.
  2. Your code is not working for number with more than 1 digits. Consider this testcase
    2
    200 1
    Your code is giving “12 21” as ans but ans should be “1 200 200 1”. please check

error is removed but getting tle in two test cases https://ide.codingblocks.com/s/234278