#include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template static void amin(T &x, U y) { if(y < x) x = y; } template static void amax(T &x, U y) { if(x < y) x = y; } int main() { int TT; scanf("%d", &TT); for(int ii = 0; ii < TT; ++ ii) { char S[1001], T[1001]; scanf("%s", S); int n = strlen(S); rep(i, n - 1) { rep(j, n - i - 1) T[j] = (S[j] - '0') + (S[j + 1] - '0'); rep(j, n - i - 1) S[j] = T[j] / 10 + T[j] % 10 + '0'; S[n - i - 1] = 0; } puts(S); } return 0; }