def Determinant(A): from copy import deepcopy N=len(A) A=deepcopy(A) det=1 for i in range(N): Ai=A[i] for j in range(i+1, N): Aj=A[j] while Aj[i]: alpha=Ai[i]//Aj[i] if alpha: for k in range(i, N): Ai[k]-=alpha*Aj[k] A[i], A[j]=A[j], A[i] Ai=A[i]; Aj=A[j] det*=-1 det*=Ai[i] if det==0: break return det #================================================== def solve(): N=19; U=1<>k)&1 popcount=[0]*U DP=[0]*U; DP[0]=1 for S in range(U): t=popcount[S]=(popcount[S>>1]+(S&1)) for i in range(N): if bit(S,i)==0 and B[t][i]: DP[S|(1<