def best_margin_dict_(regions, r_ids):
    """
    For given list of ids selects region with max margin
    :param regions:
    :param r_ids:
    :return: (margin_value, region_id)
    """
    best_margin = -1
    best_margin_id = -1
    for r_id in r_ids:
        if regions[r_id]['margin'] > best_margin:
            best_margin = regions[r_id]['margin']
            best_margin_id = r_id

    return best_margin, best_margin_id