#include #include using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int t; cin >> t; while (t--) { string str; cin >> str; vector s(str.size()), s2(str.size()); for (int i = 0; i < str.size(); i++) { s[i] = str[i] - '0'; } for (int i = 0; i < s.size() - 1; i++) { for (int j = 0; j < s.size() - i - 1; j++) { s2[j] = s[j] + s[j + 1]; if (s2[j] >= 10) { s2[j] = 1 + s2[j] % 10; } } /* cout << i << "回目: "; for (int j = 0; j < s.size() - i - 1; j++) { cout << s[j] << " "; } cout << endl; */ s = s2; } cout << s[0] << endl; } return 0; }