
# q-expansion of newform 490.4.c.f, 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 = 490
weight = 4
poly_data = [60840000, 0, 33016000, 0, 5908496, 0, 405460, 0, 12748, 0, 185, 0, 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, 0, 0, 0, 0], 1], [[31, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], 1], [[167652000, 0, 40381408, 0, 1082536, 0, -32112, 0, -1331, 0, -11, 0], 529200], [[-12402000, 0, -5385040, 0, -725074, 0, -33981, 0, -631, 0, -4, 0], 44100], [[0, -326805600, 0, -124631048, 0, -12654320, 0, -511584, 0, -8765, 0, -53], 22932000], [[40345344000, 5032389600, 13584773280, 1578737104, 1229242560, 136581760, 45611280, 4984182, 737490, 80395, 4290, 469], 137592000], [[-40345344000, 5032389600, -13584773280, 1578737104, -1229242560, 136581760, -45611280, 4984182, -737490, 80395, -4290, 469], 137592000], [[0, 349737600, 0, 124631048, 0, 12654320, 0, 511584, 0, 8765, 0, 53], 11466000], [[0, 1474639200, 0, 324703332, 0, 5166700, 0, -510039, 0, -16335, 0, -128], 11466000], [[1575194400, 688632480, 1331831488, 259382640, 274726816, 37724400, 14793948, 1842210, 292864, 34995, 1924, 225], 13759200], [[1575194400, -688632480, 1331831488, -259382640, 274726816, -37724400, 14793948, -1842210, 292864, -34995, 1924, -225], 13759200], [[0, -2546759200, 0, -821150696, 0, -67921560, 0, -2341348, 0, -35885, 0, -201], 7644000]]

