
# q-expansion of newform 162.4.c.g, downloaded from the LMFDB on 24 June 2026.

# We generate the q-expansion using the Hecke eigenvalues a_p at the primes.
# Each a_p is given as a linear combination
# of the following basis for the coefficient ring.

def make_data():

    from sage.all import prod, floor, prime_powers, gcd, QQ, primes_first_n, next_prime, RR

    def discrete_log(elts, gens, mod):
        # algorithm 2.2, page 16 of https://arxiv.org/abs/0903.2785
        def table_gens(gens, mod):
            T = [1]
            n = len(gens)
            r = [None]*n
            s = [None]*n
            for i in range(n):
                beta = gens[i]
                r[i] = 1
                N = len(T)
                while beta not in T:
                    for Tj in T[:N]:
                        T.append((beta*Tj) % mod)
                    beta = (beta*gens[i]) % mod
                    r[i] += 1
                s[i] = T.index(beta)
            return T, r, s
        T, r, s = table_gens(gens, mod)
        n = len(gens)
        N = [ prod(r[:j]) for j in range(n) ]
        Z = lambda s: [ (floor(s/N[j]) % r[j]) for j in range(n)]
        return [Z(T.index(elt % mod)) for elt in elts]
    def extend_multiplicatively(an):
        for pp in prime_powers(len(an)-1):
            for k in range(1, (len(an) - 1)//pp + 1):
                if gcd(k, pp) == 1:
                    an[pp*k] = an[pp]*an[k]
    from sage.all import PolynomialRing, NumberField
    R = PolynomialRing(QQ, "x")
    f = R(poly_data)
    K = NumberField(f, "a")
    betas = [K.gens()[0]**i for i in range(len(poly_data))]
    convert_elt_to_field = lambda elt: sum(c*beta for c, beta in zip(elt, betas))
    # convert aps to K elements
    primes = primes_first_n(len(aps_data))
    good_primes = [p for p in primes if not p.divides(level)]
    aps = map(convert_elt_to_field, aps_data)
    if not hecke_ring_character_values:
        # trivial character
        char_values = dict(zip(good_primes, [1]*len(good_primes)))
    else:
        gens = [elt[0] for elt in hecke_ring_character_values]
        gens_values = [convert_elt_to_field(elt[1]) for elt in hecke_ring_character_values]
        char_values = dict([(
            p,prod(g**k for g, k in zip(gens_values, elt)))
            for p, elt in zip(good_primes, discrete_log(good_primes, gens, level))
            ])
    an_list_bound = next_prime(primes[-1])
    an = [0]*an_list_bound
    an[1] = 1
    
    from sage.all import PowerSeriesRing
    PS = PowerSeriesRing(K, "q")
    for p, ap in zip(primes, aps):
        if p.divides(level):
            euler_factor = [1, -ap]
        else:
            euler_factor = [1, -ap, p**(weight - 1) * char_values[p]]
        k = RR(an_list_bound).log(p).floor() + 1
        foo = (1/PS(euler_factor)).padded_list(k)
        for i in range(1, k):
            an[p**i] = foo[i]
    extend_multiplicatively(an)
    return PS(an)
level = 162
weight = 4
poly_data = [1, -1, 1]

# The basis for the coefficient ring is just the power basis
# in the root of the defining polynomial above.
hecke_ring_character_values = [[83, [0, -1]]]
aps_data = [[2, -2], [0, 0], [0, 3], [-29, 29], [-57, 57], [0, -20], [72, 0], [-106, 0], [0, 174], [-210, 210], [0, -47], [2, 0], [0, -6], [-218, 218], [474, -474], [-81, 0], [0, 84], [-56, 56], [0, 142], [-360, 0], [-1159, 0], [160, -160], [735, -735], [954, 0], [-191, 191], [-363, 363], [0, 628], [-675, 0], [1730, 0], [0, 1866], [1379, 0], [0, 579], [654, -654], [0, 3004], [0, 1803], [-2459, 2459], [0, 196], [-1564, 0], [0, 1974], [-2217, 2217], [2475, 0], [1568, 0], [1140, -1140], [0, -2045], [3735, 0], [1163, 0], [0, -2126], [2752, -2752], [-3972, 3972], [0, -4502], [-4842, 0], [0, -5334], [3994, -3994], [1008, 0], [0, -924], [1014, -1014], [2970, 0], [245, 0], [-4376, 4376], [240, -240], [0, 6838], [0, -5118], [-5560, 0], [0, 7662], [-3485, 3485], [-7059, 7059], [-9290, 9290], [0, 3814], [0, 1929], [6586, -6586], [-6042, 6042], [3762, 0], [7261, -7261], [0, -1640], [-7396, 0], [0, -4992], [-9453, 9453], [8588, 0], [0, -1716], [0, 9889], [0, 5556], [2104, -2104], [-7614, 0], [7805, 0], [5209, -5209], [4236, -4236], [16002, 0], [-7319, 7319], [9483, -9483], [0, -10793], [-2583, 0], [-1254, 1254], [17336, 0], [0, -15171], [0, -8930], [-15210, 0], [0, 19641], [-22428, 0], [-8152, 0], [-2860, 0], [9664, -9664], [-14859, 0], [0, 8193], [-16572, 16572], [0, 6244], [-14794, 0], [-26769, 26769], [3078, 0], [0, 1002], [20653, -20653], [0, -27128], [24518, 0], [0, -474], [1132, -1132], [6725, 0], [-21126, 21126], [0, -19460], [11664, 0], [0, -3345], [9393, -9393], [0, 1762], [-25517, 25517], [26898, -26898], [-23940, 0], [-23060, 23060], [14175, 0], [8692, -8692], [29556, 0], [36691, -36691], [0, 19798], [-21976, 0], [0, -13236], [0, 6325], [-3238, 0], [0, -40416], [0, 4759], [-27414, 0], [0, -6176], [0, 6879], [16902, 0], [24086, 0], [7854, -7854], [0, -5771], [17568, 0], [31322, 0], [41856, -41856], [-15662, 15662], [-39864, 39864], [0, 9160], [-5076, 0], [0, -14978], [22860, 0], [-32506, 0], [0, 35868], [33586, -33586], [-28902, 28902], [28271, 0], [19140, -19140], [31619, 0], [0, -20913], [17529, -17529], [53604, 0], [0, -11117], [27297, 0], [0, 25086], [-20982, 20982], [11477, 0], [-8588, 8588]]
