import java.math.BigInteger;
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while(n-->0){
BigInteger sum = BigInteger.ZERO;
while(sc.hasNext()){
String str = sc.next();
if ("0".equals(str)) {
break;
}
sum = sum.add(new BigInteger(str));
}
System.out.println(sum);
if (n!=0) {
System.out.println();
}
}
sc.close();
}
}