#include <bits/stdc++.h>
using namespace std;
const int N = 100000, M = 500, p = 1e9 + 7;
long long fac[N], ifac[N], f[M][M], g[M][M], h[M][M];
inline int read() {
  int num = 0;
  char g = getchar();
  while (g < 48 || 57 < g) g = getchar();
  while (47 < g && g < 58)
    num = (num << 1) + (num << 3) + g - 48, g = getchar();
  return num;
}
inline void write(long long u) {
  if (u > 9) write(u / 10);
  putchar(u % 10 + '0');
}
inline long long pows(long long u, int v) {
  long long ans = 1;
  while (v > 0) {
    if (v & 1) ans = ans * u % p;
    u = u * u % p, v = v >> 1;
  }
  return ans;
}
inline long long getans(long long a, long long b) {
  return fac[a] * ifac[b] % p * ifac[a - b] % p;
}
int main() {
  int n = read(), k = read();
  fac[0] = ifac[0] = 1;
  long long ans = 0;
  for (int i = 1; i <= n * n; i++)
    fac[i] = fac[i - 1] * i % p, ifac[i] = pows(fac[i], p - 2);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) {
      if (i == 0 && j != 0) continue;
      if (i != 0 && j == 0) continue;
      f[i][j] = pows(k - 1, n * n - i * j) % p * pows(k, i * j) % p;
    }
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= n; j++) {
      if (i == 0 && j != 0) continue;
      if (i != 0 && j == 0) continue;
      for (int a = 0; a <= i; a++)
        f[i][j] = (f[i][j] - h[a][j] * getans(i, a)) % p;
      g[i][j] = f[i][j];
      for (int b = j; b <= n; b++)
        h[i][b] = (h[i][b] + g[i][j] * getans(b, j)) % p;
    }
  cout << (g[n][n] + p) % p << endl;
  return 0;
}
