
# q-expansion of newform 392.3.g.m, downloaded from the LMFDB on 23 April 2024.

# 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, ZZ
    R = PolynomialRing(QQ, "x")
    f = R(poly_data)
    K = NumberField(f, "a")
    betas = [K([c/ZZ(den) for c in num]) for num, den in basis_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 = 392
weight = 3
poly_data = [256, -64, -32, -8, 24, -2, -2, -1, 1]

# The entries in the following list give a basis for the
# coefficient ring in terms of a root of the defining polynomial above.
# Each line consists of the coefficients of the numerator, and a denominator.
basis_data  = [[[1, 0, 0, 0, 0, 0, 0, 0], 1], [[0, 16, 4, -2, 0, 1, 1, 0], 16], [[128, 0, -24, -16, 10, 6, -3, -1], 64], [[-64, -32, -8, 24, -2, -2, -1, 1], 64], [[128, 64, -88, -16, 10, 6, -3, -1], 64], [[-128, 160, 56, 24, -2, -2, -1, 1], 64], [[192, -64, 24, 8, 26, -6, 1, -1], 64], [[-32, -16, 16, 8, -2, -2, 1, -1], 32]]

hecke_ring_character_values = [[295, [-1, 0, 0, 0, 0, 0, 0, 0]], [197, [-1, 0, 0, 0, 0, 0, 0, 0]], [297, [1, 0, 0, 0, 0, 0, 0, 0]]]
aps_data = [[0, 0, 0, -1, 0, 0, 0, 0], [1, 0, -1, -1, 0, 0, 0, 0], [-1, -1, 0, -1, -1, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [-4, 0, 0, -2, 0, 1, -1, -1], [-1, -1, 0, -1, 1, 0, -2, 2], [10, 0, 4, 4, 0, 0, 0, 0], [-7, 0, -1, -1, 0, 0, 0, 0], [1, 2, 1, -3, 3, -2, -1, 1], [-2, 2, 4, 2, -6, 2, -2, 2], [0, 6, 6, 0, -6, 0, 0, 0], [-2, -10, -8, -6, 2, -2, 6, -6], [-16, 0, 2, 14, -2, -4, 2, 2], [0, 0, 4, -6, 4, 1, 3, 3], [-6, -2, 4, -14, -4, -4, -2, 2], [-4, -4, 0, 0, -4, 2, -2, 2], [-13, 0, 13, -7, 8, 2, 6, 6], [-3, -11, -8, -3, -3, 0, 8, -8], [38, 0, 6, 16, -4, -1, -3, -3], [6, 10, 4, 6, -8, 0, 10, -10], [14, 0, 0, -8, 0, 4, -4, -4], [14, 10, -4, 22, 16, 4, -2, 2], [-9, 0, 1, -27, 8, 6, 2, 2], [64, 0, -6, -2, 2, -4, 6, 6], [-8, 0, -6, 30, -10, -8, -2, -2], [-5, 19, 24, -13, -23, -4, -2, 2], [10, 16, 6, 10, -2, 0, 6, -6], [86, 0, -2, -8, 0, 3, -3, -3], [10, 26, 16, 14, -10, 2, 2, -2], [17, 0, 19, 45, -5, -8, 3, 3], [-15, -26, -11, -11, -1, 2, -5, 5], [59, 0, -3, 25, -8, -6, -2, -2], [16, 0, 6, -6, 6, 0, 6, 6], [93, 0, -21, -45, 8, 4, 4, 4], [-4, 8, 12, -32, -4, -14, 2, -2], [-29, -22, 7, -25, -27, 2, -11, 11], [-9, -25, -16, -41, 21, -16, 2, -2], [24, 0, 20, -22, 8, 13, -5, -5], [-16, 0, 16, 8, -36, 12, -8, 8], [3, -13, -16, 19, 21, 8, -10, 10], [26, 0, -14, 20, -12, -5, -7, -7], [-11, 13, 24, -3, -15, 4, -24, 24], [-6, -26, -20, 2, -16, 4, 26, -26], [25, 0, -37, -27, -5, 0, -5, -5], [-12, -28, -16, 8, 4, 10, -10, 10], [-2, -24, -22, -50, 10, -24, 34, -34], [-62, 0, 10, 28, -4, -5, 1, 1], [38, 44, 6, 62, 18, 12, 2, -2], [29, 0, 11, 35, -8, -4, -4, -4], [-11, 5, 16, -59, -13, -24, 10, -10], [56, 0, -50, -78, 6, 8, -2, -2], [19, 34, 15, 15, -11, -2, 17, -17], [-96, 0, 18, 54, -10, -8, -2, -2], [131, 0, 37, -31, 8, 26, -18, -18], [98, 0, 4, 44, -20, 0, -20, -20], [-34, -66, -32, -66, -12, -16, 26, -26], [35, 19, -16, 35, 33, 0, 18, -18], [-14, -48, -34, -54, 10, -20, 30, -30], [-20, -24, -4, -96, 8, -38, 14, -14], [130, 0, 32, 64, 0, -16, 16, 16], [-43, 0, -53, -13, -16, -4, -12, -12], [-5, 35, 40, 19, -39, 12, -18, 18], [-85, 0, 29, 89, -16, -14, -2, -2], [-10, -18, -8, 54, 4, 32, -38, 38], [88, 0, -22, 6, -26, 12, -38, -38], [-36, -52, -16, -24, -48, 6, 22, -22], [48, 0, 4, 26, 12, -23, 35, 35], [131, 0, -3, -29, -11, 24, -35, -35], [76, 0, 8, 70, -20, -11, -9, -9], [31, 47, 16, -9, 55, -20, -20, 20], [-64, 0, 90, 38, 10, 16, -6, -6], [-43, -6, 37, -79, -41, -18, -21, 21], [-26, -52, -26, -114, 10, -44, 34, -34], [64, 44, -20, 100, 52, 18, 14, -14], [80, 0, 36, 90, -28, 1, -29, -29], [34, 114, 80, 10, -32, -12, -2, 2], [70, 134, 64, 50, 30, -10, -14, 14], [-29, -13, 16, -5, -29, 12, -28, 28], [-21, 0, 117, 27, 29, 16, 13, 13], [-110, 0, -84, -188, 16, 36, -20, -20], [-195, 0, -13, 59, -40, 4, -44, -44], [-16, -20, -4, 20, -24, 18, -6, 6], [41, 50, 9, 125, 27, 42, -37, 37], [-66, 0, -56, -128, 36, 0, 36, 36], [32, 22, -10, 168, 14, 68, -40, 40], [142, 0, 78, 88, 4, -9, 13, 13], [-184, 0, 46, -94, 38, 32, 6, 6], [-15, 0, -93, -67, 11, -24, 35, 35], [23, 87, 64, 159, -57, 68, -52, 52], [-34, 18, 52, -58, -40, -12, -34, 34], [-55, 0, 47, 47, 16, -16, 32, 32], [-40, 50, 90, -40, -138, 0, 8, -8], [17, -2, -19, 29, -17, 6, 47, -47], [450, 0, -22, -20, -4, 3, -7, -7], [-138, 0, -130, -24, -40, -13, -27, -27], [-36, 18, 54, -44, -114, -4, 28, -28], [55, 135, 80, 95, -5, 20, -40, 40], [290, 0, -4, 4, 16, -20, 36, 36], [159, 0, 17, -155, 32, 54, -22, -22], [-20, -56, -36, 24, 80, 22, -86, 86], [-332, 0, -136, -42, -16, -31, 15, 15], [-8, -120, -112, -28, 44, -10, 70, -70], [-89, 0, -55, -131, 16, 22, -6, -6], [19, 0, -83, -173, 29, 16, 13, 13], [-208, 0, -124, -262, 20, 49, -29, -29], [-16, 0, 42, -58, 58, -8, 66, 66], [565, 0, 35, 91, 8, -36, 44, 44], [-562, 0, 48, -144, 64, 32, 32, 32], [102, 118, 16, 86, 52, -8, 42, -42], [224, 0, -70, -2, -14, -20, 6, 6], [28, 44, 16, 76, 64, 24, -76, 76], [-26, 42, 68, -94, -62, -34, 2, -2], [547, 0, 45, 3, -3, 24, -27, -27], [89, 0, 71, 103, -24, 8, -32, -32], [54, 78, 24, 6, -28, -24, 82, -82], [-113, 0, -55, -25, -31, 16, -47, -47], [-297, 0, -103, -19, -32, -10, -22, -22], [-10, 12, 22, 38, -26, 24, -30, 30], [-10, 2, 12, 106, -46, 58, -34, 34], [-172, 0, 232, 230, -8, 9, -17, -17], [51, 67, 16, 107, 37, 28, -30, 30], [162, 0, 0, 0, 40, -40, 80, 80], [-75, -251, -176, -83, 25, -4, 80, -80], [-402, 0, 86, 96, -16, 11, -27, -27], [35, 0, 53, -159, 32, 74, -42, -42], [-66, -54, 12, -110, -114, -22, 58, -58], [-182, -158, 24, -346, -126, -82, 2, -2], [26, -102, -128, -46, 88, -36, 102, -102], [124, 28, -96, 84, 188, -20, 52, -52], [-163, -115, 48, -211, -159, -24, -28, 28], [720, 0, -4, -30, 8, 5, 3, 3], [-55, -138, -83, 53, -25, 54, -1, 1], [53, 110, 57, 121, 35, 34, -73, 73], [78, -62, -140, 282, 138, 102, -22, 22], [-68, 0, -66, 18, -22, -20, -2, -2], [-388, 0, 14, 90, -38, 0, -38, -38], [-113, -233, -120, -49, 7, 32, -32, 32], [473, 0, -33, 287, -88, -72, -16, -16], [-17, 127, 144, -65, -175, -24, 38, -38], [149, 0, -201, -215, 31, -24, 55, 55], [829, 0, -29, -101, 32, 4, 28, 28], [164, 176, 12, 360, 76, 98, -22, 22], [114, 70, -44, 210, 120, 48, -10, 10], [-278, 0, 122, -52, 88, -1, 89, 89], [49, -95, -144, 81, 77, 16, 100, -100], [-14, -80, -66, 82, -98, 48, 102, -102], [-79, 89, 168, -79, -173, 0, -74, 74], [-254, 0, 44, 116, -24, -12, -12, -12], [-361, 0, -15, -187, 48, 38, 10, 10], [-74, 70, 144, 14, -244, 44, -18, 18], [26, 58, 32, -50, 26, -38, 6, -6], [-588, 0, 78, -30, 54, 0, 54, 54], [-738, 0, 134, 320, -72, -21, -51, -51], [-76, -8, 68, -52, 32, 12, -188, 188], [-130, 0, -146, -8, -12, -57, 45, 45], [163, 150, -13, 383, 129, 110, -63, 63], [118, 234, 116, 134, 16, 8, -22, 22], [278, 0, -208, -344, 20, 48, -28, -28], [110, 0, -80, 312, -88, -108, 20, 20], [-51, -75, -24, -171, -25, -60, 58, -58], [-140, 0, -56, -218, 72, 9, 63, 63], [-874, 0, -44, 76, -28, -32, 4, 4], [49, 202, 153, 29, 43, -10, -137, 137], [-589, 0, -67, 233, -48, -102, 54, 54], [-184, 0, 158, -62, 62, 48, 14, 14], [122, 12, -110, -22, 226, -72, 78, -78], [50, 26, -24, 218, -20, 84, 10, -10], [83, 171, 88, 211, 55, 64, -124, 124]]
