#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
const long long mod = (long long)1e9 + 7;
const double eps = (double)1e-9;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
const int N = (int)1000;
long long n, c[N][N], dp[N][N], K[N], k[N];
;
long long bp(long long x, long long y) {
  long long z = 1;
  while (y) {
    if (y & 1) z = z * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return z;
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n >> k[1];
  K[1] = k[1] - 1;
  K[0] = 1;
  k[0] = 1;
  for (int i = 2; i <= n; ++i)
    k[i] = k[i - 1] * k[1] % mod, K[i] = K[i - 1] * K[1] % mod;
  for (int i = 0; i <= n; ++i) {
    c[i][i] = c[i][0] = 1;
    for (int j = 1; j < i; ++j) c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int x = 0; x <= n; ++x) {
      for (int y = x + 1; y <= n; ++y) {
        dp[i][y] = (dp[i][y] + dp[i - 1][x] * k[x] % mod * c[n - x][n - y] %
                                   mod * K[n - y] % mod) %
                   mod;
      }
      dp[i][x] = (dp[i][x] +
                  dp[i - 1][x] * (k[x] - K[x] + mod) % mod * K[n - x] % mod) %
                 mod;
    }
  }
  cout << dp[n][n];
  return 0;
}
