mod = 998244353 N, M, Q = map(int, input().split()) A = list(map(int, input().split())) for i in range(N): A[i] -= 1 sums = [0 for _ in range(N + 1)] for i in range(N): sums[i + 1] = (sums[i] * M + A[i]) % mod pow_m = [1 for _ in range(N + 1)] for i in range(N): pow_m[i + 1] = (pow_m[i] * M) % mod for i in range(Q): l, r = map(int, input().split()) ans = (sums[r] - sums[l - 1] * pow_m[r - l + 1]) % mod print((ans + 1) % mod)