#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int t; cin >> t; while (t--) { string a; cin >> a; while (a.size() > 1) { string b = ""; rep(i, a.size() - 1) { int x = a[i] - '0' + a[i + 1] - '0'; if (x >= 10) x = x / 10 + x % 10; b += x + '0'; } swap(a, b); } cout << a << endl; } return 0; }