#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while(t--) { string s; cin >> s; while(s.size() > 1) { string t; for(int i = 0; i < s.size() - 1; i++) { int a = s[i] - '0', b = s[i + 1] - '0'; if(a + b > 9) { t += to_string((a + b) % 10) + to_string((a + b) / 10); } else { t += (a + b) + '0'; } } s = t; } cout << s << endl; } return 0; }