I,R=input,range L=1000 P=[] C=[0]*L for i in R(2,L): if C[i]<1: P+=[i] j=i*2 while j1:S(B) if u:a=-1 else: a,r=0,1 for k in R(n): b,c=[r,q[k]],[[1,0],[0,1]] i=r