#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
void mul(int &a, int b) { a = (long long)a * b % MOD; }
void pls(int &a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
void mns(int &a, int b) {
  a += MOD - b;
  if (a >= MOD) a -= MOD;
}
int pw(int a, int b) {
  int ans = 1;
  for (int aa = a; b; b /= 2, mul(aa, aa))
    if (b & 1) mul(ans, aa);
  return ans;
}
int m[300];
int ncr[300];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  if (K == 1) {
    cout << "1";
    return 0;
  }
  m[N + 1] = 1;
  for (int i = N; i > 0; i--) m[i] = (long long)m[i + 1] * i % MOD;
  int f = 1;
  for (int i = 1; i <= N; i++) mul(f, i);
  int fi = pw(f, MOD - 2);
  for (int i = 0; i <= N; i++)
    ncr[i] = (long long)m[i + 1] * m[N - i + 1] % MOD * fi % MOD;
  int x = (long long)K * pw(K - 1, MOD - 2) % MOD;
  int y = 1;
  int ans = 0;
  for (int i = 0; i <= N; i++) {
    int t = (long long)ncr[i] * pw(MOD + 1 - y, N) % MOD;
    if (i & 1)
      mns(ans, t);
    else
      pls(ans, t);
    mul(y, x);
  }
  mul(ans, pw(K - 1, N * N));
  cout << ans;
  return 0;
}
