import itertools


def broadcast_lists(list_a, list_b):
    """Broadcast two lists.

    Similar behavior as ``gs.broadcast_arrays``, but for lists.
    """
    n_a = len(list_a)
    n_b = len(list_b)

    if n_a == n_b:
        return list_a, list_b

    if n_a == 1:
        return itertools.zip_longest(list_a, list_b, fillvalue=list_a[0])

    if n_b == 1:
        return itertools.zip_longest(list_a, list_b, fillvalue=list_b[0])

    raise Exception(f"Cannot broadcast lens {n_a} and {n_b}")