import random


def draw_random_indices(
        mutable_sonic_content_indices: list[int], n_tone_row_instances_by_group: list[int]
) -> tuple[int, int]:
    """
    Draw index of melodic lines group and index of tone row instance from it.

    :param mutable_sonic_content_indices:
        indices of groups such that their sonic content can be transformed
    :param n_tone_row_instances_by_group:
        list where number of tone row instances in the group is stored for each group of
        melodic lines sharing the same series (in terms of vertical distribution of series pitches)
    :return:
        index of group and index of tone row instance from it
    """
    group_index = random.choice(mutable_sonic_content_indices)
    n_instances = n_tone_row_instances_by_group[group_index]
    instance_index = random.randrange(0, n_instances)
    return group_index, instance_index