BESSIE COME HOME

Could anyone solve the problem “BESSIE COMES HOME” from USACO successfully?
Does anyone feel that there is a mistake in the seventh test case?
(My first 6 answers are correct. However, in the seventh test case, my answer is coming “A 127”, but according to them, the answer is “R 111”.

REPLY SOON.
THANKS IN ADVANCE

YES, I HAVE GOT THE FLAWLESS SOLUTION!!

IT WAS MY MISTAKE.