CODECHEF: Run with Rotation

http://www.codechef.com/SEPT14/problems/ROTATION