#include using namespace std; void solve() { long long n; cin >> n; if (n <= 4) { vector ans = {0, 2, 5, 6, 5}; cout << ans[n] << '\n'; return; } int ans = 0; n = n % 10 + 10; for (int i = 1; i <= 5; i++) { ans += n; ans += n * (n - 1); ans += n * (n - 1) * (n - 2); ans += n * (n - 1) * (n - 2) * (n - 3); ans += n * (n - 1) * (n - 2) * (n - 3) * (n - 4); } ans += 1; ans %= 10; cout << ans << endl; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t--) { solve(); } }