#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const long long mod = 1e9 + 7;
const long long N = 2e5 + 5, K = 105;
const int si = (1 << 20);
const long long add = 1e4;
const long long M = 100 + 5;
const double INFdb = 1e10;
long long n, k;
long long C[300][300];
long long PowMod(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
void init() {
  for (int i = 0; i < 300; ++i) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; ++j) {
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(0);
  init();
  cin >> n >> k;
  long long ans = 0;
  long long dir = 1;
  for (int i = 0; i <= n; ++i) {
    long long ways = C[n][i] * PowMod(PowMod(k - 1, n), i) % mod *
                     PowMod((PowMod(k, n - i) - PowMod(k - 1, n - i)), n) %
                     mod * dir;
    ans = (ans + ways) % mod;
    dir *= (-1);
  }
  cout << (ans % mod + mod) % mod;
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
