Bridge Crossing solution in Prolog