#include<iostream>
using namespace std;
// Get first number
int first_number(int n)
{
while (n > 9)
{
n /= 10;
}
return n;
}
// Get last number
int last_number(int n)
{
return n %= 10;
}
int main()
{
int t, n, sum;
cin >> t;
for (int i = 0; i < t; i++)
{
cin >> n;
sum = 0;
sum = first_number(n) + last_number(n);
cout << sum << "
";
}
return 0;
}