#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long long #define INF (1 << 30) #define INFLL (1LL << 60) #define FOR(i,a,b) for(ll i = (a);i<(b);i++) #define REP(i,a) FOR(i,0,(a)) #define MP make_pair int solve(string str){ int k = str.size(); int now[1010] = {}; for(int i = 0;i < k;i++){ now[i] = str[i] - '0'; } while(k != 1){ for(int i = 0;i < k - 1;i++){ now[i] += now[i + 1]; now[i] = (now[i] % 10) + now[i] / 10; } k--; } return now[0]; } int main() { int n; string str; cin >> n; for(int i = 0;i < n;i++){ cin >> str; cout << solve(str) << endl; } return 0; }