N, M, Q = map(int, input().split()) A = list(map(int, input().split())) LR = [list(map(int, input().split())) for _ in range(Q)] MOD = 998244353 B = [] for i in range(N): B.append(A[i]-1) POW = [1] POW_inv = [1] for _ in range(N): POW.append(POW[-1]*M%MOD) POW_inv.append(pow(POW[-1], -1, MOD)) for i in reversed(range(N)): B[i] *= POW[N-1-i] B[i] %= MOD cum = [0] for i in range(N): cum.append((cum[-1]+B[i])%MOD) for L, R in LR: L -= 1 q = (cum[R]-cum[L])%MOD ans = q*POW_inv[N-R]%MOD print((ans+1)%MOD)