def travel_by_ferry(state, me, x, y, pos):
    data = get_travel_data(state,pos)
    own = taxi_rate(data['dist'])
    if state.money[me] >= own and \
        data['dist'] <= ferry_max_distance and \
        is_island_to(not_island_to[data['from']], data['to']):
        if pos == len(places) - 2:
            return [('get_souvenir', me, data['from']),
                    ('buy_ferry_ticket', me, own),
                    ('go_by_ferry', me, data['from'], data['to'])]
        else:
            return [('get_souvenir', me, data['from']),
                    ('buy_ferry_ticket', me, own),
                    ('go_by_ferry', me, data['from'], data['to']),
                    ('travel', me, places[0], places[-1], pos + 1)]
    return False
def travel_by_taxi(state, me, x, y, pos):
    data = get_travel_data(state,pos)
    own = taxi_rate(data['dist'])
    if state.money[me] >= own and \
        data['dist'] <= taxi_max_distane and \
        not is_island_to(not_island_to[data['from']], data['to']):
        if pos == len(places) - 2:
            return [('get_souvenir', me, data['from']),
                    ('call_taxi', me, data['from']),
                    ('ride_taxi', me, data['from'], data['to']),
                    ('pay_taxi_driver', me, own)]
        else:
            return [('get_souvenir', me, data['from']),
                    ('call_taxi', me, data['from']),
                    ('ride_taxi', me, data['from'], data['to']),
                    ('pay_taxi_driver', me, own),
                    ('travel', me, places[0], places[-1], pos + 1)]
    return False