#include using namespace std; int main() { int T; cin >> T; while (T--) { string s; cin >> s; while (s.size() > 1) { string t = s; s = ""; for (int i = 0; i < t.size() - 1; i++) { int x = t[i] - '0' + t[i + 1] - '0'; while (x >= 10) { x = (x % 10) + (x / 10); } s += x + '0'; } } cout << s << endl; } }