Your solution gives no output for the test input:
1 1
I don’t know if there are any other problems, yet.
Thanks for your help.
Can someone please point out my mistake in KPRIME https://www.codechef.com/viewsolution/47909493