#include #include using namespace std; using namespace atcoder; using ll = long long; using ld = long double; int t; string s; int main() { cin >> t; for (int i = 0; i < t; i++) { cin >> s; int k = s.size(); while (k > 1) { string t; for (int j = 0; j < k - 1; j++) { int x = s[j] - '0' + s[j + 1] - '0'; if (x >= 10) { string y = to_string(x); x = y[0] - '0' + y[1] - '0'; } t += '0' + x; } //cout << t << endl; s = t; k = s.size(); } cout << s << endl; } return 0; }