#include <bits/stdc++.h>
using namespace std;
// 科学记数法 scientific notation
// 对数logarithm / 真数antilogarithm / 底base
// 首数characteristic/ 尾数mantissa
int solve(int x){
double res = x*log10(x);
return pow(10, res - floor(res));
}
int main(){
int n, T;
scanf("%d", &T);
while(T--){
scanf("%d", &n);
printf("%d\n", solve(n));
}
return 0;
}
09-06
09-06
09-06
09-06