from itertools import accumulate MOD = 998244353 N, M, Q = map(int, input().split()) A = list(map(lambda x: int(x) - 1, input().split())) culc_A = [(a * pow(M, N-i, MOD)) % MOD for i, a in enumerate(A, start=1)] cum_culc_A = [0] + list(map(lambda x: x % MOD, accumulate(culc_A))) for _ in range(Q): l, r = map(int, input().split()) ans = (cum_culc_A[r] - cum_culc_A[l-1]) * pow(M, (N-r)*(MOD-2), MOD) + 1 ans %= MOD print(ans)