#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
namespace mymath {
long long power(long long a, long long p, long long mod) {
  long long res = 1;
  while (p) {
    if (p & 1) {
      res *= a;
      res %= mod;
    }
    p >>= 1;
    a *= a;
    a %= mod;
  }
  return res;
}
long long inverse(long long a, long long M) { return power(a, M - 2, M); }
}  // namespace mymath
int main() {
  int n, k;
  cin >> n >> k;
  long long NCR[n + 1][n + 1];
  for (int i = 0; i <= n; ++i) {
    NCR[0][i] = 0;
    NCR[i][0] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      NCR[i][j] = NCR[i - 1][j] + NCR[i - 1][j - 1];
      NCR[i][j] %= MOD;
    }
  }
  long long ans = 0;
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) {
      long long cur = (NCR[n][i] * NCR[n][j]) % MOD;
      int a = n * (i + j) - i * j;
      cur *= mymath::power(k - 1, a, MOD);
      cur %= MOD;
      cur *= mymath::power(k, n * n - a, MOD);
      if ((i + j) % 2) {
        cur *= -1;
      }
      ans += cur;
      ans %= MOD;
    }
  }
  if (ans < 0) ans += MOD;
  cout << ans << "\n";
}
