N,M,Q=map(int, input().split()) A=list(map(int, input().split())) mod=998244353 B=[1];BB=[1] for i in range(N-1): B.append(B[-1]*M%mod) BB.append(BB[-1]*M%mod) B=B[::-1] C=[] for i in range(N): C.append((A[i]-1)*B[i]%mod) D=[0] for c in C: D.append(D[-1]+c) def xgcd(a, b): x0, y0, x1, y1 = 1, 0, 0, 1 while b != 0: q, a, b = a // b, b, a % b x0, x1 = x1, x0 - q * x1 y0, y1 = y1, y0 - q * y1 return a, x0, y0 def modinv(a, m): g, x, y = xgcd(a, m) if g != 1: raise Exception('modular inverse does not exist') else: return x % m for _ in range(Q): l,r=map(int, input().split()) ans=(D[r]-D[l-1])*modinv(BB[N-r],mod)%mod+1 ans%=mod print(ans)