#include #include void solve(){ std::string s; std::cin >> s; while(s.length() != 1){ std::string s2; for(int i = 0; i < s.length() - 1; ++i){ int t = (s[i] - '0') + (s[i + 1] - '0'); if(t / 10 != 0){ t = t % 10 + t / 10; } s2 += t + '0'; } s = s2; } std::cout << s << std::endl; } int main() { int test_case; std::cin >> test_case; for(int i = 0; i < test_case; ++i){ solve(); } return 0; }