getting wa SPOJ AMBLE

https://www.spoj.com/problems/AMBLE/ https://ideone.com/A4tpoW
I am taking the forward path element before the current place and reverse path element