#include <bits/stdc++.h>
using namespace std;
long long pow(long long a, long long b) {
  if (b == 0) return 1;
  if (b & 1) {
    long long tt = pow(a, b >> 1);
    tt = (tt * tt) % 1000000007ll;
    tt *= a;
    tt %= 1000000007ll;
    return tt;
  }
  long long tt = pow(a, b >> 1);
  return ((tt * tt) % 1000000007ll);
}
vector<vector<long long>> cnk;
int32_t main() {
  long long n, r, k;
  cin >> n >> k;
  if (k == 1) {
    cout << 1;
    return 0;
  }
  cnk.resize(n + 1, vector<long long>(n + 1));
  for (long long i = 0; i <= n; i++) {
    cnk[i][1] = i;
  }
  for (long long i = 2; i <= n; i++) {
    for (long long j = 2; j <= i; j++) {
      cnk[i][j] = (cnk[i - 1][j] + cnk[i - 1][j - 1]);
      if (cnk[i][j] >= 1000000007ll) cnk[i][j] -= 1000000007ll;
    }
  }
  vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, 1));
  vector<long long> pp(n + 1);
  pp[0] = 1;
  for (long long i = 1; i <= n; i++) {
    pp[i] = pp[i - 1] * k;
    pp[i] %= 1000000007ll;
  }
  vector<long long> pp2(n * n + 1);
  pp2[0] = 1;
  for (long long i = 1; i <= n * n; i++) {
    pp2[i] = pp2[i - 1] * (k - 1);
    pp2[i] %= 1000000007ll;
  }
  for (long long i = 2; i <= n; i++) {
    for (long long j = 2; j <= n; j++) {
      long long t1 = pp[i], t2 = pp2[i];
      t1 -= t2;
      t1 %= 1000000007ll;
      dp[i][j] = (dp[i][j - 1] * t1) % 1000000007ll;
      for (long long ttt = 1; ttt < i; ttt++) {
        long long add = dp[i - ttt][j - 1];
        add *= cnk[i][ttt];
        add %= 1000000007ll;
        add *= pp[i - ttt];
        add %= 1000000007ll;
        add *= pp2[(j - 1) * ttt];
        add %= 1000000007ll;
        dp[i][j] += add;
        dp[i][j] %= 1000000007ll;
      }
    }
  }
  while (dp[n][n] < 0) dp[n][n] += 1000000007ll;
  cout << dp[n][n];
  return 0;
}
