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