#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) typedef long long ll; int main(){ int t; cin >> t; while(t--){ string s; cin >> s; int a[s.length()]; FOR(i,0,s.length()){ a[i] = s[i] - '0'; } FOR(i,0,s.length()-1){ if(a[i]+a[i+1]<10) { a[i] = a[i] + a[i+1]; } else { a[i] = (a[i] + a[i+1]) / 10 + (a[i] + a[i+1]) % 10; } } cout << a[0] << endl; } return 0; }