{ ll@t; rep(t){ ll@n,a=1; rep(100)a=10a%n; ll b=a,i=0; while(++i,a=10a%n,a!=b); wt(i); } }