#!/bin/python import sys def countArray(n, k, x): # Return the number of ways to fill in the array. ways=0 n=n-1 while(n>2): ways = ways + (k-1) n = n-1 ways = ways + k-2 return int(ways % (10e9 + 7)) if __name__ == "__main__": n, k, x = raw_input().strip().split(' ') n, k, x = [int(n), int(k), int(x)] answer = countArray(n, k, x) print answer