#include using namespace std; signed main(){ int T; cin >> T; for( int i = 0; i < T; ++i ){ string S; cin >> S; while( S.size() > 1 ){ string t; for( int i = 0; i + 1 < S.size(); ++i ){ int x = S[ i ] + S[ i + 1 ] - 2 * '0'; if( x < 10 ) t += ( char ) ( '0' + x ); else t += ( char ) ( '0' + x / 10 ), t += ( char ) ( '0' + x % 10 ); } swap( t, S ); } cout << S << endl; } return 0; }