T=int(input()) def rep_mul(a,x,m): t=0 val=a while t50: X = find_min_2x(L-40) A=[rep_mul(A[i],X,m)+rep_mul(A[i+X],X,m) for i in range(L-X)] L=len(A) print(process(A,m)) for _ in range(T): solve()