import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static final long MODULO = 1000000007; static long[] kpow; static long countArray(int n, int k, int x) { // Return the number of ways to fill in the array. if (n == 1) { return x == 1 ? 1 : 0; } long rec = countArray(n - 1, k, x) % MODULO; long aux = (kpow[n - 2] - rec) % MODULO; while (aux < 0) aux += MODULO; return aux; } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int x = in.nextInt(); kpow = new long[n]; kpow[0] = 1; for (int i = 1; i < n; i++) { kpow[i] = (kpow[i - 1] * (k - 1)) % MODULO; } long answer = countArray(n, k, x); System.out.println(answer); in.close(); } }