Solve question (1) with the condition that two goals goal1 and goal2 are given. If the number k (additional and last input) was never ever moved, the algorithm should find a path till goal1. If however anytime k was moved, the algorithm should find a path to goal2.