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