#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 303;
const ll mod = 1e9 + 7;
ll C[N][N];
ll pot[N];
ll fexp(ll b, ll e = mod - 2) {
  ll ans = 1;
  while (e) {
    if (e & 1) ans = ans * b % mod;
    b = b * b % mod;
    e /= 2;
  }
  return ans;
}
int n, k;
int main() {
  for (int i = 0; i < N; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++) {
      C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
      if (C[i][j] >= mod) C[i][j] -= mod;
    }
  }
  scanf("%d %d", &n, &k);
  pot[0] = 1;
  for (int i = 1; i < N; i++) pot[i] = (k - 1) * pot[i - 1] % mod;
  ll ans = 0;
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) {
      ll tmp = C[n][i] * C[n][j] % mod;
      tmp = tmp * fexp(k - 1, n * i) % mod;
      tmp = tmp * fexp(k - 1, j * (n - i)) % mod;
      tmp = tmp * fexp(k, n * n - n * i - j * (n - i)) % mod;
      if ((i + j) % 2 == 0)
        ans += tmp;
      else
        ans -= tmp;
      if (ans >= mod) ans -= mod;
      if (ans < 0) ans += mod;
    }
  printf("%lld\n", ans % mod);
}
