from functools import reduce
import operator


def get_nth_product(n, elements):
    """
    Get the nth product of a list without calculating any other products.
    The order is the same as itertools.product(x).

    Args:
        n: The number product to generate
        elements: The lists to generate the product from

    Returns:
        The nth product of elements
    """
    length = len(elements)
    demoninators = [
        reduce(operator.mul, (map(len, elements[x + 1 :])), 1) for x in range(length)
    ]
    return [
        elements[x][(n // demoninators[x]) % len(elements[x])] for x in range(length)
    ]