from sys import stdin, setrecursionlimit input = stdin.readline readline = stdin.readline N,M=map(int, input().split()) B=[] for i in range(N): a,b=map(int, input().split()) B.append((a,b)) Q,X=map(int, input().split()) A=list(map(int, input().split())) from collections import deque def ff(x,mid): p,q=B[x] if mid<=p: l=0 elif q==0: if mid>p: l=M else: l=min(M,(mid-p)//q+1) r=M-l ls=(p+p+q*(l-1))*l//2 rs=(p+p+q*(M-1))*M//2-ls return abs(l*mid-ls)+abs(r*mid-rs) def f(x,y): ok=0;ng=10**9+1 p,q=B[x];pp,qq=B[y] while abs(ok-ng)>1: mid=(ok+ng)//2 acum=ff(x,mid) bcum=ff(y,mid) if acum<=bcum: ok=mid else: ng=mid return ok d=deque() for i in range(N): a,b=B[i] if len(d)<2: d.append(i) else: while len(d)>1: x,y=d[-2],d[-1] k=f(y,i) if ff(x,k)<=ff(y,k): d.pop() else: break d.append(i) #print(d) C=list(d) now=0 def ff(x,mid): p,q=B[x] if mid<=p: l=0 elif q==0: if mid>p: l=M else: l=min(M,(mid-p)//q+1) r=M-l ls=(p+p+q*(l-1))*l//2 rs=(p+p+q*(M-1))*M//2-ls return abs(l*mid-ls)+abs(r*mid-rs) ans=[] for i in range(Q): if i==0: x=X if now+1==N: ans.append(C[now]+1) else: D=[] s=now for i in range(s,len(C)): p=C[i] D.append(ff(p,x)) if len(D)>1 and D[-2]1 and D[-2]>D[-1]: now=i ans.append(C[now]+1) x+=A[C[now]] print(*ans)