Solve SRM 637, Div 2, Problem PathGameDiv2