
명령을 일단 리스트로 입력받자.
그리고 리스트의 0번 인덱스의 값이 1이라면 속력을 입력받은 값만큼 올려주고, 2라면 빼주면 된다.
이때 감속을 해서 속도가 0보다 작아지는 경우는 0으로 설정해준다.
T = int(input())
for tc in range(1, T+1):
distance = 0
speed = 0
N = int(input())
for _ in range(N):
command = list(input().split())
if int(command[0]) == 1:
speed += int(command[1])
elif int(command[0]) == 2:
speed -= int(command[1])
if speed < 0:
speed = 0
distance += speed
print(f'#{tc} {distance}')
