#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ int t; cin>>t; rep(_,t){ long long n; cin>>n; long long ans =0; long long cur = 1; rep(i,100){ ans += cur; cur %= 10; long long t = n-i; if(t<0)break; cur *= t%10; cur %= 10; if(cur==0)break; } ans %= 10; cout<