#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;

template<class T,class U>constexpr bool chmin(T&a,const U b){if(a<=b)return false;a=b;return true;}
template<class T,class U>constexpr bool chmax(T&a,const U b){if(a>=b)return false;a=b;return true;}
template<class T,class U>constexpr bool bit(const T n,const U k){return (n>>k)&1;}

//デバッグ
template<class T>
void Vout(vector<T> &V){
    cout<<"start"<<endl;
    const int sz=V.size();
    for(int i=0;i<sz;i++){
        cout<<i<<" "<<V[i]<<'\n';
    }
    cout<<"end"<<endl;
}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


constexpr int MAX=1<<30;
constexpr ll INF=1LL<<62;
constexpr int MOD=1e9+7;
//__builtin_popcount(S);
//#define int ll


struct ModInt{
    ll a;
    constexpr ModInt() :a(0){}
    constexpr ModInt(ll x) :a((x>=0)?(x%MOD):(x%MOD+MOD) ) {}

    constexpr ModInt operator+(const ModInt rhs)const noexcept{
        return ModInt(*this)+=rhs;
    }
    constexpr ModInt operator-(const ModInt rhs)const noexcept{
        return ModInt(*this)-=rhs;
    }
    constexpr ModInt operator*(const ModInt rhs)const noexcept{
        return ModInt(*this)*=rhs;
    }
    constexpr ModInt operator/(const ModInt rhs)const noexcept{
        return ModInt(*this)/=rhs;
    }
    constexpr ModInt operator+(const ll rhs) const noexcept{
        return ModInt(*this)+=rhs;
    }
    constexpr ModInt operator-(const ll rhs)const noexcept{
        return ModInt(*this)-=rhs;
    }
    constexpr ModInt operator*(const ll rhs)const noexcept{
        return ModInt(*this)*=rhs;
    }
    constexpr ModInt operator/(const ll rhs)const noexcept{
        return ModInt(*this)/=rhs;
    }

    constexpr ModInt &operator+=(const ModInt rhs)noexcept{
        a+=rhs.a;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt rhs)noexcept{
        a-=rhs.a;
        if(a<0) a+=MOD;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt rhs)noexcept{
        a=(a*rhs.a)%MOD;
        return *this;
    }
    constexpr ModInt &operator/=(ModInt rhs)noexcept{
        a=(a*rhs.inverse().a)%MOD;
        return *this;
    }
    constexpr ModInt &operator+=(const ll rhs)noexcept{
        a+=rhs;
        if(a>=MOD) a-=MOD;
        return *this;
    }
    constexpr ModInt &operator-=(const ll rhs)noexcept{
        a-=rhs;
        if(a<0) a+=MOD;
        return *this;
    }
    constexpr ModInt &operator*=(const ll rhs)noexcept{
        a=(a*rhs)%MOD;
        return *this;
    }
    constexpr ModInt &operator/=(ll rhs)noexcept{
        a=(a*ModInt(rhs).inverse().a)%MOD;
        return *this;
    }

    constexpr ModInt operator=(ll x)noexcept{
        x%=MOD;
        if(x<0) x+=MOD;
        a=x;
        return *this;
    }

    constexpr bool operator==(const ModInt p)const noexcept{
        return a==p.a;
    }

    constexpr bool operator!=(const ModInt p)const noexcept{
        return a!=p.a;
    }

    constexpr ModInt pow(ll N) const noexcept{
        ModInt ans(1LL),p(a);
        while(N>0){
            if(bit(N,0)){
                ans*=p;
            }
            p*=p;
            N>>=1;
        }
        return ans;
    }
    constexpr ModInt inverse() const noexcept{
        return pow(MOD-2);
    }

};
inline constexpr ModInt operator+(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)+=b;
}
inline constexpr ModInt operator-(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)-=b;
}
inline constexpr ModInt operator*(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)*=b;
}
inline constexpr ModInt operator/(const ll &a,const ModInt &b)noexcept{
    return ModInt(a)/=b;
}


constexpr ModInt Mr(ll p){
    p%=MOD;
    if(p<0) p+=MOD;
    return ModInt(p);
}

struct Binominal{
    vector<ModInt> fac,finv,inv;

    Binominal(int n){
        fac.resize(n+1,1);
        finv.resize(n+1,1);
        inv.resize(n+1,1);
        for(int i=2;i<=n;i++){
            fac[i]=fac[i-1]*i;
            inv[i]=MOD-inv[MOD%i]*(MOD/i);
            finv[i]=finv[i-1]*inv[i];
        }
    }
    //nCk(n,k<=N) をO(1)で求める
    ModInt com(int n,int k){
        if(n<k) return ModInt(0);
        if(n<0 || k<0) return ModInt(0);
        return fac[n]*finv[k]*finv[n-k];
    }
    //nCk(k<=N) をO(k)　で求める 
    ModInt rcom(ll n,int k){
        if(n<k) return ModInt(0);
        if(n<0 || k<0) return ModInt(0);
        ModInt ret(1);
        for(int i=0;i<k;i++){
            ret*=(n-i);
        }
        ret*=finv[k];
        return ret;
    }
};

signed main(void){
    int n,k;
    cin>>n>>k;
    cout<<Mr(k).pow(n).a<<endl;
}



Measured memory_bytes: 3112