J=lambda:map(int,input().split()) for q in range(sum(J())):t,*a=J();print([sum(a),q+1][t-1])