import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { static final int MOD = 998244353; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int m = sc.nextInt(); int q = sc.nextInt(); long[] sums = new long[n + 1]; for (int i = 1; i <= n; i++) { sums[i] = (sums[i - 1] + (sc.nextInt() - 1) * pow(m, n - i) % MOD) % MOD; } String result = IntStream.range(0, q).mapToObj(a -> { int left = sc.nextInt(); int right = sc.nextInt(); return String.valueOf(((sums[right] + MOD - sums[left - 1]) % MOD * pow(pow(m, n - right), MOD - 2) + 1) % MOD); }).collect(Collectors.joining("\n")); System.out.println(result); } static long pow(long x, int p) { if (p == 0) { return 1; } else if (p % 2 == 0) { return pow(x * x % MOD, p / 2); } else { return pow(x, p - 1) * x % MOD; } } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }