#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int N = 1e3 + 5;
int n, h;
long long d[N][N];
long long p[N], p1[N], inv[N];
long long cal(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = res * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return res;
}
long long C[N][N];
void gao() {
  for (int i = 1; i <= n; i++) {
    C[i][1] = 1ll * i;
    long long x = 1ll * i - 1;
    long long y = 2;
    for (int j = 2; j <= i; j++) {
      C[i][j] = C[i][j - 1] * x % mod * inv[y] % mod;
      x--;
      y++;
    }
  }
}
int main() {
  std::ios::sync_with_stdio(0);
  cin >> n >> h;
  for (int i = 0; i <= n; i++) {
    p[i] = cal(h, i);
    p1[i] = cal(h - 1, i);
  }
  for (int i = 1; i <= n; i++) {
    inv[i] = cal(1ll * i, mod - 2);
  }
  gao();
  for (int i = 1; i <= n; i++) {
    long long r1 = C[n][i];
    long long r2 = p1[n - i];
    d[1][i] = r1 * r2 % mod;
  }
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = j; k <= n; k++) {
        if (k == j) {
          long long r1 = p[j];
          long long r2 = p1[j];
          r1 = (r1 - r2 + mod) % mod;
          r2 = p1[n - j];
          d[i][k] = (d[i][k] + d[i - 1][k] * r1 % mod * r2 % mod) % mod;
          continue;
        }
        long long r1 = p[j];
        long long r2 = C[n - j][k - j];
        r1 = r1 * r2 % mod;
        r2 = p1[n - k];
        d[i][k] = (d[i][k] + d[i - 1][j] * r1 % mod * r2 % mod) % mod;
      }
    }
  }
  cout << d[n][n] << endl;
}
