import java.io.*; import java.util.StringTokenizer; public class A { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(), k = sc.nextInt(), x = sc.nextInt() - 1; int MOD = 1000_000_007; long[][] dp = new long[n][2]; if (x == 0) dp[0][1] = 1; else dp[0][0] = 1; for (int i = 1; i < n - 1; i++) { dp[i][1] = dp[i - 1][0]; dp[i][0] = (dp[i - 1][0] * (k - 2) % MOD) + (dp[i - 1][1] * (k - 1) % MOD); if (dp[i][0] >= MOD) dp[i][0] -= MOD; } out.println(dp[n - 2][0]); out.flush(); out.close(); } static class Scanner { StringTokenizer st; BufferedReader br; public Scanner(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); } public Scanner(FileReader s) throws FileNotFoundException { br = new BufferedReader(s); } public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public String nextLine() throws IOException { return br.readLine(); } public double nextDouble() throws IOException { return Double.parseDouble(next()); } public boolean ready() throws IOException { return br.ready(); } } }