#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while(T--){ ll N, ans = 0, c = 1; cin >> N; for(int i = 0; i <= 10; i++){ ans += c % 10; c *= (N - i) % 10; } ans %= 10; cout << ans << '\n'; } }