CODECHEF: WALK

http://www.codechef.com/MARCH14/problems/WALK