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