#include #include #include #include #include #include #include using namespace std; typedef unsigned int uint; typedef long long LL; #define FOR(k,a,b) for(uint k(a); k < (b); ++k) #define REP(k,a) for(uint k=0; k < (a); ++k) int main (int argc, char** argv) { #ifdef HOME freopen("in.txt","rb",stdin); freopen("out.txt","wb",stdout); #endif int T; LL K; scanf("%d", &T); while (T--) { scanf("%lld", &K); K--; LL res = 0, act = 1; while (K) { res += 2 * (K % 5) * act; K /= 5; act *= 10; } printf("%lld\n", res); } return 0; }