T = int(input())
# 여러개의 테스트 케이스가 주어지므로, 각각을 처리합니다.
for test_case in range(1, T + 1):
num_of_command = int(input())
command_and_speed = []
for command in range(0, num_of_command):
command = list(map(int, input().split()))
command_and_speed.append(command)
distance = 0
current_speed = 0
for c in command_and_speed:
current_command = c[0]
if current_command == 1 :
current_speed += c[1]
distance += current_speed
elif current_command == 2 :
current_speed -= c[1]
distance += current_speed
else :
distance += current_speed
print("#%d %d" % (test_case, distance))
49분
현재로써는 레벨 2의 10문제만 목표는 1시간 안에 풀기, 이후에는 30분 안에 풀 수 있도록 하기