#include #define rep(x, to) for (int x = 0; x < (to); x++) #define REP(x, a, to) for (int x = (a); x < (to); x++) #define EPS (1e-14) #define _PA(x,N) rep(i,N){cout< PII; typedef pair PLL; typedef complex Complex; typedef vector< vector > Mat; int t; string s; void solve() { string cur = s; while (cur.size() != 1) { string nxt = ""; for (int i = 0; i < cur.size() - 1; i++) { int x = cur[i] - '0'; int y = cur[i + 1] - '0'; nxt += (((x + y) / 10 + (x + y) % 10) + '0'); } cur = nxt; } cout << cur << endl; } int main() { cin >> t; for (int i = 0; i < t; i++) { cin >> s; solve(); } return 0; }