#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 5;
const long long mod = 1e9 + 7;
long long fact[MAXN];
long long invfact[MAXN];
bool sieve[MAXN];
long long powe(long long x, long long y, long long mod) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
void makesieve() {
  for (long long i = 0; i < MAXN; ++i) {
    sieve[i] = 1;
  }
  sieve[0] = 0;
  sieve[1] = 0;
  for (long long i = 2; i * i <= MAXN; ++i) {
    for (long long j = 2 * i; j < MAXN; j += i) {
      sieve[j] = 0;
    }
  }
}
void pre() {
  fact[0] = 1;
  invfact[0] = 1;
  for (long long i = 1; i < MAXN; ++i) {
    fact[i] = (fact[i - 1] * i) % mod;
    invfact[i] = powe(fact[i], mod - 2, mod);
  }
  makesieve();
}
long long comb(long long n, long long r) {
  if (r == 0 || n == r) return 1;
  if (r > n) return 0;
  long long A = (fact[n] * invfact[r]) % mod;
  return (A * invfact[n - r]) % mod;
}
long long gcde(long long a, long long b) {
  if (a == 0) return b;
  return gcde(b % a, a);
}
long long gcdExtended(long long a, long long b, long long *x, long long *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long modInverse(long long a, long long m) {
  long long x, y;
  long long g = gcdExtended(a, m, &x, &y);
  return (x % m + m) % m;
}
bool ifcontains(string str, string smlstr) {
  if (str.length() < smlstr.length()) return false;
  for (long long i = 0; i < str.length(); ++i) {
    bool fg = 0;
    for (long long j = 0; j < smlstr.length(); ++j) {
      if (i + j >= str.length()) {
        fg = 1;
        break;
      }
      if (smlstr[j] != str[i + j]) {
        fg = 1;
        break;
      }
    }
    if (!fg) return true;
  }
  return false;
}
int main() {
  pre();
  long long n, k;
  cin >> n >> k;
  long long ans = 0;
  for (long long i = 0; i <= n; ++i) {
    for (long long j = 0; j <= n; ++j) {
      long long sign;
      if ((i + j) % 2 == 0)
        sign = 1;
      else
        sign = -1;
      long long total_cells = (i + j) * n - i * j;
      long long rest_cells = n * n - total_cells;
      long long temp =
          (powe(k - 1, total_cells, mod) * powe(k, rest_cells, mod)) % mod *
          sign;
      temp = (temp + mod) % mod;
      temp *= (comb(n, i) * comb(n, j)) % mod;
      temp %= mod;
      ans += temp;
      ans %= mod;
    }
  }
  cout << ans << "\n";
  return 0;
}
