Here is the link to my submission - CodeChef: Practical coding for everyone
I ran the code in my code editor and inputted the given sample input in the question, then gave some inputs made by me and it worked perfectly. But it shows WA on the website…