#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int N,M,Q; using P = pair; P op(P a,P b){ swap(a,b); a.first += b.first * mint(M).pow(a.second); a.second += b.second; return a; } P e(){ return make_pair(0,0); } int main(){ cin>>N>>M>>Q; segtree seg(N); rep(i,N){ int a; cin>>a; a--; seg.set(i,make_pair(mint(a),1)); } rep(i,Q){ int l,r; cin>>l>>r; cout<<(seg.prod(l-1,r).first+1).val()<