N=int(input()) while True: l=[int(i) for i in input().split()[1:]] if not l: break print(sum(l)) print()