Class assignment question

I wrote the code for this question but my code is not able to pass any of the test cases , I don’t know why. Output format is not clear. It is different in question and in sample output . So I tried with both but none of them got accepted.
My code-https://ide.codingblocks.com/s/364778

hello @akshat_jain

image

here it should be test case number in place of n.