#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main(){ int i, j; int t; vectors; vectorlist; cin >> t; for (i = 0; i < t; i++) { string str; cin >> str; s.push_back(str); } for (i = 0; i < t; i++) { string str = s[i]; if (str.length() == 1) { list.push_back(str); continue; } while (true) { string str2 = ""; for (j = 0; j < str.length() - 1; j++) { int num = ((int)str[j] - 48) + ((int)str[j + 1] - 48); if (num > 9) { num = ((int)to_string(num)[0] - 48) + ((int)to_string(num)[1] - 48 ); } str2 += to_string(num); } if (str2.length() == 1) { list.push_back(str2); break; } str = str2; } } for (i = 0; i < list.size(); i++) { cout << list[i] << endl; } getchar(); getchar(); return 0; }