from typing import Set


def get_top_x_genes_in_overlap(genes: list, overlap_list: list, topx: int) -> Set[str]:
    """Select a certain number of genes from an ordered list which are also in a given overlap(second list of genes)

    Parameters
    ----------
    genes : list
        list of (genes, stats) from which to take the top x genes from
    overlap_list : list
        list of genes
    topx : int
        number of desired genes in resulting list

    Returns
    -------
        list of genes of length (topx) that are also present in the overlap list
    """
    index = 0
    top_genes = set()
    while len(top_genes) < topx:
        gene, _ = genes[index]
        if gene in overlap_list:
            top_genes.add(gene)
        index += 1
    return top_genes