import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static long countArray(int n, int k, int x) { long count = 0; if (n > 4) { for (int i = 0; i < n - 3; i++) { if (i == 0) count = 1; count = count * (k - 1); } } // When n-3 is same as x :(n-1) long c2 = k - 1; // When n-3 is different from x:(n-1) c2 = c2 + (k - 2) * (k - 2); count = count + c2; if (count > Math.pow(10, 9)) return (long) (count % Math.pow(10, 9) + 7); return count; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int x = in.nextInt(); long answer = countArray(n, k, x); System.out.println(answer); in.close(); } }