func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long INF =       sizeof(long long) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;   const long long MOD = (long long)(1e9) + 7;   const double PI = acos(-1);   const double EPS = 1e-9;   using pii = pair<long long, long long>;   template <typename T, typename S>   istream &operator>>(istream &is, pair<T, S> &p) {     is >> p.first >> p.second;     return is;   }   template <typename T, typename S>   ostream &operator<<(ostream &os, pair<T, S> &p) {     os << p.first <<     << p.second;     return os;   }   template <typename T>   void printvv(const vector<vector<T>> &v) {     cerr << endl;     for (long long i = (0); i < (v.size()); i++)       for (long long j = (0); j < (v[i].size()); j++) {         if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {           cerr <<  INF ;         } else           cerr << v[i][j];         cerr << (j == v[i].size() - 1 ?   n  :    );       }     cerr << endl;   }   void YES(bool f) { cout << (f ?  YES  :  NO ) << endl; }   void Yes(bool f) { cout << (f ?  Yes  :  No ) << endl; }   template <class T>   bool chmax(T &a, const T &b) {     if (a < b) {       a = b;       return true;     }     return false;   }   template <class T>   bool chmin(T &a, const T &b) {     if (a > b) {       a = b;       return true;     }     return false;   }   template <long long MOD>   struct ModInt {     static const long long Mod = MOD;     unsigned x;     ModInt() : x(0) {}     ModInt(signed sig) {       long long sigt = sig % MOD;       if (sigt < 0) sigt += MOD;       x = sigt;     }     ModInt(signed long long sig) {       long long sigt = sig % MOD;       if (sigt < 0) sigt += MOD;       x = sigt;     }     long long get() const { return (long long)x; }     ModInt &operator+=(ModInt that) {       if ((x += that.x) >= MOD) x -= MOD;       return *this;     }     ModInt &operator-=(ModInt that) {       if ((x += MOD - that.x) >= MOD) x -= MOD;       return *this;     }     ModInt &operator*=(ModInt that) {       x = (unsigned long long)x * that.x % MOD;       return *this;     }     ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }     ModInt operator+(ModInt that) const { return ModInt(*this) += that; }     ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }     ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }     ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }     ModInt inverse() const {       signed a = x, b = MOD, u = 1, v = 0;       while (b) {         signed t = a / b;         a -= t * b;         std::swap(a, b);         u -= t * v;         std::swap(u, v);       }       if (u < 0) u += MOD;       ModInt res;       res.x = (unsigned)u;       return res;     }   };   template <long long MOD>   ostream &operator<<(ostream &os, const ModInt<MOD> &m) {     return os << m.x;   }   template <long long MOD>   istream &operator>>(istream &is, ModInt<MOD> &m) {     signed long long s;     is >> s;     m = ModInt<MOD>(s);     return is;   };   template <long long MOD>   ModInt<MOD> pow(ModInt<MOD> a, unsigned long long k) {     ModInt<MOD> r = 1;     while (k) {       if (k & 1) r *= a;       a *= a;       k >>= 1;     }     return r;   }   using mint = ModInt<1000000007>;   vector<mint> fact, factinv;   void nCr_compute_factinv(long long N) {     N = min(N, mint::Mod - 1);     fact.resize(N + 1);     factinv.resize(N + 1);     fact[0] = 1;     for (long long i = (1); i < (N + 1); i++) fact[i] = fact[i - 1] * i;     factinv[N] = fact[N].inverse();     for (long long i = N; i >= 1; i--) factinv[i - 1] = factinv[i] * i;   }   mint nCr(long long n, long long r) {     if (n >= mint::Mod)       return nCr(n % mint::Mod, r % mint::Mod) *              nCr(n / mint::Mod, r / mint::Mod);     return r > n ? 0 : fact[n] * factinv[n - r] * factinv[r];   }   mint nHr(long long n, long long r) { return r == 0 ? 1 : nCr(n + r - 1, r); }   mint f(long long x, long long y) {     if (x != y)       return mint(y) * pow(mint(x), x - y - 1);     else       return mint(1);   }   signed main(signed argc, char *argv[]) {     long long N, M;     cin >> N >> M;     long long a, b;     cin >> a >> b;     nCr_compute_factinv(N + M + 10);     mint ans;     for (long long i = (0); i < (N - 1); i++) {       if (N - 2 - i >= 0 and i <= M - 1) {         ;         ;         ans += fact[N - 2] / fact[N - 2 - i] * nCr(M - 1, i) *                pow(mint(M), N - 1 - i - 1) * f(N, i + 2);         ;       }     }     cout << ans << endl;     return 0;   }   