/* package codechef; // don’t place package name! */
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
List arr = new ArrayList<>();
Scanner sc = new Scanner(System.in);
Long t = sc.nextLong();
for(int i=0;i<=t;i++){
int z = 0;
String s = sc.nextLine();
char[] n = s.toCharArray();
for(int j=0;j<n.length;j++){
int x = Integer.parseInt(String.valueOf(n[j]));
// System.out.println("x value:"+x);
z=z+x;
// System.out.println("z value:"+z);
}
// System.out.println(z);
arr.add(z);
}
arr.remove(0);
arr.forEach(System.out::println);
}
}