#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
constexpr int ms = 253;
constexpr long long MOD = 1000000007LL;
vector<long long> fat, inv_fat;
long long n_choose_k(long long n, long long k) {
  long long mult = (inv_fat[k] * inv_fat[n - k]) % MOD;
  return (fat[n] * mult) % MOD;
}
long long powmod(long long a, long long b, long long mod = MOD) {
  long long res = 1LL;
  a %= mod;
  long long mult = a;
  while (b > 0) {
    if (b & 1) res = (res * mult) % mod;
    mult = (mult * mult) % mod;
    b /= 2;
  }
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  fat.assign(1000, 1);
  inv_fat.assign(1000, 1);
  for (int i = 2; i < 1000; ++i) {
    fat[i] = (fat[i - 1] * i) % MOD;
    inv_fat[i] = powmod(fat[i], MOD - 2);
  }
  long long n, k;
  cin >> n >> k;
  long long ans = 0;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      int livre = (n - i) * (n - j);
      long long cur = (powmod(k, livre) * powmod(k - 1, n * n - livre)) % MOD;
      cur = (cur * n_choose_k(n, i)) % MOD;
      cur = (cur * n_choose_k(n, j)) % MOD;
      if ((i + j) & 1)
        ans = (ans + MOD - cur) % MOD;
      else
        ans = (ans + cur) % MOD;
    }
  }
  cout << ans << '\n';
}
