#include <bits/stdc++.h>
using namespace std;
long long mpow(long long x, long long n) {
  long long r = 1;
  for (; n > 0; x = x * x % 1000000007, n >>= 1)
    if (n & 1) r = r * x % 1000000007;
  return r;
}
int main(int argc, char *argv[]) {
  long long n, k;
  cin >> n >> k;
  vector<vector<long long> > C(n + 1, vector<long long>(n + 1));
  for (int i = 0; i < C.size(); i++) {
    C[i][i] = C[i][0] = 1;
    for (int j = 1; j <= i / 2; j++)
      C[i][j] = C[i][i - j] = (C[i - 1][j] + C[i - 1][j - 1]) % 1000000007;
  }
  vector<vector<long long> > dp(n + 1, vector<long long>(n + 1));
  for (int r = 1; r <= n; r++)
    dp[r][0] = mpow((mpow(k, n) - mpow(k - 1, n) + 1000000007) % 1000000007, r);
  for (int c = 1; c <= n; c++) dp[1][c] = mpow(k, n - c);
  for (int r = 2; r <= n; r++)
    for (int c = 1; c <= n; c++) {
      long long t = 0;
      for (int i = 1; i <= c; i++)
        t = (t + C[c][i] * mpow(k - 1, c - i) % 1000000007 * dp[r - 1][c - i] %
                     1000000007) %
            1000000007;
      t = t * mpow(k, n - c) % 1000000007;
      dp[r][c] = ((mpow(k, n - c) - mpow(k - 1, n - c) + 1000000007) %
                      1000000007 * mpow(k - 1, c) % 1000000007 * dp[r - 1][c] +
                  t) %
                 1000000007;
    }
  cout << dp[n][n] << endl;
  return 0;
}
