MOD = 998244353 N, M, Q = map(int, input().split()) A = list(map(int, input().split())) for _ in range(Q): L, R = map(int, input().split()) ans = 0 for i in range(L-1, R): ans *= M a = A[i]-1 ans += a ans %= MOD print((ans+1)% MOD)