满分答案:
r,y,g = input().split()
r,y,g = int(r),int(y),int(g)
n = int(input())
light = [[0 for i in range(2)] for j in range(n)]
time = 0
for i in range(n):
light[i] = input().split()
if int(light[i][0]) == 0 or int(light[i][0]) == 1:
time = time + int(light[i][1])
elif int(light[i][0]) == 2:
time = time + int(light[i][1]) + r
elif int(light[i][0]) == 3:
pass
print(time)