def get_exiting_var(Binv_A, Binv_b, entering_ind):
    """
    Get the exiting variable index using min-ratio test.
    In case of a tie, we use Bland's rule to select a variable.
    """
    min_ratio = float("inf")
    min_ind = None
    for i, rhs_val in enumerate(Binv_b):
        col_val = Binv_A[i, entering_ind]
        if col_val > 1e-9:
            ratio = rhs_val / col_val
            if ratio < min_ratio:
                min_ratio = ratio
                min_ind = i
    return min_ind