import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static BigInteger countArray(int n, int k, int x) { // Return the number of ways to fill in the array. BigInteger rs ; long s = (long) (Math.pow(10, 9)+7); BigInteger m = new BigInteger(String.valueOf(s)); BigInteger two = new BigInteger(String.valueOf("2")); BigInteger bn = new BigInteger(String.valueOf(n)); BigInteger bk = new BigInteger(String.valueOf(k)); BigInteger bx = new BigInteger(String.valueOf(x)); if(n ==3 ) { rs = bk.subtract(two); }else if( n== 4) { rs = bk.subtract(BigInteger.ONE).add(bk.subtract(two).pow(2)); } else { BigInteger t = (bn.subtract(new BigInteger(String.valueOf("4")))).multiply(bk.subtract(BigInteger.ONE)); rs = t.multiply(bk.subtract(BigInteger.ONE).add(bk.subtract(two).pow(2))); } return rs.mod(m); } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int x = in.nextInt(); BigInteger answer = countArray(n, k, x); System.out.println(answer); in.close(); } }