#include <bits/stdc++.h>
using namespace std;
const int N = 500 + 10;
const int MOD = 1000 * 1000 * 1000 + 7;
int n, k;
long long C[N][N], dp[N];
long long power(int a, int b);
void PrePros() {
  for (int i = 0; i < N; i++) C[i][0] = 1;
  for (int i = 1; i < N; i++)
    for (int j = 1; j <= i; j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
  for (int i = 1; i <= n; i++) {
    dp[i] = (power(k, i) - power(k - 1, i)) % MOD;
    dp[i] = power(dp[i], n);
  }
  return;
}
void solve() {
  long long tmp;
  for (int i = 2; i <= n; i++)
    for (int j = 1; j < i; j++) {
      tmp = (((C[i][j] * dp[j]) % MOD) * power(k - 1, n * (i - j))) % MOD;
      dp[i] = (dp[i] - tmp) % MOD;
    }
  return;
}
int main() {
  cin >> n >> k;
  PrePros();
  solve();
  cout << (dp[n] + MOD) % MOD << endl;
  return 0;
}
long long power(int a, int b) {
  if (!b) return 1;
  long long keep = power(a, b / 2);
  keep = (keep * keep) % MOD;
  if (b % 2) return (keep * a) % MOD;
  return keep;
}
