#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int T; cin >> T; rep(_,T) { string s; cin >> s; while(int(s.size()) > 1) { string ns = ""; rep(i,int(s.size())-1) { int a = s[i] - '0', b = s[i + 1] - '0'; int x = a + b; if(x >= 10) x = x / 10 + x % 10; ns += char(x + '0'); } swap(s, ns); } cout << s << endl; } }