i tried it with the sample input it is coming out 100% correct . i dont know what is with the code.
hello @ashishxmathew
first read m and then n