solve the bridge crossing problem