#include <bits/stdc++.h>
using namespace std;
const int N = 600;
const long long MOD2 = 998244353;
const long long MOD = 1e9 + 7;
long long dp[N][N], p[N], pm[N], c[N][N];
bool col[N][N];
long long k, n;
inline long long rec(int a, int b) {
  if (a == 0 && b == 0) return 1;
  if (a == 0) return 0;
  if (col[a][b]) return dp[a][b];
  long long ans = 0;
  for (int i = (1); i <= (b); ++i) {
    long long tv = (c[b][i] * pm[b - i]) % MOD;
    tv = (tv * p[n - b]) % MOD;
    tv = (tv * rec(a - 1, b - i)) % MOD;
    ans = (ans + tv) % MOD;
  }
  long long tv = (p[n - b] - pm[n - b] + MOD) % MOD;
  tv = (tv * pm[b]) % MOD;
  tv = (tv * rec(a - 1, b)) % MOD;
  ans = (ans + tv) % MOD;
  ;
  col[a][b] = true;
  return dp[a][b] = ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> k;
  p[0] = 1;
  pm[0] = 1;
  for (int i = (1); i <= (n + 20); ++i) {
    p[i] = (p[i - 1] * k) % MOD;
    p[i] %= MOD;
    pm[i] = (pm[i - 1] * (k - 1ll)) % MOD;
    pm[i] %= MOD;
  }
  for (int i = (0); i <= (2 * n); ++i) {
    c[i][0] = 1;
  }
  for (int i = (1); i <= (2 * n); ++i) {
    for (int j = (1); j <= (i); ++j) {
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD;
      c[i][j] %= MOD;
    }
  }
  cout << rec(n, n) << endl;
  return 0;
}
