ll@t;rep(t){string@n;ll@m,a=0;for(char c:n)a=(10a+c-48)%(2m);wt(a*-~a/2%m);}