main=getLine>>f;f=readLn>>=(\k->print$11*k+k`mod`10).round.sqrt>>f