#include using namespace std; #ifdef _RUTHEN #include #else #define show(...) true #endif #define REP(i, n) for (int i = 0; i < (n); i++) template using V = vector; int main() { ios::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while (tt--) { long long N; cin >> N; long long ans = 0, c = 1; for (long long k = N; k >= 1; k--) { ans += c; ans %= 10; c = c * k % 10; } ans += c; ans %= 10; cout << ans << '\n'; } return 0; }