import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String args[]) { Scanner cin=new Scanner(System.in); int t; t=cin.nextInt(); for(int i=1;i<=t;i++) { BigInteger a,s,b; s=BigInteger.valueOf(0); b=BigInteger.valueOf(0); while(cin.hasNextBigInteger()) { a=cin.nextBigInteger(); if(a.compareTo(b)==0) break; s=s.add(a); } System.out.println(s); if(i!=t) { System.out.println(); } } } }