#include #include #include #include #include #include using namespace std; using ll = long long; void solve(); int main() { solve(); #ifdef DBG while (true); #endif } //432 void solve() { int t, len; scanf("%d", &t); char s[1001]; for (int tcase = 0; tcase < t; tcase++) { scanf("%s", s); for (len = 0; s[len] != 0; len++) s[len] -= '0'; for (;1 <= len; len--) for (int i = 0; i < (len - 1); i++) { s[i] += s[i + 1]; s[i] = (s[i] % 10) + (s[i] / 10); } printf("%d\n", s[0]); } }