#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; V a = {1, 2, 5, 6, 5, 6, 7, 0, 1, 0}; while (tt--) { long long N; cin >> N; if (N == 0) { cout << 2 << '\n'; } else { cout << a[N % 10] << '\n'; } } return 0; }