#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  const int mod = (int)1e9 + 7;
  vector<vector<int>> c(n + 1, vector<int>(n + 1));
  vector<vector<int>> f(n + 1, vector<int>(n + 1));
  auto add = [&mod](int& a, int b) {
    if ((a += b) >= mod) {
      a -= mod;
    }
  };
  auto sub = [&mod](int& a, int b) {
    if ((a -= b) < 0) {
      a += mod;
    }
  };
  auto mul = [&mod](int a, int b) { return (long long)a * b % mod; };
  auto power = [&](int a, int k) {
    int res = 1;
    while (k > 0) {
      if (k & 1) {
        res = mul(res, a);
      }
      a = mul(a, a), k >>= 1;
    }
    return res;
  };
  for (int i = 0; i <= n; ++i) {
    c[i][0] = 1;
    for (int j = 1; j <= i; ++j) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
  }
  for (int i = 1; i <= n; ++i) {
    f[1][i] = mul(c[n][i], power(k - 1, n - i));
  }
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j <= n; ++j) {
      int s = mul(f[i][j], power(k, j));
      for (int t = j; t <= n; ++t) {
        if (t == j) {
          sub(s, mul(f[i][j], power(k - 1, j)));
        }
        add(f[i + 1][t], mul(s, mul(c[n - j][t - j], power(k - 1, n - t))));
        if (t == j) {
          add(s, mul(f[i][j], power(k - 1, j)));
        }
      }
    }
  }
  printf("%d\n", f[n][n]);
  return 0;
}
