M := ModularSymbols("389A");

function Rank0(p,m)
   assert Type(p) eq RngIntElt;
   assert Type(m) eq RngIntElt;
   assert IsPrime(p) and IsOdd(p) and p gt 0;
   assert m ge 1;
   n := m+1;
   G<eps> := DirichletGroup(p^n, CyclotomicField(EulerPhi(p^n)));
   chi := eps^(p-1);
   assert Order(chi) eq p^(n-1);
   K := BaseRing(G);
   MK := BaseExtend(M,K);
   return Dimension(TwistedWindingSubmodule(MK,1,chi)) ne 0, chi, MK;
end function;

time r1 := Rank0(3,1);
printf "1: %o\n", r1;
time r2 := Rank0(3,2);
printf "2: %o\n", r2;
time r3 := Rank0(3,3);
printf "2: %o\n", r2;

