
// Make newform 349.2.a.b in Magma, downloaded from the LMFDB on 25 April 2024.
// To make the character of type GrpDrchElt, type "MakeCharacter_349_a();"
// To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
// To make the newform (type ModFrm), type "MakeNewformModFrm_349_2_a_b();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_349_2_a_b();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function ConvertToHeckeField(input: pass_field := false, Kf := [])
    if not pass_field then
        poly := [-4, -41, 75, 1075, -164, -5373, 2880, 6673, -4835, -3021, 2887, 474, -792, 26, 102, -14, -5, 1];
        Kf := NumberField(Polynomial([elt : elt in poly]));
        AssignNames(~Kf, ["nu"]);
    end if;
    Rf_num := [[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, -5, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-349096, 464407341, -528604566, -5454831045, 8001174573, 7020646464, -12507143628, -2198561585, 7225993314, -358261227, -1946294566, 302832280, 248098852, -53358172, -12143208, 3046496, 6881], [33470372, -18197482, -385718169, 1367630449, -446520802, -1874089153, 1360000699, 693906061, -839916930, 16498676, 202090863, -58049485, -15879081, 11316825, -842951, -673231, 129907], [-16651472, -345190511, 26091993, 1432645940, -1394056621, -1020314197, 2146286917, -440334094, -1046385666, 610889171, 175130105, -208650675, 6728395, 29695925, -4675055, -1539407, 342344], [-60860676, 84175177, 1738656858, 550576315, -8563127797, 2175158294, 10918796292, -5084510469, -5364723646, 3290717187, 1102309566, -933243792, -56644828, 122225562, -9436362, -6048190, 954477], [-38280072, -187476637, 301820608, 787373203, -2034349445, 2127467628, 2410932626, -4627216617, -534122266, 2889057543, -296651690, -803930404, 157565816, 104173792, -25701018, -5123424, 1423805], [-16113024, 32793065, -752233888, -765969227, 7039828559, -3380595882, -9907626526, 7287976453, 4723757470, -4606979421, -770532978, 1292185188, -38246072, -168218710, 22421616, 8295022, -1624725], [100990532, 334787557, -3249870492, -3709594629, 18977545907, -1752525352, -24980012280, 9816264405, 12362382076, -7035651475, -2524139110, 2072568454, 119779992, -276884452, 23761238, 13871476, -2320607], [-38449256, -40686922, 708875774, -213355823, -3336736615, 3337708828, 3888315285, -5145466896, -1397185719, 2952339580, -6972284, -791693437, 101420316, 100486682, -19898736, -4876786, 1177751], [-53459238, -173708857, 1628902717, 1891397865, -9771397341, 1355364934, 12956859425, -5820649228, -6331983519, 4081521360, 1225665635, -1193366371, -33046398, 158865051, -16588569, -7943686, 1430016], [-54985350, -167916467, 1598499815, 917431766, -9935315824, 4629682174, 12943391397, -9524615238, -5873224414, 5955878758, 862799245, -1664310761, 78707123, 216378870, -31922034, -10666320, 2212232], [161461920, 424686951, -3979676103, -2117117842, 22306957823, -9681635945, -28679333929, 20045296036, 13167816710, -12518312453, -2076095689, 3492081761, -117535949, -453309389, 62453009, 22316577, -4464588], [41232606, 45368196, -1709938046, -1222783277, 11481073899, -4310704213, -15251807704, 9783571190, 7147568361, -6260382996, -1184928143, 1766179249, -42311710, -230738128, 30768077, 11405411, -2258564], [155763180, 276723354, -4755103951, -2992752301, 29732956670, -11084633469, -39180778403, 24731166679, 18433074534, -15773479316, -3127113413, 4445515351, -79913865, -580575835, 74918371, 28694781, -5588767]];
    Rf_basisdens := [1, 1, 1, 1, 13854332, 13854332, 13854332, 13854332, 13854332, 13854332, 13854332, 6927166, 6927166, 6927166, 13854332, 6927166, 13854332];
    Rf_basisnums := ChangeUniverse([[z : z in elt] : elt in Rf_num], Kf);
    Rfbasis := [Rf_basisnums[i]/Rf_basisdens[i] : i in [1..Degree(Kf)]];
    inp_vec := Vector(Rfbasis)*ChangeRing(Transpose(Matrix([[elt : elt in row] : row in input])),Kf);
    return Eltseq(inp_vec);
