#include
#include
int count_fun(int n)
{
int count = 1;
while(n>=10)
{
count++;
n=n/10;
}
return count;
}
int main(int argc, char *argv[])
{
int n,i,sum = 0;
scanf("%d",&n);
int *arr = (int *)malloc(sizeof(int)*n);
for(i = 0; i < n; i++)
{
scanf("%d",&arr[i]);
}
for(i = 0; i < n; i++)
{
switch(count_fun(arr[i]))
{
case 1:
sum += arr[i];
break;
case 2:
sum = arr[i]/10 + arr[i]%10;
break;
case 3:
sum = arr[i]/100 + arr[i]%100/10 + arr[i]%10;
break;
case 4:
sum = arr[i]/1000 + arr[i]%1000/100
+ arr[i]%1000%100/10 + arr[i]%10;
break;
}
printf("%d\n",sum);
}
return 0;
}