#include <bits/stdc++.h>
using namespace std;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long MAXN = 4e3 + 7;
const long long MAXM = 1e6 + 7;
const long long MOD = 1e9 + 7;
const double eps = 1e-6;
const double pi = acos(-1.0);
long long quick_pow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (1LL * ans * a) % MOD;
    a = (1LL * a * a) % MOD;
    b >>= 1;
  }
  return ans;
}
int c[305][305];
long long ksm1[305], ksm2[305];
int main() {
  long long n, k;
  scanf("%lld%lld", &n, &k);
  c[0][0] = 1;
  c[1][0] = c[1][1] = 1;
  for (int i = 2; i <= n; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++)
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % MOD;
  }
  ksm1[0] = ksm2[0] = 1;
  for (int i = 1; i <= n; i++)
    ksm1[i] = (ksm1[i - 1] * k) % MOD, ksm2[i] = (ksm2[i - 1] * (k - 1)) % MOD;
  long long ans = 0;
  long long t = 1;
  for (int i = 0; i <= n; i++) {
    ans += t * c[n][i] * quick_pow((ksm1[n - i] * ksm2[i] - ksm2[n]) % MOD, n) %
           MOD;
    t *= -1;
    ans %= MOD;
  }
  printf("%lld\n", (ans % MOD + MOD) % MOD);
  return 0;
}
