#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int add(int a, int b) {
  long long c = (long long)a + b;
  c %= MOD;
  if (c < MOD) c += MOD;
  return c;
}
int mul(int a, int b) {
  long long c = (long long)a * b % MOD;
  if (c < 0) c += MOD;
  return c;
}
int powmod(int a, long long b) {
  if (a == 0) return 0;
  if (b == 0) return 1;
  int c = powmod(a, b / 2);
  c = mul(c, c);
  if (b & 1) c = mul(c, a);
  return c;
}
const int MAXN = 255;
int fact[MAXN];
int binom[MAXN][MAXN];
int n, k;
void load() { scanf("%d%d", &n, &k); }
void solve() {
  fact[0] = 1;
  for (int i = 1; i <= n; i++) {
    fact[i] = mul(fact[i - 1], i);
  }
  for (int i = 0; i <= n; i++) binom[i][0] = 1;
  for (int i = 1; i <= n; i++) binom[0][i] = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      binom[i][j] = add(binom[i - 1][j - 1], binom[i - 1][j]);
    }
  int sol = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (!i && !j) continue;
      int f = i * n + j * n - i * j;
      int temp = mul(((i + j - 1) & 1) ? -1 : 1,
                     mul(mul(binom[n][i], binom[n][j]),
                         mul(powmod(k - 1, f), powmod(k, n * n - f))));
      sol = add(sol, temp);
    }
  }
  sol = add(powmod(k, n * n), -sol);
  printf("%d\n", sol);
}
int main() {
  load();
  solve();
  return 0;
}
