import sys input = sys.stdin.readline from functools import lru_cache K,N,M=map(int,input().split()) A=list(map(int,input().split())) C=list(map(int,input().split())) mod=10**9+7 for i in range(N): sc=0 for j in range(K): sc+=C[j]*A[-1-j] sc%=mod A.append(sc) @lru_cache(maxsize=None) def calc_l(x): ANS=A[x] for i in range(1,K): if x-i>=0: ANS=(ANS-A[x-i]*C[i-1])%mod return ANS @lru_cache(maxsize=None) def calc_r(stind,x): #print((stind,x),A[stind]) ANS=0 for i in range(x,K): if stind+x-i>=0: ANS=(ANS-A[stind+x-i]*C[i])%mod return ANS S=[0]*N for i in range(M): l,r=map(int,input().split()) for j in range(K): if l+j=0: ANS[i]=(ANS[i]+ANS[i-j-1]*C[j])%mod for ans in ANS: print(ans)