#include <bits/stdc++.h>
using namespace std;
int MOD = 1000000007;
int comb[445][445];
int dp[445][445];
int pow(int a, int b, int m) {
  a %= m;
  int r = 1;
  while (b) {
    if (b & 1) r = (1LL * r * a) % m;
    a = (1LL * a * a) % m;
    b >>= 1;
  }
  return r;
}
int powK[445];
int powK1[445];
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  comb[0][0] = 1;
  for (int i = 1; i <= 333; i++) {
    comb[i][0] = 1;
    for (int j = 0; j < i; j++)
      comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % MOD;
    comb[i][i] = 1;
  }
  int n, k;
  cin >> n >> k;
  for (int i = 0; i <= n; i++) powK[i] = pow(k, i, MOD);
  for (int i = 0; i <= n; i++) powK1[i] = pow(k - 1, i, MOD);
  for (int i = 1; i <= n; i++) {
    dp[1][i] = (1LL * comb[n][i] * (pow(k - 1, n - i, MOD))) % MOD;
  }
  for (int i = 2; i <= n; i++) {
    for (int q = 1; q <= n; q++) {
      for (int p = 1; p <= q; p++) {
        int a = powK[p] % MOD;
        int d = powK1[p];
        if (p == q) a = (a - d + MOD) % MOD;
        int b = comb[n - p][q - p];
        int c = powK1[n - q];
        int t = a;
        t = (1LL * t * b) % MOD;
        t = (1LL * t * c) % MOD;
        dp[i][q] = (dp[i][q] + 1LL * t * dp[i - 1][p]) % MOD;
      }
    }
  }
  cout << dp[n][n] << endl;
  return 0;
}
