#include #define M 1000000007 using namespace std; long countArray(int n, int k, int x) { // Return the number of ways to fill in the array. long long temp = ((k-1)%M * (k-2)%M)%M; temp = (temp%M * (n-3)%M)%M; return (temp+1)%M; } int main() { int n; int k; int x; cin >> n >> k >> x; long answer = countArray(n, k, x); cout << answer << endl; return 0; }