hecke_ring_character_values = [[197, [-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], [101, [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]]
aps_data = [[0, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0], [1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [5, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, -3, -2, -2, 4, -2, 2, -2, 1], [0, 0, 0, 0, -5, 0, 0, -8, -3, 1, -1, -2], [-17, 1, 2, -2, 0, 1, -1, 0, 0, 2, 2, 0], [0, 0, 0, 0, -2, 2, 2, -11, -2, 2, -2, -3], [-22, 3, -6, -2, 0, -11, 11, 0, 0, -3, -3, 0], [54, 4, 1, -7, 0, -4, 4, 0, 0, 3, 3, 0], [0, 0, 0, 0, 6, 4, 4, 18, -1, 7, -7, 5], [33, 0, 7, 12, 0, 6, -6, 0, 0, -3, -3, 0], [0, 0, 0, 0, 25, 15, 15, -5, 4, -1, 1, 4], [0, 0, 0, 0, -35, 3, 3, -91, 4, -4, 4, -9], [0, 0, 0, 0, 37, -1, -1, 28, -2, 10, -10, -7], [-104, -26, 11, 21, 0, 6, -6, 0, 0, 3, 3, 0], [42, 1, 9, 26, 0, -11, 11, 0, 0, 2, 2, 0], [0, 0, 0, 0, -12, 11, 11, -118, -1, 14, -14, 6], [170, 6, 11, -51, 0, -5, 5, 0, 0, -2, -2, 0], [0, 0, 0, 0, -5, -6, -6, 128, 15, -15, 15, -4], [142, -4, 9, -7, 0, 6, -6, 0, 0, -13, -13, 0], [0, 0, 0, 0, -90, 10, 10, 94, 19, 15, -15, 8], [-502, -5, -3, -19, 0, -17, 17, 0, 0, 13, 13, 0], [0, 0, 0, 0, 98, -10, -10, -244, -2, 12, -12, 8], [136, 5, -4, -88, 0, 34, -34, 0, 0, 1, 1, 0], [0, 0, 0, 0, -9, 48, 48, 100, -10, -13, 13, -30], [0, 0, 0, 0, 78, -25, -25, 32, 15, 14, -14, -12], [446, 21, -13, -22, 0, -33, 33, 0, 0, -2, -2, 0], [0, 0, 0, 0, -83, 7, 7, -192, 9, 9, -9, 28], [0, 0, 0, 0, 167, -8, -8, 293, 10, -13, 13, 11], [173, 15, -19, 69, 0, -28, 28, 0, 0, 12, 12, 0], [0, 0, 0, 0, 152, 55, 55, 92, -18, -20, 20, -22], [-16, -12, 46, 58, 0, 110, -110, 0, 0, 28, 28, 0], [666, -23, -35, 72, 0, -43, 43, 0, 0, -6, -6, 0], [-134, -40, -49, 11, 0, 10, -10, 0, 0, -17, -17, 0], [0, 0, 0, 0, 14, -20, -20, -538, -47, 1, -1, -29], [0, 0, 0, 0, -125, -58, -58, 693, -15, -19, 19, -26], [0, 0, 0, 0, 99, -58, -58, -48, -45, -11, 11, -37], [0, 0, 0, 0, -54, -34, -34, 158, -55, 33, -33, 31], [441, 67, -26, -54, 0, -73, 73, 0, 0, 38, 38, 0], [-1068, 69, -44, -48, 0, -1, 1, 0, 0, 41, 41, 0], [300, -30, 38, -64, 0, -37, 37, 0, 0, 51, 51, 0], [0, 0, 0, 0, -378, 15, 15, -700, -74, 40, -40, 60], [0, 0, 0, 0, 56, 131, 131, 82, 45, -43, 43, -55], [-1102, 40, 66, -20, 0, -99, 99, 0, 0, -1, -1, 0], [657, 85, -76, -10, 0, -62, 62, 0, 0, -1, -1, 0], [0, 0, 0, 0, -127, -211, -211, 1139, -51, -8, 8, -20], [0, 0, 0, 0, -365, 140, 140, -895, 151, 9, -9, 12], [-1290, 12, -60, 34, 0, 19, -19, 0, 0, -30, -30, 0], [0, 0, 0, 0, -377, 224, 224, 1456, 67, -101, 101, 16], [-612, -36, -113, -139, 0, -53, 53, 0, 0, 18, 18, 0], [1145, -93, -109, 7, 0, -32, 32, 0, 0, -67, -67, 0], [311, -137, 62, 48, 0, 120, -120, 0, 0, 39, 39, 0], [0, 0, 0, 0, -492, -25, -25, -116, -16, -46, 46, -132], [0, 0, 0, 0, 137, 2, 2, -1140, -24, -139, 139, -114], [-1586, -51, -11, 180, 0, 117, -117, 0, 0, -84, -84, 0], [-432, -6, 135, 31, 0, -44, 44, 0, 0, 1, 1, 0], [0, 0, 0, 0, 417, -146, -146, 1114, -5, -3, 3, -138], [-247, -117, 159, 325, 0, 33, -33, 0, 0, 65, 65, 0], [0, 0, 0, 0, -53, 40, 40, 3071, -37, 15, -15, -48], [0, 0, 0, 0, -288, 153, 153, 678, -9, -19, 19, -237], [0, 0, 0, 0, 402, -226, -226, 8, -129, 25, -25, -72], [-238, 120, 93, 301, 0, 36, -36, 0, 0, 65, 65, 0], [0, 0, 0, 0, 182, -75, -75, 1332, 82, 78, -78, -76], [0, 0, 0, 0, 429, 120, 120, -654, -181, 73, -73, 82], [83, -107, 82, 546, 0, 549, -549, 0, 0, -24, -24, 0], [0, 0, 0, 0, 319, -215, -215, 812, 167, 87, -87, 168], [0, 0, 0, 0, -288, -171, -171, 1106, -47, 52, -52, 176], [3346, -113, -184, -36, 0, -97, 97, 0, 0, -31, -31, 0], [0, 0, 0, 0, -997, -78, -78, 2080, -101, 43, -43, -100], [4, 14, 9, -175, 0, 322, -322, 0, 0, -21, -21, 0], [0, 0, 0, 0, 230, 0, 0, -953, -148, 50, -50, 207], [0, 0, 0, 0, -272, -169, -169, 1712, 52, 162, -162, -56], [447, -77, 186, -320, 0, 192, -192, 0, 0, -45, -45, 0], [0, 0, 0, 0, 146, -34, -34, 655, -74, -114, 114, 37], [-1084, -54, 14, -218, 0, -43, 43, 0, 0, 50, 50, 0], [0, 0, 0, 0, 48, 35, 35, -840, -16, -16, 16, 372], [2893, 26, -182, 280, 0, -354, 354, 0, 0, -150, -150, 0], [2366, -63, 112, -441, 0, -48, 48, 0, 0, 174, 174, 0], [687, 79, 67, -19, 0, 113, -113, 0, 0, -225, -225, 0], [682, 153, -239, -2, 0, 2, -2, 0, 0, -86, -86, 0], [-2994, -84, -80, 18, 0, 475, -475, 0, 0, 155, 155, 0], [0, 0, 0, 0, 255, 107, 107, 3916, -51, 93, -93, 134], [7628, -62, -264, -122, 0, -243, 243, 0, 0, -93, -93, 0], [0, 0, 0, 0, 209, 182, 182, 2943, 298, -94, 94, 6], [5321, -16, 253, 134, 0, 148, -148, 0, 0, 265, 265, 0], [0, 0, 0, 0, 430, 285, 285, 72, 122, 62, -62, 100], [-1508, -150, -146, 84, 0, -310, 310, 0, 0, -366, -366, 0], [0, 0, 0, 0, 297, -266, -266, -158, 67, 165, -165, 61], [0, 0, 0, 0, 262, -255, -255, -898, 121, -276, 276, -358], [4500, 214, -279, -407, 0, -496, 496, 0, 0, -89, -89, 0], [0, 0, 0, 0, 107, -70, -70, -1815, 317, -5, 5, 250], [-576, 60, 197, 305, 0, -119, 119, 0, 0, 224, 224, 0], [524, -362, -442, -396, 0, 271, -271, 0, 0, -285, -285, 0], [0, 0, 0, 0, 550, 74, 74, 1893, 289, -12, 12, 216], [4482, -89, -164, 448, 0, 370, -370, 0, 0, -1, -1, 0], [4551, -391, 261, -173, 0, 198, -198, 0, 0, 121, 121, 0], [0, 0, 0, 0, -961, -90, -90, 2781, -143, 127, -127, 138], [3432, -71, 740, 624, 0, 10, -10, 0, 0, 137, 137, 0], [0, 0, 0, 0, -484, -212, -212, -904, -203, 45, -45, -616], [0, 0, 0, 0, 860, 122, 122, 1486, -25, -299, 299, 183], [0, 0, 0, 0, 822, 293, 293, 2332, -95, 194, -194, -110], [-5143, 51, 119, -485, 0, -580, 580, 0, 0, 209, 209, 0], [-5512, -262, 323, -59, 0, 14, -14, 0, 0, -203, -203, 0], [0, 0, 0, 0, 796, -577, -577, -992, -2, -14, 14, -482], [0, 0, 0, 0, -1247, -581, -581, -91, -389, 196, -196, 282], [0, 0, 0, 0, 3, -206, -206, -216, 297, -247, 247, -110], [-40, -510, -80, -334, 0, 215, -215, 0, 0, 303, 303, 0], [-6906, -24, 8, 64, 0, -528, 528, 0, 0, 366, 366, 0], [0, 0, 0, 0, -156, 364, 364, -3647, 420, 202, -202, -35], [0, 0, 0, 0, -557, 405, 405, -3164, 540, -162, 162, -363], [0, 0, 0, 0, 340, 370, 370, 2152, 250, -312, 312, 66], [5639, -123, -85, 1063, 0, 576, -576, 0, 0, 76, 76, 0], [2442, 90, -26, -1554, 0, 474, -474, 0, 0, 30, 30, 0], [-11405, 282, -161, -256, 0, -555, 555, 0, 0, 401, 401, 0], [0, 0, 0, 0, -1871, 271, 271, -231, 271, -384, 384, -370], [0, 0, 0, 0, 396, -98, -98, 819, -306, 420, -420, 307], [0, 0, 0, 0, -721, 149, 149, -2356, -266, -346, 346, -733], [1592, 164, -83, -107, 0, -459, 459, 0, 0, 242, 242, 0], [-2012, 91, 357, -752, 0, 577, -577, 0, 0, -86, -86, 0], [0, 0, 0, 0, -1612, -348, -348, 620, 288, -86, 86, -56], [0, 0, 0, 0, 303, -81, -81, 2660, -228, -170, 170, 177], [0, 0, 0, 0, 747, -66, -66, 3729, 442, -628, 628, 128], [-724, -814, 94, 1284, 0, 259, -259, 0, 0, -193, -193, 0], [-2596, -33, -335, -908, 0, 294, -294, 0, 0, 280, 280, 0], [-2496, -195, -194, -350, 0, 100, -100, 0, 0, 439, 439, 0], [934, 356, 250, -404, 0, -473, 473, 0, 0, 463, 463, 0], [0, 0, 0, 0, -311, 204, 204, -858, 489, -653, 653, -297], [0, 0, 0, 0, 3132, 208, 208, 3798, -73, -141, 141, -373], [1107, -543, 551, 187, 0, 304, -304, 0, 0, 186, 186, 0], [0, 0, 0, 0, 2061, -578, -578, 1970, -569, 25, -25, -495], [-2668, -146, 20, -286, 0, 693, -693, 0, 0, 91, 91, 0], [0, 0, 0, 0, 2321, -565, -565, 1382, -387, 275, -275, 272], [-2249, -51, -123, 119, 0, -642, 642, 0, 0, 203, 203, 0], [509, 295, 51, -557, 0, -1507, 1507, 0, 0, -305, -305, 0], [0, 0, 0, 0, -2513, -171, -171, -9732, 200, 130, -130, 593], [0, 0, 0, 0, 1664, 27, 27, 5096, 351, -212, 212, 234], [0, 0, 0, 0, 104, 210, 210, 6548, 58, -116, 116, 538], [5341, 382, -192, 602, 0, -356, 356, 0, 0, 216, 216, 0], [-11535, -727, -278, 116, 0, 220, -220, 0, 0, -85, -85, 0], [11868, 346, 346, -748, 0, -1011, 1011, 0, 0, -4, -4, 0], [0, 0, 0, 0, 1924, -65, -65, 5629, -791, 745, -745, 322], [0, 0, 0, 0, -391, 715, 715, -741, -488, 179, -179, 1240], [-7360, -82, -1298, 488, 0, 805, -805, 0, 0, -316, -316, 0], [8646, -582, -632, -888, 0, 384, -384, 0, 0, -266, -266, 0], [0, 0, 0, 0, 2135, 478, 478, -2132, -118, 134, -134, 871], [0, 0, 0, 0, 1230, 701, 701, 4076, 720, 216, -216, 438], [-9344, 30, -234, 1056, 0, -417, 417, 0, 0, -343, -343, 0], [0, 0, 0, 0, 4419, -263, -263, 1052, 549, 58, -58, 653], [0, 0, 0, 0, 177, 393, 393, 5344, -382, 516, -516, -427], [-6277, -50, -793, 18, 0, 794, -794, 0, 0, -221, -221, 0], [0, 0, 0, 0, 3713, 557, 557, 10565, -143, 54, -54, -320], [0, 0, 0, 0, 1318, -447, -447, 9235, -893, -101, 101, 30], [0, 0, 0, 0, -295, 312, 312, -2055, -588, 456, -456, 48], [2958, -350, -172, 488, 0, -836, 836, 0, 0, -410, -410, 0], [18992, 198, -205, -1269, 0, -216, 216, 0, 0, -421, -421, 0], [723, -1390, -197, 1408, 0, 297, -297, 0, 0, 109, 109, 0], [0, 0, 0, 0, -320, 918, 918, 148, -254, 62, -62, 274], [16070, 936, -928, 926, 0, -757, 757, 0, 0, -328, -328, 0], [0, 0, 0, 0, -1896, -483, -483, 1068, -1215, 990, -990, 36], [0, 0, 0, 0, -2574, 10, 10, 4088, 566, 12, -12, -828], [0, 0, 0, 0, -1698, 542, 542, -4193, 1821, -602, 602, -100], [-459, 439, 395, -1597, 0, 498, -498, 0, 0, 752, 752, 0], [0, 0, 0, 0, -452, 1273, 1273, 784, 1048, -130, 130, 628], [0, 0, 0, 0, 3299, 311, 311, -9776, -333, 154, -154, 639], [-10808, 722, -335, 1105, 0, -808, 808, 0, 0, -557, -557, 0], [0, 0, 0, 0, -1075, 94, 94, -770, -833, -303, 303, -350]]
