#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long dx[] = {0, 0, 1, -1};
long long dy[] = {1, -1, 0, -1};
long long m, k, n, res, fact[200005];
set<long long> st1, st2, st;
string s1 = "one", s2 = "zero", s, ch = "";
vector<long long> v;
vector<pair<long long, long long> > vv;
vector<pair<long double, long long> > vvA, vvB;
vector<pair<long long, pair<long long, long long> > > vvv;
priority_queue<long long> pq;
map<long long, pair<long long, long long> > mp;
map<long long, long long> mp1;
long long xa, xb, xc, ya, yb, yc, xres;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long Inverse(long long n, long long MOD) { return power(n, MOD - 2, MOD); }
long long Combinaison(long long n, long long r, long long MOD) {
  if (r > n) return 0;
  if (n < 0) return 0;
  return (fact[n] *
          ((Inverse(fact[r], MOD) * Inverse(fact[n - r], MOD)) % MOD)) %
         MOD;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long i = 0, x, y, j = 0, z = 0, q, nb1 = 0, nb = 0, nbmax = 0, nbinf = 0,
            nb2 = 0, mm = 5e8, idx = 0, ok = 0, l, negatif = 0, positif = 0, l1,
            r1;
  multiset<long long>::iterator it, it1, it2;
  char c;
  long long ans = 0;
  cin >> n >> k;
  m = n * n;
  fact[0] = 1;
  for (i = 1; i <= m + 2; i++) {
    fact[i] = i * fact[i - 1];
    fact[i] += mod;
    fact[i] %= mod;
  }
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= n; j++) {
      long long cnt = n * (i + j) - i * j;
      long long pp = 1;
      if ((i + j) & 1) pp = -1;
      ans += pp * Combinaison(n, i, mod) % mod * Combinaison(n, j, mod) % mod *
             power(k - 1, cnt, mod) % mod * power(k, n * n - cnt, mod) % mod;
      ans += mod;
      ans %= mod;
    }
  }
  cout << ans;
  return 0;
}
