def select_max(actions, rewards, priorites):
    """
    Return action with max rewards, if there are
    many optimal actions, chose the one with highest
    priorites

    Args:
        actions(list): actions list
        rewards(list): rewards list
        priorites(dict):  map(action -> priority)

    Returns:
        best: best action with max rewards and highest priority
        reward: max reward
    """
    act_reward_prio = zip(actions, zip(rewards, priorites))
    best_choice = max(act_reward_prio, key=lambda x: x[1])
    return best_choice[0], best_choice[1][0]