#include <bits/stdc++.h>
using namespace std;
const int maxn = 535;
const long long MOD = 1e9 + 7;
int n;
long long k, inv[maxn], fac[maxn], ifac[maxn], f[maxn][maxn], pow1[maxn],
    pow2[maxn];
void init(int n) {
  fac[0] = ifac[0] = inv[1] = pow1[0] = pow2[0] = 1;
  for (int i = (1); i <= (n); i++) fac[i] = fac[i - 1] * i % MOD;
  for (int i = (2); i <= (n); i++)
    inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
  for (int i = (1); i <= (n); i++) ifac[i] = ifac[i - 1] * inv[i] % MOD;
  for (int i = (1); i <= (n); i++)
    pow1[i] = pow1[i - 1] * k % MOD, pow2[i] = pow2[i - 1] * (k - 1) % MOD;
}
long long qpow(long long a, long long b) {
  long long ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % MOD;
    a = a * a % MOD, b >>= 1;
  }
  return ret;
}
inline long long C(long long a, long long b) {
  return fac[a] * ifac[b] % MOD * ifac[a - b] % MOD;
}
int main() {
  scanf("%d%I64d", &n, &k);
  init(n + 6);
  f[0][0] = 1;
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (n); j++) {
      for (int j0 = (0); j0 <= (j - 1); j0++) {
        long long tmp = f[i - 1][j0] * C(n - j0, j - j0) % MOD;
        tmp = tmp * pow2[n - j] % MOD * pow1[j0] % MOD;
        ((f[i][j]) = ((f[i][j]) + (tmp)) % MOD);
      }
      ((f[i][j]) = ((f[i][j]) + ((pow1[j] - pow2[j] + MOD) % MOD * pow2[n - j] %
                                 MOD * f[i - 1][j] % MOD)) %
                   MOD);
    }
  printf("%I64d\n", f[n][n]);
  return 0;
}
