#include <bits/stdc++.h>
using namespace std;
long long modexp(long long x, long long n) {
  if (n == 0) return 1;
  if (n == 1) return x % 1000000007;
  long long y = modexp(x, n / 2);
  if (n % 2 == 0)
    return (y * y) % 1000000007;
  else
    return (((y * y) % 1000000007) * x) % 1000000007;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k, i, j, ans = 0, m, r, x, c;
  cin >> n >> k;
  long long dp[n + 1];
  dp[0] = 1;
  for (j = 1; j <= n; ++j)
    dp[j] =
        ((((n - j + 1) * dp[j - 1]) % 1000000007) * modexp(j, 1000000007 - 2)) %
        1000000007;
  for (m = 0; m <= n; ++m) {
    for (r = 0; r <= n; ++r) {
      x = (dp[m] * dp[r]) % 1000000007;
      x *= modexp(k - 1, n * m + n * r - m * r);
      x %= 1000000007;
      x *= modexp(k, n * n - n * m - n * r + m * r);
      x %= 1000000007;
      if ((m + r) % 2 == 0)
        ans = (ans + x) % 1000000007;
      else
        ans = (ans - x + 1000000007) % 1000000007;
    }
  }
  cout << ans;
  return 0;
}
