#include using namespace std; int a[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; int Q; string s; int main() { cin >> Q; while(Q--) { cin >> s; while(s.size() > 1) { string t; for(int i = 1; i < s.size(); i++) t += a[(s[i] - 48) + (s[i - 1] - 48)] + 48; s = t; } cout << s << endl; } }