Algorithm for path written (except the guards' corner position)