n,m,q=map(int,input().split()) a=list(map(int,input().split())) for i in range(n): a[i]-=1 M=998244353 B=m P=[1,B] R=[1,pow(B,M-2,M)] for i in range(2,n): P+=[P[-1]*P[1]%M] R+=[R[-1]*R[1]%M] h=[0]*(n+1) for i in reversed(range(n)): h[i]=(a[i]*P[n-1-i]+h[i+1])%M for i in range(q): l,r=map(int,input().split()) l-=1 r-=1 print(((h[l]-h[r+1])*R[n-1-r]+1)%M)