#include #include using namespace std; const long D = 1e9+7; const long MaxK = 100001; int N; int K; int X; array V; //array V1; long Y, U; long countArray() { V.fill(0); Y = 0; U = 1; // for( int j = 2; j <= K; ++j ) // V[j]++; for( int i = 1; i < N - 2; ++i ) { long s = Y + U * (K - 1); s %= D; Y = s - Y; if( Y < 0 ) Y += D; Y %= D; U = s - U; if( U < 0 ) U += D; U %= D; /* long s = 0; for( int j = 1; j <= K; ++j ) { s += V[j]; while( s >= D ) s -= D; } for( int j = 1; j <= K; ++j ) { V[j] = s - V[j]; if( V[j] < 0 ) V[j] += D; while( V[j] >= D ) V[j] -= D; }*/ } /* long ww = 0; // V1.fill(0); for( int j = 1; j <= K; ++j ) { if( j != X ) { ww += V[j]; ww %= D; } } */ long s = Y + U * (K - 1); if( X == 1 ) s -= Y; else s -= U; if( s < 0) s += D; s %= D; return s; } int main() { cin >> N >> K >> X; long answer = countArray(); cout << answer << endl; return 0; }