func_code_string: #include <bits/stdc++.h>   using namespace std;   void setIO() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);   }   const long long N = 3e2 + 0;   const long long M = 5e5 + 5;   const long long L = 2e1 + 1;   const long long inf = 9e17;   const long long mod = 1e9 + 7;   long long xyz = 1;   long long n, k;   long long dp[N][N];   long long fac[N];   long long inv[N];   long long chs[N][N];   long long pwr[2][N];   long long bin(long long b, long long e) {     return b == k ? pwr[0][e] : pwr[1][e];   }   long long cal(long long b, long long e) {     if (e == 0) return 1;     if (e == 1) return b;     if (e == 2) return b * b % mod;     return cal(cal(b, e / 2), 2) * cal(b, e % 2) % mod;   }   void prc(long long n, long long k) {     chs[n][k] = fac[n] * inv[k] % mod * inv[n - k] % mod;   }   void cmp(long long b, long long e) {     if (b == k - 0) {       pwr[0][e] = cal(b, e);     }     if (b == k - 1) {       pwr[1][e] = cal(b, e);     }   }   long long ncr(long long n, long long k) { return chs[n][k]; }   void run() {     cin >> n >> k;     fac[0] = 1;     inv[0] = 1;     for (long long i = 1; i <= n; i++) {       fac[i] = fac[i - 1] * i % mod;       inv[i] = inv[i - 1] * cal(i, mod - 2) % mod;     }     for (long long i = 0; i <= n; i++)       for (long long j = 0; j <= i; j++) prc(i, j);     for (long long i = 0; i <= n; i++) cmp(k, i), cmp(k - 1, i);     for (long long i = 1; i <= n; i++)       dp[1][i] = ncr(n, i) * bin(k - 1, n - i) % mod;     for (long long i = 2; i <= n; i++) {       for (long long j = 1; j <= n; j++) {         dp[i][j] = (bin(k, j) - bin(k - 1, j) + mod) * bin(k - 1, n - j) % mod *                    dp[i - 1][j] % mod;         for (long long x = 1; x < j; x++) {           dp[i][j] += bin(k - 1, n - j) * bin(k, x) % mod * ncr(n - x, j - x) %                       mod * dp[i - 1][x] % mod;           dp[i][j] %= mod;         }       }     }     cout << dp[n][n] << endl;   }   signed main() {     setIO();     while (xyz--) run();     return 0;   }   