end function;


// To make the character of type GrpDrchElt, type "MakeCharacter_349_a();"
function MakeCharacter_349_a()
    N := 349;
    order := 1;
    char_gens := [2];
    v := [1];
    // chi(gens[i]) = zeta^v[i]
    assert UnitGenerators(DirichletGroup(N)) eq char_gens;
    F := CyclotomicField(order);
    chi := DirichletCharacterFromValuesOnUnitGenerators(DirichletGroup(N,F),[F|F.1^e:e in v]);
    return MinimalBaseRingCharacter(chi);
end function;

function MakeCharacter_349_a_Hecke(Kf)
    return MakeCharacter_349_a();
end function;


function ExtendMultiplicatively(weight, aps, character)
    prec := NextPrime(NthPrime(#aps)) - 1; // we will able to figure out a_0 ... a_prec
    primes := PrimesUpTo(prec);
    prime_powers := primes;
    assert #primes eq #aps;
    log_prec := Floor(Log(prec)/Log(2)); // prec < 2^(log_prec+1)
    F := Universe(aps);
    FXY<X, Y> := PolynomialRing(F, 2);
    // 1/(1 - a_p T + p^(weight - 1) * char(p) T^2) = 1 + a_p T + a_{p^2} T^2 + ...
    R<T> := PowerSeriesRing(FXY : Precision := log_prec + 1);
    recursion := Coefficients(1/(1 - X*T + Y*T^2));
    coeffs := [F!0: i in [1..(prec+1)]];
    coeffs[1] := 1; //a_1
    for i := 1 to #primes do
        p := primes[i];
        coeffs[p] := aps[i];
        b := p^(weight - 1) * F!character(p);
        r := 2;
        p_power := p * p;
        //deals with powers of p
        while p_power le prec do
            Append(~prime_powers, p_power);
            coeffs[p_power] := Evaluate(recursion[r + 1], [aps[i], b]);
            p_power *:= p;
            r +:= 1;
        end while;    
    end for;
    Sort(~prime_powers);
    for pp in prime_powers do
        for k := 1 to Floor(prec/pp) do
            if GCD(k, pp) eq 1 then
                coeffs[pp*k] := coeffs[pp]*coeffs[k];
            end if;
        end for;
    end for;
    return coeffs;
end function;


function qexpCoeffs()
    // To make the coeffs of the qexp of the newform in the Hecke field type "qexpCoeffs();"
    weight := 2;
    raw_aps := [[0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, -1, 0, 0, -1, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 0], [3, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, -1, 1, 0, 0, 0], [1, 0, 0, -1, 0, 0, -1, 0, 0, 1, 1, -1, -1, 1, -1, 0, 0], [0, 0, -1, 0, 1, 0, 0, -1, 0, 0, -1, 0, 1, -1, 0, 0, -1], [0, 1, -1, 1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 1, 0, -1], [-1, 0, 0, 0, 1, -1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0], [1, -1, 0, 0, 0, -2, 1, 0, 1, -1, -2, 0, 0, -1, 0, 0, 0], [-1, 1, 0, 0, 1, 0, 0, 1, 0, -1, -2, 0, 0, -1, 1, 1, -1], [-2, 0, 1, 0, 0, 0, 0, 0, -1, 0, 1, 2, 1, 0, 0, 1, 1], [2, -1, 0, 0, -1, 0, -2, -1, 0, 0, 1, -1, -2, 1, -1, -1, 0], [0, 0, 1, 0, 1, 2, 1, 0, -2, -1, 0, 0, 0, -2, 0, 1, -1], [3, -2, 1, -1, -2, 0, -1, -1, -2, 2, 3, 0, -1, 1, -2, 0, 1], [2, 0, 0, 0, -1, -2, -1, -1, 3, 0, 1, -1, -1, 1, 1, -2, 0], [3, -1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 2, 0, 1, 0, 1], [-2, -2, 1, -2, 1, 0, 1, -2, -2, 1, 0, 1, 2, -1, -1, 0, 2], [-2, -1, 1, -1, 2, -1, 2, -2, -2, 0, -2, 1, 4, -2, 2, 0, 1], [5, -2, 2, -1, 0, 1, 0, 0, -2, 2, 1, -1, -1, 0, -2, 0, 3], [-2, 0, 0, 0, 0, 1, 0, 0, 0, -1, 1, 1, 0, 1, -1, -1, 0], [2, 0, -1, 1, -1, 0, 0, 1, 1, -1, -2, 0, -2, 0, -1, 0, -1], [6, 0, 1, -2, -1, 0, -3, 0, 1, 2, 2, -3, -4, 2, -3, 0, 2], [-1, 1, -1, 1, 3, 2, 1, -2, -2, 0, -2, 2, 3, -2, 2, 0, -3], [-2, 0, 0, -1, 3, 0, 0, 0, 1, -1, -3, -1, 2, -2, 2, 1, -2], [-3, 3, -2, 2, 2, 1, 1, -1, -1, 0, -4, 0, 3, -3, 1, 0, -1], [1, 2, 1, -1, -2, 1, -1, 1, 1, 1, 1, 0, -2, -1, -1, 2, -2], [4, 1, -1, 1, -1, 1, 1, 1, 1, -4, 1, 3, -2, 0, 0, 2, -1], [-2, 0, 1, 0, 3, 1, 1, -1, 0, 0, -2, 0, 1, -1, 2, -1, -2], [0, -1, 3, -1, 0, 0, 0, 0, -2, -3, 0, 0, -1, 0, -1, 3, 1], [2, 0, -1, -1, -5, -4, -5, 0, 5, 2, 3, -3, -5, 2, -4, -3, 2], [-1, 0, 1, 0, 2, -1, 3, 0, -3, -2, -2, 3, 3, -3, 1, 1, -1], [-2, 0, 0, 0, 2, 1, 3, 1, -2, 0, 0, 1, 5, -1, 2, 0, 2], [6, -7, 2, -2, 1, 1, -3, -2, -3, 4, 2, -4, -3, 0, -5, -2, 3], [-1, 1, -2, 3, 2, 2, 1, 4, 0, -2, -3, 1, 1, -1, 0, 1, -1], [-2, 0, -1, 2, 3, 0, 3, 2, 0, -4, -5, 1, 1, -1, 1, 1, 0], [-1, 3, 0, 3, -2, 3, 1, 1, -3, -1, -1, 0, 0, 0, -1, 3, 0], [1, 2, 3, 2, 0, 0, 0, 0, 1, -3, -1, 1, 1, 0, 1, 4, 0], [3, -2, -1, -3, 1, 2, 1, 1, -2, 1, 2, 0, 0, -1, -2, 2, 0], [-3, 3, -4, -1, 0, -1, -1, -1, 3, 0, 2, 0, -1, 1, 1, -2, -1], [9, 3, -1, 1, -3, 2, 0, 3, 2, 0, 1, 0, -2, 1, 1, 2, -3], [-1, -3, 1, 1, -3, 0, 2, 1, -3, 2, 5, 3, -1, 3, 1, -2, 4], [3, 1, -1, -1, 0, -1, -4, -2, 1, 0, 1, -2, 1, 0, 0, 0, -1], [4, 2, 5, -3, -2, 1, -3, 2, 1, -2, 2, -3, -6, 3, -2, 5, -2], [2, 1, -2, -2, -5, -4, -1, -1, 5, -2, 0, 1, -3, -1, 0, 0, -1], [1, -3, 2, -2, -2, -3, -2, 1, 1, 5, 3, -4, 1, 1, -2, -1, 3], [-1, -1, 1, -2, 1, 1, 1, 0, -3, -3, 1, 2, 2, 0, -2, 2, 3], [-2, 1, 0, -1, 2, 3, 5, 3, -4, 1, 0, 1, 3, 3, 1, 1, 1], [2, -1, 1, -3, -2, -3, -2, -1, 2, 1, 4, -3, 0, 1, -2, -3, 1], [-2, -1, 1, 1, -2, -2, 2, 1, 3, -3, 0, 0, -1, -2, 3, 0, -1], [-3, 0, -2, 1, 1, 1, 4, 0, 0, -4, -2, 3, 3, -3, 1, 0, -1], [-1, -1, -2, 2, 5, 1, 4, -2, 0, -2, -5, 3, 5, -2, 2, -2, -1], [-5, 5, -3, 4, 1, 3, 3, 2, 1, -1, -3, -1, 2, -2, 3, 2, -2], [10, 1, 0, -1, 1, -1, 0, -4, 3, -4, -4, -1, -2, -1, 1, 0, -1], [-3, 1, 0, 3, -6, -3, 2, 4, 2, 0, 2, 2, 2, 0, 4, 1, 0], [2, 2, 5, -6, -1, -2, -3, -1, 1, 3, 0, -5, -2, 1, -3, 3, 2], [0, -1, -4, 0, 0, -2, -2, 0, 2, 2, 3, 0, -3, 3, 1, -4, 0], [-5, 0, 0, 6, -1, -2, 2, -3, 1, -2, -1, 2, 7, -4, 4, -1, -2], [-8, 1, 0, 1, 0, 2, 0, 0, -1, -3, 3, 4, 1, 1, 1, 4, 1], [9, -4, 4, -7, -2, -2, -5, -3, -1, 4, 5, -5, -5, 4, -7, -2, 4], [-5, 2, -2, -2, -1, -1, -4, -3, 4, -1, 2, 1, -1, 1, -1, -1, -2], [-2, -2, -3, 4, -1, 2, -1, 0, 1, 3, 1, -1, -4, 5, 1, -7, 3], [-4, 2, -5, 2, 1, -1, 1, -2, 7, -4, -1, 4, 3, -2, 4, 0, -6], [2, 1, 4, -1, -3, -6, -3, 2, 7, 0, 2, -3, 0, 2, 3, 1, 1], [-3, -9, 2, 0, -1, -3, 1, 0, -2, 2, 2, -1, 1, -3, -3, -2, 3], [-1, -6, 1, -1, 2, -1, -1, -6, -4, 3, 0, 2, 2, -3, -2, -4, 0], [1, -1, -3, 0, -2, -1, -3, 1, 0, 5, 6, -1, 1, 5, 0, -3, 2], [-1, -1, -3, 2, 5, 5, 5, -2, -4, -1, -1, 5, 1, 1, 1, -3, 1], [1, -1, 0, -2, 4, 2, -1, 1, 0, -1, -4, 1, -2, -2, 1, 1, -3], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [-9, 8, 2, 1, 0, 2, 3, 1, 0, -1, 2, 5, 5, -2, 3, 4, -4], [11, -2, 1, -3, -2, 2, 1, -1, 0, 2, 6, -1, -3, 2, 0, 0, -2], [-4, 3, -2, 3, 0, 3, -2, 3, -2, 1, 4, 2, -3, 6, 3, -2, -2], [-3, -3, -4, 1, 1, -3, -1, 0, 2, 4, -3, -1, 0, -2, -1, -2, -1], [4, 2, -3, -2, 1, -3, -1, 3, 10, -5, -4, -1, -3, 1, 3, 0, -6], [3, -2, 2, 5, -6, -2, 0, 4, 4, -1, 1, -2, 1, 4, 1, 1, 1], [0, 4, 3, 0, 0, 0, 2, 3, 0, -2, -3, -2, -4, 1, 2, 6, -2], [-2, -3, -1, 3, -5, -3, 0, -1, 3, 3, 3, 1, 1, 2, 4, -2, -2], [-1, -8, 0, -2, 3, 1, 1, -3, -5, 5, 3, 3, 6, -4, 0, -2, 0], [3, -3, -2, 3, 0, 3, 5, 1, -4, 0, 2, 5, 0, -3, 1, 2, 0], [7, 0, 2, 0, -2, 7, 0, 2, -4, 1, 4, 0, -2, -3, -3, 8, -2], [2, -6, -3, -2, 6, 2, 2, -7, -6, 2, -3, 2, 4, -3, 0, -4, 2], [8, 0, 3, -3, 2, 1, 0, -7, -1, 0, -4, -1, 5, -4, -2, 2, -2], [-2, -6, 6, -1, -3, -1, -3, -2, -5, 6, 3, -2, 2, 0, -4, -4, 8], [-6, -8, -1, 0, 2, 1, 1, 0, -2, 1, 2, 5, 1, 0, 0, -5, 6], [12, -4, 2, -6, -4, -3, -5, -3, 2, 2, 4, -1, -6, 5, -4, -2, 4], [0, 2, 1, 0, -1, -4, -2, 2, 1, 2, 2, -3, -2, 2, 0, -4, 0], [5, 3, 4, 0, -5, -2, 1, 4, 0, -3, 0, 0, -4, -3, 0, 5, -1], [0, 12, 2, 1, -4, 0, -1, 3, 2, -3, 2, -2, -7, 5, 1, 5, 0], [-1, -1, 2, 1, -3, -3, 1, 1, -2, -2, 2, 2, 3, 0, 2, 0, 5], [1, 0, 1, -2, 2, -2, 1, 1, -1, 0, -2, -1, -2, -1, -1, -2, 0], [-1, -1, 1, -6, 1, -2, -1, -2, -5, -1, 0, 0, -1, -5, -4, 2, 3], [4, -7, 5, -1, -3, 0, -2, -4, -5, 0, 3, 1, -7, -2, -5, -4, 3], [-2, 6, 1, 2, 0, -2, 3, 2, 2, -4, -4, 6, 9, -4, 5, 2, -4], [7, 4, -4, 1, 1, 0, 7, 2, -4, -2, -1, 3, 0, -1, 0, 1, -1], [0, 7, -6, 4, 6, 9, 4, 4, -2, -1, -4, -1, 0, 4, 5, 4, -5], [-5, 4, -5, 1, 0, -2, 0, -3, -2, 4, 1, 1, 1, 0, 4, -7, 2], [4, 1, 5, 1, -4, -1, -3, 4, 2, -2, 0, -1, -3, 0, -3, 2, -1], [-5, 5, 0, 3, 1, -1, 5, 6, 1, -2, -3, 3, 1, 1, 2, 0, 1], [1, 0, -7, 2, 0, 1, 0, -4, 0, 1, -4, 2, 3, -4, 1, 0, -1], [1, 1, -4, 1, 4, 3, 5, 1, -3, -5, -5, 0, 4, -5, -1, 1, 1], [2, -8, 1, 0, -4, 1, -4, -3, -2, 5, 7, -1, -4, 3, -7, -5, 6], [-2, -3, 3, -4, 5, -3, 0, -1, -4, -1, 1, 0, -2, 0, -2, 0, 1], [-1, 3, 0, 4, 1, 1, -1, 2, 0, -4, -1, -1, 0, 0, 3, 2, 1], [10, -4, -4, 0, -2, -5, -11, -6, 5, 6, 4, -8, -5, 4, -5, -9, 2], [0, -3, 3, -3, 7, 2, 13, -7, -7, -5, -6, 8, 11, -6, 4, 0, 0], [-2, 0, 3, 2, 5, 3, 2, 1, -3, -5, -9, 0, 3, -9, 1, 3, -6], [2, -2, 3, -2, 0, 1, 1, 3, 3, -3, -2, -3, -1, 4, -2, 6, 0], [-4, -2, -2, 4, 2, 0, 4, 1, 1, 0, -4, 3, 2, 1, 7, -3, 0], [1, 6, 1, 0, -2, -4, -3, -7, 1, 1, -1, 1, -2, -1, -1, -3, -2], [4, 4, 2, -1, -1, 6, -1, 1, 0, 0, 0, -3, -5, 4, -1, 3, -2], [-10, 6, -2, 6, 2, -1, 5, -7, -1, -5, -7, 4, 7, -5, 4, 1, -1], [6, 2, -1, 1, 0, 4, 2, 0, 0, 0, -1, 1, 5, -1, 0, 1, -3], [9, 0, 1, -6, -1, -2, -7, -2, 3, 1, 0, -6, -12, -3, -6, 1, -2], [3, 6, 4, -3, -5, -5, -7, 1, 6, 1, 4, -5, -5, 5, -2, 5, 0], [-7, 15, -7, 4, 2, 4, 3, 3, 2, -5, -6, 3, 0, -1, 0, 2, -3], [2, 2, 0, 3, -5, -5, -4, 5, 5, 2, 1, -4, 1, 3, 2, 3, 0], [-3, -4, -1, 3, 0, -2, 1, 2, 1, 1, 0, 1, -2, 2, -1, -1, 4], [-2, -8, -3, 0, 1, -1, -2, 1, 1, 3, -2, -2, 0, 2, -3, -5, 8], [13, -11, 4, -1, -3, 0, 0, -4, -7, 5, 8, -1, 1, -4, -4, -5, 4], [-7, -2, -3, 2, 5, -2, 7, 2, -2, 1, 0, 2, 11, -3, 3, -3, 1], [10, 9, -5, -1, 2, 4, -1, 6, 12, -4, -3, -2, -5, 2, 4, 4, -11], [-4, -4, -1, 0, 1, 1, 5, -4, -2, 0, 0, 4, 10, -5, 2, -1, -2], [3, -9, -6, 3, 1, -4, 0, -3, 1, 1, 1, 2, -2, 0, 5, -4, 1], [-1, 1, -1, 6, -1, 1, 3, 4, 3, -7, -1, 8, 6, 2, 6, 1, -4], [-1, -2, 6, 2, 1, -1, -1, -3, -3, -2, 2, 7, 1, -3, -2, -1, 1], [1, -6, 5, 0, 0, -3, 2, 3, -2, -2, -2, -4, -3, 0, -5, 3, 6], [-5, 4, -1, -3, 2, 2, 4, 3, 1, 2, 4, -5, 2, 3, 2, -2, 0], [-5, 4, 2, 1, 2, 0, -2, 1, -2, 5, -2, -3, 0, 0, 2, 0, 0], [-12, -3, 3, -1, 6, 1, 5, 0, -5, 0, -3, 3, 12, -3, 7, 5, -3], [-3, 5, 5, -2, 3, 0, 0, -2, -4, 3, 1, 0, 2, 2, -3, -3, 3], [-10, 6, -7, 4, -2, 1, 2, 5, 4, 0, 4, -1, 3, 3, 5, -2, -2], [-1, 12, -1, 1, -4, 3, 4, 5, -1, -7, -4, 5, 2, -2, 0, 7, -6], [7, 3, 4, 1, -7, 1, -4, 1, 0, 5, 7, -5, -1, 5, -2, 1, -3], [-3, -6, -3, 6, -2, -2, -5, 5, 5, 5, 5, -5, 0, 7, 5, -5, 4], [-7, 3, -1, 0, 6, -1, 4, -3, -8, 2, -1, 4, 7, 0, 0, -3, 3], [-3, 8, 1, 4, -3, 4, 2, 2, -6, -10, -4, 5, -1, -3, 0, 9, -7], [8, -1, 0, -1, -5, 1, 8, 1, -5, -4, -5, 4, -5, -1, -2, 4, 1], [6, 3, 1, -2, 3, 4, 3, -3, -2, -2, -3, 3, 3, 2, 2, 3, -5], [4, 4, -1, 0, -4, 3, -2, 0, 1, -1, 1, 1, -9, 6, -3, 0, 5], [-4, 4, 5, -1, 2, 2, 2, 0, 0, -2, -7, 0, 5, -4, -1, 5, -2], [7, 1, -2, 1, -3, -7, -1, -1, 9, -3, -7, -6, -5, -3, 1, -1, -4], [6, -1, -5, 2, 0, 5, -3, -3, 4, -6, -3, 3, -10, 3, 3, 0, -7], [9, 5, 6, 6, -4, 4, 0, 6, 2, -6, -5, -4, -5, 0, 0, 8, -6], [5, -6, 5, -7, -9, -10, -11, -5, 7, 4, 7, -6, -5, 0, -5, -7, 4], [0, 3, 3, 1, -6, -12, -3, -4, 10, 3, 0, -3, 5, -3, 3, -3, -1], [9, 1, -1, -2, -8, -5, -3, 4, 1, 0, 2, -3, -7, 1, -5, 1, 6], [3, 4, -3, -3, -6, -2, -10, 4, 8, 3, 7, -7, -14, 9, -4, -4, 2], [-6, 7, -5, 3, 0, 1, -3, -3, 1, -2, 2, 3, 1, -2, 3, -3, -5], [11, -8, -4, 7, 6, 8, 4, -4, -2, -3, -3, 2, 1, -2, 3, 1, -5], [-1, 10, -1, 1, -6, -1, -5, 4, 3, 2, 8, 2, 1, 4, 0, 2, -2], [-5, 2, 3, 0, 3, 3, 3, 2, -5, -13, -10, 7, 0, -7, 0, 8, -2], [7, 0, 3, -9, -2, -3, 0, -3, 3, -3, 2, -2, -3, -1, -1, 1, -6], [-6, -16, 4, -6, 7, 2, 2, -7, -5, 4, -1, -2, 5, -4, -5, 0, 4], [0, -7, -3, -2, 8, 5, 12, 3, -8, 0, 1, 4, 8, 0, 1, -3, 2], [1, 0, 5, 0, -11, -3, -10, -2, 0, 10, 9, -5, -1, 2, -4, -1, 6], [5, 7, -6, 0, -2, -2, 2, -3, 7, -6, -1, 2, -5, 2, 0, 0, -5], [5, -1, 0, -4, 0, -4, 1, -2, -1, 1, -2, 3, 2, -1, 0, 3, 5], [-1, -6, 3, 5, -7, 2, -9, -1, -4, 9, 15, -6, -7, 10, -3, -7, 7], [9, -4, 10, -1, 2, 9, -6, -3, -6, 1, 0, -2, -6, -1, -3, 2, 0], [-3, -2, 4, 1, 1, 3, 2, 9, -3, 0, -4, 3, 0, -2, 3, 1, 0], [2, 8, -4, 3, 1, -4, -1, 2, 4, 1, -4, -3, 0, 0, 5, -4, 1], [-8, -12, -8, 3, 6, 2, -3, -7, -7, 10, -2, 0, 6, -4, -1, -7, 6], [-7, -5, -5, 7, 3, 2, 5, -1, -3, -6, -4, 8, 3, 0, 6, -9, 5], [-1, 1, 3, 1, -3, 2, 1, 2, 0, -10, -7, -1, 0, -5, 2, 7, -4], [-4, 7, 5, 2, 1, 11, 4, 0, -9, 1, -3, 0, 0, 2, 0, 7, 5], [-10, -15, 4, -2, 7, 1, 5, 1, -11, 4, -3, 4, 6, -3, -1, 2, 3], [8, -4, -5, 1, 6, -1, 1, -2, 5, 2, -6, -7, 2, -3, 6, -1, -2]];
    aps := ConvertToHeckeField(raw_aps);
    chi := MakeCharacter_349_a_Hecke(Universe(aps));
    return ExtendMultiplicatively(weight, aps, chi);
end function;


// To make the newform (type ModFrm), type "MakeNewformModFrm_349_2_a_b();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose lines below.
// The precision argument determines an initial guess on how many Fourier coefficients to use.
// This guess is increased enough to uniquely determine the newform.
function MakeNewformModFrm_349_2_a_b(:prec:=17)
    chi := MakeCharacter_349_a();
    f_vec := qexpCoeffs();
    Kf := Universe(f_vec);
    // SetVerbose("ModularForms", true);
    // SetVerbose("ModularSymbols", true);
    S := CuspidalSubspace(ModularForms(chi, 2));
    S := BaseChange(S, Kf);
    maxprec := NextPrime(997) - 1;
    while true do
        trunc_vec := Vector(Kf, [0] cat [f_vec[i]: i in [1..prec]]);
        B := Basis(S, prec + 1);
        S_basismat := Matrix([AbsEltseq(g): g in B]);
        if Rank(S_basismat) eq Min(NumberOfRows(S_basismat), NumberOfColumns(S_basismat)) then
            S_basismat := ChangeRing(S_basismat,Kf);
            f_lincom := Solution(S_basismat,trunc_vec);
            f := &+[f_lincom[i]*Basis(S)[i] : i in [1..#Basis(S)]];
            return f;
        end if;
        error if prec eq maxprec, "Unable to distinguish newform within newspace";
        prec := Min(Ceiling(1.25 * prec), maxprec);
    end while;
end function;


// To make the Hecke irreducible modular symbols subspace (type ModSym)
// containing the newform, type "MakeNewformModSym_349_2_a_b();".
// This may take a long time!  To see verbose output, uncomment the SetVerbose line below.
// The default sign is -1.  You can change this with the optional parameter "sign".
function MakeNewformModSym_349_2_a_b( : sign := -1)
    R<x> := PolynomialRing(Rationals());
    chi := MakeCharacter_349_a();
    // SetVerbose("ModularSymbols", true);
    Snew := NewSubspace(CuspidalSubspace(ModularSymbols(chi,2,sign)));
    Vf := Kernel([<2,R![-4, -41, 75, 1075, -164, -5373, 2880, 6673, -4835, -3021, 2887, 474, -792, 26, 102, -14, -5, 1]>],Snew);
    return Vf;
end function;