def get_basis(a): L = len(a) top = [] for i in range(L): idx = max(range(i,L),key=lambda x:a[x].bit_length(),default=i) a[i],a[idx] = a[idx],a[i] if a[i]==0: break t = a[i].bit_length()-1 top.append(t) for j in range(i+1,L): if a[j]>>t&1: a[j]^=a[i] else: i+=1 return a[:i],top def normalize(v,basis,top): for e,l in zip(basis,top): if v&(1<