#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 1e3 + 6;
long long C[N][N], dp[N][N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  C[0][0] = 1;
  for (long long i = 1; i < N; i++) {
    C[i][0] = 1;
    for (long long j = 1; j < i; j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
    C[i][i] = 1;
  }
  long long n, k;
  cin >> n >> k;
  long long A[n + 1], B[n + 1];
  A[0] = B[0] = 1;
  for (long long i = 1; i <= n; i++) A[i] = A[i - 1] * (k - 1) % mod;
  for (long long i = 1; i <= n; i++) B[i] = B[i - 1] * k % mod;
  dp[0][0] = 1;
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j <= n; j++) {
      dp[i][j] = dp[i - 1][j] * A[n - j] % mod * (B[j] - A[j] + mod) % mod;
      for (long long k = 1; k <= j; k++) {
        (dp[i][j] += dp[i - 1][j - k] * A[n - j] % mod * B[j - k] % mod *
                     C[n - j + k][k] % mod) %= mod;
      }
    }
  cout << dp[n][n];
}
