int q[1d6],r;ll t,a,p;{r=Prime(5d6,q);rd(p);REP(p)rd(a,p),wt(*lower_bound(q,q+r,p)-p?-1:a%p>0);}