#include using namespace std; using ll=long long; #define rep(i,n)for(int i=0;i<(n);i++) #define rep3(n)for(;n>0;n--) void out(){cout< void out(Head&& head,Tail&&... tail){cout<(tail)...);} int main(){ cin.tie(nullptr);ios_base::sync_with_stdio(false); int t; cin>>t; int hoge; string a,b; rep3(t){ cin>>a; while(a.size()!=1){ b=""; rep(j,a.size()-1){ hoge=a[j]-'0'+a[j+1]-'0'; //out(a,b,j,hoge,hoge/10+hoge%10); b+=to_string(hoge/10+hoge%10); } a=b; } cout<