#include #include #define S size() using namespace std; int main() { string Sn; int T; cin >> T; while (T--) { cin >> Sn; while(Sn.S != 1){ string N; for (int i = 0; i < (int)Sn.S-1; i++) { int box = (Sn[i] - '0')+ (Sn[i + 1] - '0'); if (box >= 10) box = box / 10 + box % 10; N += box + '0'; } Sn = N; } cout << Sn << endl; } return EXIT_SUCCESS; }