#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 5005;
int d[5005];
long long qpow(long long a, long long n, long long p) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans = ans * a % p;
    n >>= 1;
    a = a * a % p;
  }
  return ans;
}
int C[maxn][maxn];
int main() {
  C[0][0] = 1;
  for (int i = 1; i <= 250; i++) {
    C[i][0] = 1;
    for (int j = 1; j <= 250; j++)
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
  }
  long long n, k;
  cin >> n >> k;
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    long long op = i % 2 == 0 ? 1 : -1;
    ans = (ans +
           op * C[n][i] *
               (qpow((qpow(k, n - i, mod) * qpow(k - 1, i, mod) % mod -
                      qpow(k - 1, n, mod) + mod) %
                         mod,
                     n, mod)) %
               mod +
           mod) %
          mod;
  }
  cout << ans << endl;
}
