t;v;i;r;c;l;o;d[11][11];main(f){for(;f;v=!c?v:0,o=r==10,o?puts("-1"+(t&1^1)):0,memset(d,0,484*o),i*=!o,t*=!o,r=10)for(f=read(0,&r,1),c=r<48,v=!c?v*10+r-48:v,i+=c,l=0;c&&l<12;t+=(1<++d[i][l*(l