#include #include #include #include #include #define ALL(x) (x).begin(),(x).end() #define RALL(x) (x).rbegin(),(x).rend() #define REP(i,a,n) for(int i = (a);i < (n);i++) #define PI 3.14159265359 #define MOD 1000000007 using namespace std; int main(){ int t; cin >> t; REP(i,0,t){ string s; cin >> s; int k = s.length(); REP(h, 1, k){ string t = ""; REP(j, 1, s.length()){ int a = s[j-1]-'0',b = s[j]-'0'; a += b; a = a/10 + a%10; t += to_string(a); } s = t; } cout << s << endl; } return 0; }