Given are integer sequences $A=(a_1,a_2,…,a_N)$, $T=(t_1,t_2,…,t_N)$, and $X=(x_1,x_2,…,x_Q)$. Let us define $N$ functions $f_1(x),f_2(x),…,f_N(x)$ as follows:
n = int(input()) low, high, add = -10 ** 18, 10 ** 18, 0 for _ inrange(n): a, t = map(int, input().split()) if t == 1: low += a high += a add += a elif t == 2: low = max(low, a) high = max(high, a) elif t == 3: low = min(low, a) high = min(high, a) q = int(input()) s = input() list = [int(_) for _ in s.split()] for x inlist: print(min(high, max(low, x + add)))