#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define nl '\n'
#define gcd __gcd
#define nset __builtin_popcount
#define pb push_back
#define pf push_front
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define nrep(i, a, b) for (int i = int(a); i >= int(b); i--)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using ll  = long long;
using ull = unsigned long long;
using vi  = vector<int>;
using vl  = vector<ll>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvl = vector<vl>;
using ii  = pair<int, int>;
using vii = vector<ii>;
using vs  = vector<string>;
using msi = map<string, int>;
using iss = istringstream;

ll powmod(ll x, ll n, ll M)
{
    if(n == 0) return 1%M;
    ll half = powmod(x, n/2, M);
    if(n % 2 == 0) return (half*half)%M;
    return (((half*half)%M)*x)%M;
}

int main()
{
    FASTIO;
    const ll M = 1e9 + 7;
    ll n, m, k;
    cin >> n >> m >> k;

    if(k == 1 || k > n) cout << powmod(m, n, M) << nl;
    else if(k == n) cout << powmod(m, (n+1)/2, M) << nl;
    else if(k % 2 == 0) cout << m << nl;
    else cout << m*m << nl;

    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <ctime>
#include <climits>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>
#define REP(i,n)      for (i=0; i<(n); ++i)
#define FOR(i,l,r)    for (i=(l); i<=(r); ++i)
#define FOReach(it,c) for (__typeof(c.begin()) it=c.begin(); it!=c.end(); ++it)
#define foreach(c)    for (__typeof(c.begin()) it=c.begin(); it!=c.end(); ++it)
using namespace std;
typedef long long LL;
template <class T> inline void checkmin(T &a, T b) {if (b<a) a=b;}
template <class T> inline void checkmax(T &a, T b) {if (b>a) a=b;}
template <class T> inline T gcd(T a, T b) {if (!b) return a; return gcd(b,a%b);}
int mod=1000000007;
int n,m,k,half,i;
long long ans;
int cb(int n,int k)
{
	int i,ret=1;
	for (i=1; i<=k; ++i)
	{
		ret*=n-k+i;
		ret/=i;
	}
	return ret%mod;
}
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	if (m==1)
	{
		printf("1\n");
		return 0;
	}
	if (k==1)
	{
		ans=1;
		REP(i,n)
		{
			ans*=m;
			ans%=mod;
		}
		cout << ans << endl;
		return 0;
	}
    if (n==k)
    {
    	half=n/2;
    	if (n%2) ++half;
    	ans=1;
    	REP(i,half)
    	{
    		ans*=m;
    		ans%=mod;
    	}
    	cout << ans << endl;
		return 0;
    }
    if (k>n)
    {
    	ans=1;
    	REP(i,n)
    	{
    		ans*=m;
    		ans%=mod;
    	}
    	cout<<ans<<endl;
    	//printf("0\n");
    	return 0;
    }
    if (k%2==0)
    {
    	printf("%d\n",m);
    	return 0;
    }
    printf("%d\n",m*m);
}

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define ll long long
#define int long long
#define ld long double
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 1e5 + 10 , N = 1e6 + 1 , SQ = 600 , base = 1999 , mod = 1e9 + 7 , INF = 1e18 , lg = 17;

int n , m , k , par[maxn] , sz;

int root(int v) {
    return (v == par[v] ? v : par[v] = root(par[v]));
}

inline void merge(int v , int u) {
    if((v = root(v)) == (u = root(u))) {
        return;
    }
    sz--;
    par[v] = u;
}

int32_t main() {
    FAST;
    cin >> n >> m >> k; sz = n;
    for (int i = 0; i < n; ++i) {
        par[i] = i;
    }

    for (int i = 0; i <= n - k; ++i) {
        for (int j = i; j < i + k; ++j) {
            merge(j , i + k - (j - i + 1));
        }
    }
    int ans = 1;
    for (int i = 0; i < sz; ++i) {
        ans = (ans * m) % mod;
    }
    cout << ans << '\n';
}

#include <cstdio>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <complex>
#include <bitset>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define allof(c) begin(c),end(c)
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int MOD=1e9+7;

int solve(int n,int m,int k)
{
	if(k==1 || n<k){
		ll res=1;
		rep(i,n)
			res=res*m%MOD;
		return res;
	}
	if(k<n){
		if(k&1)
			return m*m;
		else
			return m;
	}
	ll res=1;
	per(i,(k+1)/2)
		res=res*m%MOD;
	return res;
}

int main()
{
	for(int n,m,k;cin>>n>>m>>k && n|m|k;)
		cout<<solve(n,m,k)<<endl;

	return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<double,double> dd;
typedef pair<ll,ll> pll;
typedef pair<string,int> psi;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<ii> > vvip;
typedef vector<ii> vii;
typedef map<int,int> mpi;
#define pb push_back
#define F first
#define S second
#define MOD 1000000007
#define NA -1
#define ALL(v) v.begin(),v.end()
#define mp make_pair
#define rep(i, n) for (int (i) = 0; (i) < (n); (i) ++)
#define rep1(i, n) for (int (i) = 1; (i) <= (n); (i) ++)
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define db(x) {cout << #x << " = " << (x) << endl;}
#define dba(a, x, y) {cout<<#a<<" :";FOR(i123,x,y)cout<<setw(4)<<(a)[i123];cout<<endl;}
#define foreach(e, x) for (__typeof(x.begin()) e = x.begin(); e != x.end(); e++)
#define clr(x) memset(x,0,sizeof(x));
#define sz(x) int((x).size())
#define endl '\n'
const int INF = INT_MAX;
const ll INFL = LLONG_MAX;
const ld pi = acos(-1);
#define sc(t) scanf("%d",&t)
// vector<string> split(const string &s, char delim) {
//     stringstream ss(s);
//     string item;
//     vector<string> tokens;
//     while (getline(ss, item, delim)) {
//         tokens.push_back(item);
//     }
//     return tokens;
// }
typedef pair<pll,ll> ppll;
// int dx[] = {1, -1, 0, 0};
// int dy[] = {0, 0, 1, -1};
// these directions are from top to bottom in circular manner
// so adding changing direction is now adding proper offsets.
int dx[] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[] = {1, 1, 0, -1, -1, -1, 0, 1};

#define re return
int p[3000],r[3000];
int f(int u){re p[u]!=u?p[u]=f(p[u]):p[u];}
void u( int a, int b)
{
	int x=f(a),y=f(b);
	if( x==y ) re;
	if( r[x]>r[y])
		p[y]=x;
	else
		p[x]=y;
	if( r[x] == r[y])r[y]++;
}
int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	//     freopen("output.txt","w",stdout);;
	// #endif
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	//ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
	ios_base::sync_with_stdio(0); cout.precision(15); cout << fixed; cout.tie(0); cin.tie(0);
	int n,m,k;
	cin>>n>>m>>k;
	rep(i,3000)	p[i]=i;clr(r);
	for(int i=0;i+k-1<=n-1;i++)
		for(int o=i,oo=i+k-1;o<=oo;o++,oo--)
			u(o,oo);
	int w[3000];clr(w);
	ll ans=1LL;
	rep(i,n) if( w[f(i)]==0) {ans=(ans*m)%MOD;w[f(i)]=1;}
	cout<<ans<<endl;
}

#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define ins insert
#define sz(x) (long long)x.size()
typedef long long ll;
typedef long double ld;
const int N = 1e5 + 5;
const ld pi = 3.141592653;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

int dx[9] = {1, -1, 0, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 0, 1, -1, 1, -1, 1, -1, 0};

int main()
{
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int T = 1;
        //cin>>T;
        while(T--)
        {
                ll n, m, k, ans = 1;
                cin>>n>>m>>k;
                if(n < k){
                        for(ll i = 1; i<=n; i++) ans = (ans * m) % MOD;
                }
                else if(n == k){
                        for(ll i = 1; i<=(k + 1)/2; i++) ans = (ans * m) % MOD;
                }
                else{
                        if(k % 2 == 0) ans = m;
                        else{
                                if(k == 1){
                                        for(ll i = 1; i<=n; i++) ans = (ans * m) % MOD;
                                }
                                else ans = m * m;
                        }
                }
                cout<<ans;
        }
        return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<string>
#include<math.h>
#include<queue>
#include<stack>
#include<sstream>
#include<stdio.h>
#include<map>
#include<set>
#include<memory.h>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){
    if (!b)
        return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b){
    return b / gcd(a, b)*a;
}
#define FOR(I,N) for(int(i)=0;i<int(N);++i)
#define FORK(I,N,K) for(int(i)=0;i<int(N);i+=int(K))
#define mp make_pair
int mod = (1e9) + 7;
ll Pow(int b, int e){
    if (!e)
        return 1;
    ll r = Pow(b, e / 2);
    r = (r * r) % mod;
    if (e & 1)
        r = (r * b) % mod;
    return r;
}
int n, m, k;
int main(){
    cin >> n >> m >> k;
    if (k == 1 || k > n)
        cout << Pow(m, n) << endl;
    else if (k == n)
        cout << Pow(m, (n + 1) / 2) << endl;
    else if (k & 1)
        cout << m * m << endl;
    else cout << m << endl;
}

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(),v.end()
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 998244353

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ordered_set<ll> ods;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll power(ll a, ll n, ll m)
{
    ll ans=1;
    while(n)
    {
        if(n&1) ans=(ans*a)%m;
        n>>=1;
        a=(a*a)%m;
    }
    return ans;
}

ll invmod(ll a, ll m)
{
    return power(a,m-2,m);
}

ll par[2001],sz[2001];

ll findp(ll x)
{
    if(x==par[x]) return par[x];
    return par[x]=findp(par[x]);
}

void merge(ll x, ll y)
{
    ll px=findp(x);
    ll py=findp(y);
    if(px==py) return;
    if(sz[px]>=sz[py])
    {
        par[py]=par[px];
        sz[px]+=sz[py];
    }
    else
    {
        par[py]=par[px];
        sz[py]+=sz[px];
    }
}

void solve()
{
    ll n,m,k;
    cin>>n>>m>>k;
    repf(i,1,n+1) par[i]=i;
    for(ll i=1;i<=n-k+1;i++)
    {
        ll st=i;
        ll en=i+k-1;
        // cout<<st<<endl;
        while(st<en)
        {
            merge(st,en);
            // cout<<st<<" "<<en<<endl;
            st++,en--;
        }
    }
    ll c=0;
    repf(i,1,n+1)
    {
        if(par[i]==i)
        {
            // cout<<i<<endl;
            c++;
        }
    }
    ll ans=power(m,c,mod);
    cout<<ans<<endl;
}

int main()
{
    IOS;
    ll t;
    // cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
}

#include <iostream>

using namespace std;

const int delta = 1000 * 1000 * 1000 + 7;
long long n, k, m, ans = 1;

int main() {
	cin >> n >> m >> k;
	if (k > n) {
			for (int i = 0; i < n; ++i) {
				ans *= m;
				ans %= delta;
			}
			cout << ans << "\n";
	}
	else if (k == n) {
		for (int i = 0; i < (n + 1) / 2; ++i) {
			ans *= m;
			ans %= delta;
		}
		cout << ans << "\n";
	}
	else if (k % 2 == 0)
		cout << m << "\n";
	else {
		if (k == 1) {
			for (int i = 0; i < n; ++i) {
				ans *= m;
				ans %= delta;
			}
			cout << ans << "\n";
		}
		else
			cout << m * m << "\n";
	}
	return 0;
}

#include<iostream>
#include<sstream>
#include<fstream>
#include<set>
#include<map>
#include<queue>
#include<functional>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<cstdio>
#include<ctime>
#include<algorithm>
#define mp make_pair
#define pb push_back
#define rep(i,j,k) for(int (i)=(j);(i)<=k;(i)++)
using namespace std;
int fa[2010];
long long n,m,k,re=1;
int Find(int x)
{
    if(fa[x]==x)return x;
    else return fa[x]=Find(fa[x]);
}
bool Uni(int x,int y)
{
    int fx=Find(x),fy=Find(y);
    if(fx!=fy){fa[fx]=fy;return true;}
    return false;
}
int main()
{
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)fa[i]=i;
    int aa=n;
    for(int i=1;i<=n-k+1;i++)for(int j=1;j<=k/2;j++)if(Uni(i+j-1,i+k-j))aa--;
    while(aa){
        if(aa%2==1)re=(re*m)%1000000007;
        m=(m*m)%1000000007;aa/=2;
    }
    cout<<re;
    return 0;
}

//
//  main.cpp
//  D
//
//  Created by Liza Kondakova on 17.02.12.
//  Copyright (c) 2012 likogra@gmail.com. All rights reserved.
//

#include <iostream>
using namespace std;
long long p=1000000007;
long long pow(long long a,long long b){
    long long ans=1;
    for(int i=0;i<b;i++){
        ans*=a;
        ans%=p;
    }
    return ans;
}
int main ()
{
    long long n,k,m;
    cin>>n>>m>>k;
    if(k>n){
        cout<<pow(m,n);
    }
    if(k==n){
        cout<<pow(m,(n+1)/2);
        return 0;
    }
    if(k==1){
        cout<<pow(m,n);
        return 0;
    }
    if(k<n){
        cout<<pow(m,(k)%2+1);
    }
    cout<<endl;
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}

/*
 *  eat_code
 *  IIIT Allahabad
 */
#include <bits/stdc++.h>
// #include "pretty_print.h"
using namespace std;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define CONTAINS(a, x) (a.find(x) != a.end())
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()
#define nl cout << endl
#define F first
#define S second

#define what_is(x) cout << #x << " = " << x << endl
#define boost ios::sync_with_stdio(false);cin.tie(NULL)
#define CASET int ___T, case_n = 1; scanf("%d", &___T); while (___T-- > 0)

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<ii> vii;
typedef vector<vi> vvi;

ll INF = 1E9;
ll M = 1E9 + 7;

inline ll power (ll a,ll p){
    ll res = 1, x = a;
    while ( p ) {
        if ( p & 1 ) res = ( res * x ) % M;
        x = ( x * x) % M; p >>= 1;
    }
    return res;
}
vvi g;
vi vis;
void dfs(int u){
    vis[u] = 1;
    for(int v : g[u])
        if(!vis[v])
            dfs(v);
}
int main() {
    boost;
    if(fopen("input.txt", "r")){
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    }
    int n, m, k;
    cin >> n >> m >> k;
    g.resize(n + 1);
    vis.assign(n + 1, 0);
    if(n == 1 || m == 1){
        cout << m << "\n";
        exit(0);
    }
    if(k == 1){
        cout << power(m, n) << "\n";
        exit(0);
    }
    for(int i = 1;i <= n;i++){
        for(int j = i + (k - 1);j <= n;j += (k - 1)){
            g[i].pb(j);
            g[j].pb(i);
        }
        if((i + k - 1) <= n){
            int lo = i;
            int hi = i + k - 1;
            while(lo <= hi){
                g[lo].pb(hi);
                g[hi].pb(lo);
                lo++;
                hi--;
            }
        }
    }
    int cc = 0;
    for(int i = 1;i <= n;i++){
        if(!vis[i]){
            cc++;
            dfs(i);
        }
    }
    cout << power(m, cc) << "\n";
    return 0;
}
//  Train Insane or Remain the same

#include "bits/stdc++.h"
#define ll long long int
using namespace std;

struct ${$(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    cout << fixed << setprecision(9);
}}$;

#ifndef _MOD
    #define _MOD
    const int MOD = 1000000007LL;
#endif

#ifndef _MOD_POW
    #define _MOD_POW
    template<typename T>
    T mod_pow(T base, T exp, T mod = MOD) {
        if(exp == 0) {
            return 1;
        } else if(exp % 2 == 0) {
            T root = mod_pow(base, exp >> 1, mod);
            return (root * root) % MOD;
        } else {
            T prev = mod_pow(base, exp - 1, mod);
            return (prev * base) % MOD;
        }
    }
#endif

int main() {

  ll n, m, k;
  cin >> n >> m >> k;

  if(k == 1) {
    cout << mod_pow(m, n) << endl;
  } else if(k == n) {
    cout << mod_pow(m, (n + 1) >> 1) << endl;
  } else if(k < n) {
    cout << m * mod_pow(m, k & 1) << endl;
  } else {
    cout << mod_pow(m, n) << endl;
  }

  return 0;
}

#include "bits/stdc++.h"
using namespace std;
const int mod = 1e9 + 7;
int n , m , k;
long long ans = 1;
int power;
int main(){
    cin >> n >> m >> k;
    if(k == 1 || k > n){
        power = n;
    }
    else if(k == n){
        power = (n >> 1) + (n & 1);
    }
    else if(k & 1){
        power = 2;
    }
    else{
        power = 1;
    }
    while(power--){
        ans *= m;
        ans %= mod;
    }
    cout << ans;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<queue>
#include<cctype>
#include<functional>
#include<fstream>
#include<sstream>
#include<complex>
#include<cmath>
#include<cstdlib>

using namespace std;

#define EPS 1.0e-10
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(it,c) for(__typeof((c).begin()) it = (c).begin();it != (c).end();++it)
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int SIZE=12800;
const ll mod=1000000007LL;
int main(){
	ll n,m,k;
	while(cin>>n>>m>>k){
		ll ans=1;
		if(k!=1&&n>k){
			if(k%2==0) ans=m;
			else ans=m*m;
		}
		else if(n==k){
			if(n%2==1) ans=m;
			REP(i,n/2){
				ans*=m;
				ans%=mod;
			}
		}
		else{
			REP(i,n){
				ans*=m;
				ans%=mod;
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define LL long long
#define MOD 1000000007
int gr[2001][2001];
int n, m, k;
int mark[2001];
void dfs(int s){
    mark[s] = 1;
    for(int i = 0; i < n; i++)
        if(gr[s][i] && !mark[i])
            dfs(i);
}
int main(){
    cin >> n >> m >> k;
    memset(gr, 0, sizeof gr);
    for(int i = 0; i + k <= n; i++){
        for(int j = 0; j < k; j++){
            gr[i + j][i + k - j - 1] = gr[i + k - j - 1][i + j] = 1;
        }
    }
    memset(mark, 0, sizeof mark);
    LL ans = 1;
    for(int i = 0; i < n; i++){
        if(!mark[i]){
            dfs(i);
            ans = (ans * m) % MOD;
        }
    }
    cout << ans << endl;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define forn(i, n)  for(ll i = 0;i<n;i++)
#define pb         push_back
const ll N = 2005;
const ll MOD = 1000 * 1000 * 1000 + 7;

ll mul(ll a, ll b){ return (a * b + MOD) %MOD; }
ll add(ll a, ll b){ return (a + b + MOD)  %MOD; }

ll POW(ll a, ll lu){
	if(lu == 1) return a%MOD;
	if(lu == 0) return 1;

	ll mi = POW(a, lu/2);
	mi = mul(mi, mi);
	if(lu&1) mi = mul(mi, a);
	return mi;
}

int main(){
	ll m, n, k;
	cin >> n >> m >> k;

	if(k == 1 || n<k) cout<< POW(m, n);
	else if(n == k) cout<<POW(m, (n + 1)/2);

	else if(k%2 == 0) cout<<m << endl;
	else if(k % 2 == 1) cout<< POW(m, 2) << endl;

}

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;

const int MOD = 1000000007;

int bspow (int a, int b)
{
    int ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (long long)ans * a % MOD;
        a = (long long)a * a % MOD;
        b >>= 1;
    }
    return ans;
}

int n, m, k;

int main ()
{
    while (scanf ("%d%d%d", &n, &m, &k) != EOF)
    {
        if (k > n)
        {
            printf ("%d\n", bspow(m, n));
            continue;
        }
        if (k == 1)
        {
            printf ("%d\n", bspow(m, n));
            continue;
        }
        if (k % 2 == 0)
        {
            if (n == k)
                printf ("%d\n", bspow(m, k / 2));
            else
                printf ("%d\n", m);
        }
        else
        {
            if (n == k)
                printf ("%d\n", bspow(m, k / 2 + 1));
            else
                printf ("%d\n", m * m);
        }
    }
}

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

const long long p = 1000000007;

vector <int> v[2000];
bool used[2000];

int dfs(int x) {
	if (used[x]) {
		return 0;
	}

	used[x] = true;
	for (int i = 0; i < (int)v[x].size(); i++) {
		dfs(v[x][i]);
	}

	return 1;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	long long n, m, k;
	cin >> n >> m >> k;

	if (k > n || k == 1) {
		long long ans = 1;
		for (int i = 0; i < n; i++) {
			ans = ans * m;
			ans = ans % p;
		}
		ans = ans % p;
		cout << ans;

		return 0;
	}

	if (k == n) {
		long long ans = 1;
		for (int i = 0; i < (k + 1) / 2; i++) {
			ans *= m;
			ans = ans % p;
		}
		cout << ans;
		return 0;
	}

	if (k < n) {
		for (int i = 0; i + k - 1 < n; i++) {
			for (int j = 0; j < k / 2; j++) {
				v[i + j].push_back(i + k - 1 - j);
				v[i + k - 1 - j].push_back(i + j);
			}
		}

		memset(used, 0, sizeof(used));

		int d = 0;
		for (int i = 0; i < n; i++) {
			d += dfs(i);
		}

		long long ans = 1;
		for (int i = 0; i < d; i++) {
			ans = (ans * m) % p;
		}

		cout << ans;
	}

	return 0;
}

#include <bits/stdc++.h>

#define fori(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;

ll MOD = 1000000007;
ll n, m, k;

ll binpow(ll a, ll n) {
	ll res = 1;
	while(n) {
		if(n & 1) res *= a; res %= MOD;
		a *= a;
		a %= MOD;
		n >>= 1;
	}
	return res;
}

ll solve() {
	if(m == 1) return 1;
	if(k < n && k != 1) {
		if(k % 2 == 0) return m;

		return m * m;
	}
	//if(k >= 2 * n) return m * m;

	/*ll d = floor(log(MOD) / log(m));
	ll mult = 1;
	for()
	ll deg = 0;
	ll ans = 1;
	for(; deg + d <= n; deg += d, ans *= mult, ans %= MOD);
	ans *= pow(m, n - deg);*/
	return binpow(m, (k == n ? ((n + 1) / 2) : n));
}

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m >> k;

    cout << solve() << endl;

	return 0;
}

#include <bits/stdc++.h>

using namespace std;

# define ll long long
# define pb push_back
# define ppb pop_back
# define pf push_front
# define ppf pop_front

const ll N = 1e5 + 10;
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const ll inf = -1e18;

ll n, m, k, ans = 1;

int main() {
    //freopen("in.cpp", "r", stdin);
    //freopen("out.cpp", "w", stdout);
    //ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    cin >> n >> m >> k;
    if(k == 1 || k > n) {
        for(int i = 1;i <= n;i++) {
            ans = (ans * m) % mod;
        }
        cout << ans;
        return 0;
    }
    if(n == k) {
        n = (n + (n % 2 != 0)) / 2;
        for(int i = 1;i <= n;i++) {
            ans = (ans * m) % mod;
        }
        cout << ans;
        return 0;
    }
    if(k % 2 != 0) {
        cout << (m * m) % mod;
        return 0;
    }
    cout << m;
    return 0;
}

// codefr1.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include <vector>
#include <string>
#include <iostream>

using namespace std;

#define P 1000000007

void main()
{
	int n, m, k;
	cin >> n >> m >> k;
	long long ans = 0;
	if(k == 1 || k > n)
	{
		ans = 1;
		int i;
		for(i = 0; i < n; i++)
		{
			ans *= m;
			ans %= P;
		}
	}
	else if(k == n)
	{
		ans = 1;
		int i;
		for(i = 1; i <= n + 1 - i; i++)
		{
			ans *= m;
			ans %= P;
		}
	}
	else
	{
		if(k % 2 == 0)
		{
			ans = m;
		}
		else
		{
			if(n == 1)
			{
				ans = m;
			}
			else
			{
				ans = m * m;
			}
		}
	}
	ans %= P;
	cout << ans << endl;
}

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 10;
int n, m, k, MOD = 1e9 + 7;
long long int ans;

int main() {
    // freopen("output.txt", "w", stdout);
    // freopen("input.txt", "r", stdin);
    scanf("%d%d%d", &n, &m, &k);
    if (k > n) {
        ans++;
        while (n--) {
            ans *= m;
            ans %= MOD;
        }
    } else if (k == n) {
        ans++;
        if (n % 2 == 1)
            n++;
        n /= 2;
        while (n--) {
            ans *= m;
            ans %= MOD;
        }
    } else {
        if (k == 1) {
            ans++;
            while (n--) {
                ans *= m;
                ans %= MOD;
            }
        } else if (k % 2 == 0) {
            ans = m;
        } else {
            ans = m*m;
        }
    }
    printf("%lld", ans);
    return 0;
}

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const __int64 mod = 1000000007;
int main()
{
    __int64 ans = 0;
    int n, m, k;
    scanf("%d%d%d", &n, &m, &k);
    if(k > n){
        ans = 1;
        for(int i = 0; i < n; i++){
            ans = (ans * m) % mod;
        }
    }
    else if(k == n){
        int t = (k + 1) / 2;
        ans = 1;
        for(int i = 0; i < t; i++){
            ans = (ans * m) % mod;
        }
    }
    else if(k == 1){
        ans = 1;
        for(int i = 0; i < n; i++){
            ans = (ans * m) % mod;
        }
    }
    else if(k == 2){
        ans = m;
    }
    else if(k % 2 == 1){
        ans = 1;
        ans = (ans * m) % mod;
        ans = (ans * m) % mod;
    }
    else{
        ans = m;
    }
    printf("%I64d\n", ans);

    return 0;
}

#include <cstdio>
#include <algorithm>
#define FI(a, b, c) for(int a = b; a <= c; a++)
#define FD(a, b, c) for(int a = b; a >= c; a--)
#define B 1000000007
using namespace std;

typedef long long LL;

int n, m, k;

int pow(int x){
	int a = 1;
	for(int t = m; x; x /= 2){
		if(x & 1) a = (LL) a * m % B;
		m = (LL) m * m % B;
	}
	return a;
}

int main(){
	scanf("%d %d %d", &n, &m, &k);

	if(n < k) printf("%d\n", pow(n));
	else if(n == k) printf("%d\n", pow(k + 1 >> 1));
	else{
		if(k == 1) printf("%d\n", pow(n));
		else if(k % 2) printf("%d\n", m * m);
		else printf("%d\n", m);
	}

	scanf("\n");
}

#include <iostream>
using namespace std;
int n,m,k;
int par[2005];
int fnd(int x)
{
     if (par[x]==x)
     {
          return x;
     }
     else
     {
          return par[x]=fnd(par[x]);
     }
}
int un(int x,int y)
{
     par[fnd(x)]=fnd(y);
}
int main()
{
     cin>>n>>m>>k;
     for (int i=0;i<n;i++)
     {
          par[i]=i;
     }
     for (int i=0;i<n-k+1;i++)
     {
          for (int j=0;j<k/2;j++)
          {
               un(i+j,i+k-j-1);
          }
     }
     int ans=1;
     for (int i=0;i<n;i++)
     {
          if (fnd(i)==i)
          {
               ans=(int)(((long long)ans*m)%1000000007);
          }
     }
     cout<<ans<<endl;
     return 0;
}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007

int main() {
  int n, m, k;

  scanf("%d %d %d", &n, &m, &k);

  if ((k == 1) || k > n) {
    long long ans = 1;
    for (int i = 0; i < n; i++) {
      ans = (ans * m) % MOD;
    }
    cout << ans << endl;
    return 0;
  }

  if (k == n) {
    long long ans = 1;
    for (int i = 0; i < (n+1)/2; i++) {
      ans = (ans * m) % MOD;
    }
    cout << ans << endl;
    return 0;
  }

  // odd
  if (k&1) {
    printf("%d\n", m * m);
  } else {
    printf("%d\n", m);
  }

  return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define mt make_tuple
#define mkp make_pair
#define pb push_back
#define pii pair<ll,ll>
#define pss pair<string,string>
#define pdd pair<ld,ld>
#define pff pair<float,float>
#define piii pair<ll, pair<ll,ll> >
#define pddd pair<ld, pair<ld,ld> >
#define ff first
#define ss second
typedef long long int ll;
typedef long double ld;

const int N = 2 * 100000 + 5;

int main() {
    ll n, m, k;
    cin >> n >> m >> k;

    if(k < n) {
        if(k == 1) {
            ll ans = 1;
            for(int i = 0; i < n; i++) {
                ans *= m;
                ans %= 1000000007;
            }
            cout << ans;
            return 0;
        }

        ll ans = 0;

        // aaaaaaa
        ans += m;

        // abababa
        if(k % 2 == 1)
            ans += m * (m - 1);

        ans = ans % 1000000007;

        cout << ans;
    } else if(k > n) {
        ll ans = 1;
        for(int i = 0; i < n; i++) {
            ans *= m;
            ans %= 1000000007;
        }
        cout << ans;
    } else {
        ll ans = 1;
        for(int i = 0; i < (n + 1) / 2; i++) {
            ans *= m;
            ans %= 1000000007;
        }
        cout << ans;
    }
}

#include<bits/stdc++.h>
#define int long long
using namespace std;
#define MOD 1000000007
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,m,k,ans=1;cin>>n>>m>>k;
    if(n==k ){
        n=n/2+(n&1);
            for(int i=0;i<n;i++ )
            ans=(ans*m)%MOD;}
    else if(k==1 || k>n)
    for(int i=0;i<n;i++ )
            ans=(ans*m)%MOD;
    else if(k%2)
    {
        ans=(m)*(m);
    }
    else
        ans=m;
    cout<<(ans+MOD)%MOD;

}

//JAI SHREE RAM
//JAI BAJRANGBALI

#include <bits/stdc++.h>

using namespace std;

#define ll long long int

#define     max(a,b)    ((a>b)?(a):(b))
#define     min(a,b)    ((a<b)?(a):(b))
#define     MAXN        10000005
#define     mod         1000000007
#define     pb          push_back
#define     fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define     test(a)        cout<<"testing "<< a <<endl;

ll power( ll a, ll b , ll m) { ll ans = 1;
 while(b){
    if(b&1){ans = ((ans%m )  *(a%m ) )%m ;}
    a = ((a%m )  *(a%m ) )%m ;b = b>>1;
} return ans; }

ll powe( ll a, ll b) { ll ans = 1;
 while(b){
    if(b&1){ans = a*ans;}
    a = a*a;b = b>>1;
} return ans; }

ll ncr( ll n , ll r){

    r = min( r , n-r);
    ll ans = 1;
    for( int i=0;i<r;i++){
        ans *= (n-i) ;
        ans /= (i+1);
    }

    return ans ;
}

class BIT{

public:

    ll n;

    ll *a;

    BIT( ll size){
        n = size;
        a= new ll[ size+1 ];

        for( int i=0;i<=n;i++){
            a[i] =0;
        }

    }

    void update( ll pos , ll val){

        pos = pos+1;

        while( pos <=n){
            a[pos] += val;

            pos += pos & ( -pos);
        }

    }

    ll query( ll index ){
        index = index+1;

        ll sum =0 ;
        while( index>0){

            sum += a[index ];
            index -= index& ( -index);
        }
        return sum;
    }

};

ll n ;

pair<ll,ll>  helper( ll a[] , ll t){

    ll ans =0 , cost = 0 ;

    for( int i=0;i<n;i++){

        if( t>=a[i] ){
            ans++;
            t-=a[i];
            cost += a[i];
        }

    }

    return {ans,cost};

}

void solve(){

    ll n,m,k;
    cin >> n>> m>> k;

    if( k == 1 || k>n){
        cout<< power( m,n ,mod );return ;
    }

    if( k == n){
        cout<< power( m , (n+1)/2 , mod);
        return ;
    }

    if( k%2 == 0){
        cout<< m<< endl;
    }
    else{
        cout<< m*m << endl;
    }

}

int main() {
   fast;

    ll t=1;
 //  cin >> t;
   ll tt=1;

    while(  t>0){

  //   cout<<"Case #"<<tt++<<": ";
     solve();

        t--;
    }

}

#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007LLU

template<typename T>
T fastExpPow(T base, T exp, T mod) {
    T res = 1;

    while (exp) {
        if (exp&1) {
            res *= base;
            res %= mod;
        }

        exp >>= 1;
        base *= base;
        base %= mod;
    }

    return res % mod;
}

int main()
{
    unsigned long long n, m, k;
    scanf("%I64d %I64d %I64d", &n, &m, &k);
    unsigned long long answer;
    if(m==0 || n==0)
    {
        answer = 0;
    }
    if(k==1 || k==0)
    {
        answer = fastExpPow(m, n, MOD);
    }
    else if(k%2 == 0)
    {
        if(n>k)
        {
            answer = m;
        }
        else if (n==k)
        {
            unsigned long long q = n/2;
            answer = fastExpPow(m, q, MOD);
        }
        else
        {
            answer = fastExpPow(m, n, MOD);
        }
    }
    else
    {
        if(n>k)
        {
            answer = m*m;
        }
        else if (n == k)
        {
            unsigned long long q = n/2 + 1;
            answer = fastExpPow(m, q, MOD);
        }
        else
        {
            answer = fastExpPow(m, n, MOD);
        }
    }
    printf("%I64d\n", answer);
    return 0;
}

/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author YahiaAshraf74
 */

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <complex>
#include <string>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <fstream>
#include <iomanip>
#include <assert.h>
using namespace std;
#define el  '\n'
#define ll long long
#define clr(a,b)memset(a,b,sizeof(a))
#define sz(a) (int)(a).size()
const long long N = (int)2e5 + 74, OO = 0x3f3f3f3f, MOD = (int) 1e9 + 7;

long long power(long long b, long long p, long long MOD = (long long) 1e9 + 7) {
    long long res = 1;
    b %= MOD;
    for (; p; p >>= 1LL) {
        if (p & 1)res = (res * b) % MOD;
        b = (b * b) % MOD;
    }
    return res;
}
class DQuantityOfStrings {
public:
    void init(){

    }

	void solve(istream& cin, ostream& cout) {
        init();
        int n, m,k;
        cin >> n >> m>> k;
        if(k == 1|| k > n){
            cout << power(m,n) << el;
        }else if(k == n){
            cout << power(m,(n+1)/2) << el;
        }else if(k%2==0){
            cout << m << el;
        }else{
            cout << m*m << el;
        }
	}
};
int main() {
	ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
	DQuantityOfStrings solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned int uint;

#define zero(a) memset (a, 0, sizeof(a))
#define sz(a) (int)(a.size())
#define sqr(a) ((a) * (a))
#define pb push_back
#define mp make_pair

const ll p = 1000000007;

int main (void)
{
  #ifdef LOCAL
    freopen ("input.txt", "rt", stdin);
    freopen ("output.txt", "wt", stdout);
  #endif

  int n, k, m;

  cin>>n>>m>>k;

  if (n < k)
  {
    ll ans = 1;
    for (int i = 0; i < n; i++)
      ans *= m, ans %= p;
    cout<<ans<<endl;
    exit(0);
  }
  else if (n > k)
  {
    if (k == 1)
    {
      ll ans = 1;
      for (int i = 0; i < n; i++)
        ans *= m, ans %= p;
      cout<<ans<<endl;
      exit(0);
    }
    if (k % 2 == 0)
      printf ("%d\n", m);
    else
      printf ("%d\n", m * m);
    exit(0);
  }
  else
  {
    ll ans = 1;
    for (int i = 0; i < (n + 1) / 2; i++)
      ans *= (ll)m, ans %= p;
    cout<<ans<<endl;
    exit(0);
  }

  assert(false);

  return 0;
}

	//      ******************************************************
//
//		   everything is part of a bigger plan
//
//      ******************************************************
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef vector< vector<pii> > vvii;
typedef vector<pii> vii;
typedef set<int> si;
typedef set< pii> sii;
typedef unordered_map<int,int> umii;
typedef map<int,int> mii;
typedef priority_queue<int> pqi;
typedef priority_queue< pii > pqii;
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pres(a,x) x.find(a)!=x.end()
#define cpres(a,x) find(all(x),a)!=x.end()
#define pb push_back
#define mp make_pair
#define sz(x) x.size()
#define clr(a,b) memset(a,b,sizeof(a))
#define rep(i,n) for(int i=0;i<n;i++)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define fd(i,a,b) for(int i=a;i>b;i--)
#define tr(it,x) for(auto it=x.begin();it!=x.end();it++)
#define rtr(it,x) for(auto it=x.rbegin();it!=x.rend();it++)
#define fast_io ios_base::sync_with_stdio(0);
#define accuracy  int precision = numeric_limits<double>::digits10;cout<<setprecision(precision);
#define N 200005
ll MOD=1e9+7;
ll MAX=1e17;
int par[N],sz[N];
int find(int a){
	if(par[a]==a) return a;
	return par[a]=find(par[a]);
}
void Union(int a,int b){
	a=find(a),b=find(b);
	if(sz[a]>sz[b]) swap(a,b);
	par[a]=b;
	sz[b]+=sz[a];
}
ll powmod(ll a,ll b){
	if(b==0) return 1ll;
	if(b==1) return a;
	ll temp=powmod(a,b/2ll);
	if(b%2==0) return (temp*temp)%MOD;
	return (((temp*temp)%MOD)*a)%MOD;
}
int main(){
	fast_io;//accuracy;
	int n,m,k;cin>>n>>m>>k;
	rep(i,N) par[i]=i;
	for(int i=1;i+k-1<=n;i++){
		for(int j=0;j<=k-1;j++){
			// i+j i+k-1-j
			Union(i+j,i+k-1-j);
		}
	}
	si s;
	rep(i,n){
		s.insert(find(i+1));
	}
	cout<<powmod((ll) m,(ll) s.size());
}

#include <bits/stdc++.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;
ll n,m,k;
ll modularExponentiation(ll x,ll nn,ll M)
{
    ll result=1;
    while(nn>0)
    {
        if(nn % 2 ==1)
            result=(result * x)%M;
        x=(x*x)%M;
        nn=nn/2;
    }
    return result;
}
int main()
{
    cin >> n >> m >> k;
    if(k > n){
        cout << modularExponentiation(m,n,MOD) << endl; return 0;
    }
    if(k == n){
        cout << modularExponentiation(m,(n+1)/2,MOD) << endl;
        return 0;
    }
    if(k%2 == 0){
        cout << m << endl;
        return 0;
    }
    if(k == 1){
        cout << modularExponentiation(m,n,MOD) << endl;
        return 0;
    }else{
        cout << m*(m) << endl;
    }
    return 0;
}

#include<iostream>
#include<stdlib.h>
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<utility>

using namespace std;

long long n,m,k,q,i,res,a[3000],j,z;
long long b[3000];

int main()
{
	cin>>n>>m>>k;

	if(k==1 || k>n) q=n;
	else
		if(k%2==1)
		{
			if(n==k) q=n/2+n%2;
			else	q=2;
		}
		else
			if(k%2==0)
			{
				if(n==k) q=n/2;
				else q=1;
			}

	res=1;
	for(i=1;i<=q;i++)
	{
		res=res*m;
		res=res%1000000007;
	}

	cout<<res;

	return 0;
}

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<queue>

using namespace std;

const int MOD=1e9+7;

long long modexp(long long m,long long n)
{
    if(n==0){
        return 1;
    }
    else if(n%2==0){
        return (modexp(m,n/2)*modexp(m,n/2))%MOD;
    }
    else{
        return (((modexp(m,n/2)*modexp(m,n/2))%MOD)*m)%MOD;
    }
}

int main()
{
    long long n,m,k;
    cin>>n>>m>>k;
    long long ans;
    if(k==1||k>n){
        ans=modexp(m,n);
    }
    else if(k==n){
        if(n%2==0){
            ans=modexp(m,n/2);
        }
        else{
            ans=modexp(m,n/2+1);
        }

    }
    else if(k%2==0){
        ans=m;

    }
    else{
        ans=m*m;
    }

    cout<<ans;

}

#include<bits/stdc++.h>
using namespace std;
int n,m,k,c;
long long ans;
bool w[2009];
vector<int>g[2009];
void dfs(int x) {
	if(w[x]) return;
	w[x]=1;
	for(int i=0;i<g[x].size();i++)
		dfs(g[x][i]);
}
int main() {
	cin>>n>>m>>k;
	for(int i=0;i<=n-k;i++)
		for(int j=0;j<k;j++)
			g[i+j].push_back(i+k-j-1);
	for(int i=0;i<n;i++) {
		if(!w[i]) {
//			cout<<i<<endl;
			c++;
			dfs(i);
		}
	}
	ans=1;
	for(int i=0;i<c;i++)
		ans=ans*m%1000000007;
	cout<<ans<<endl;
	return 0;
}

// Problem : D. Quantity of Strings
// Contest : Codeforces Round #107 (Div. 2)
// URL : https://codeforces.com/contest/151/problem/D
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cp-editor)

// Author - Sumit

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define int ll
#define ps push
#define pb emplace_back
#define INF 10000000000000LL
#define MOD 1000000007
#define mp make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repd(i,a,b) for (int i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define vpii vector<pair<int,int>>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define lower(v,x) (lower_bound(all(v),x)-v.begin())
#define upper(v,x) (upper_bound(all(v),x)-v.begin())
#define debug(x) cout << x << "\n";
#define debug2(x,y) cout << x << " " << y << "\n";
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;

template<typename T, typename U> inline void remin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void remax(T &x, U y) { if(x < y) x = y; }
template<typename T> T pow(T a,T b, int m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N=1e6+5;

bool vis[N];

struct DSU
{
	int connected;
	int par[N], sz[N];

	DSU() {}

	void init(int n)
	{
		for(int i=1;i<=n;i++)
		{
			par[i]=i;
			sz[i]=1;
		}
		connected=n;
	}

	int getPar(int k)
	{
		while(k!=par[k])
		{
			par[k]=par[par[k]];
			k=par[k];
		}
		return k;
	}

	int getSize(int k)
	{
		return sz[getPar(k)];
	}

	void unite(int u, int v)
	{
		int par1=getPar(u), par2=getPar(v);

		if(par1==par2)
			return;

		connected--;

		if(sz[par1]>sz[par2])
			swap(par1, par2);

		sz[par2]+=sz[par1];
		sz[par1]=0;
		par[par1]=par[par2];
	}
};

DSU dsu;

void solve(){
	int n,m,k;
	cin>>n>>m>>k;
	dsu.init(n);
	int q=n-k+1;
	cin>>q;
	rep(i,1,q+1){
		int a=i,b=i+k-1;
		// cin>>a>>b;
		int loop = (b-a+1)/2;
		rep(j,0,loop){
			//debug2(a,b);
			dsu.unite(a,b);
			a++,b--;
		}
	}
	int ans=1;
	rep(i,1,n+1){
		if(vis[dsu.getPar(i)]==0){
			ans=((ans%MOD)*m)%MOD;
			vis[dsu.getPar(i)]=1;
		}
	}
    debug(ans);
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

#include <iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define M 1000000007
bool vst[2010], grid[2010][2010];
int n;
void dfs(int from)
{
	for (int i=0; i<n; i++) {
		if (!vst[i] && grid[i][from])
		{
			vst[i] = true;
			dfs(i);
		}
	}
}
int main(int argc, char *argv[]) {
	int m, k;
	cin >> n >> m >> k;
	memset(vst, false, sizeof(vst));
	int comp = 0;
	for (int i=0; i<n; i++) {
		if (vst[i]) continue;
		for (int j=k-1; j >= 0; j-=2) {
			for (int p = (k - 1 - j)/2 ; p <= n - ( k - (k - 1 - j ) / 2); p++) {
				vst[p] = vst[p+j] = true;
				grid[p][p+j] = grid[p+j][p] = true;
			}
		}
	}
	memset(vst, 0, sizeof(vst));
	long long ret = 1;
	if (n < k) comp = n;
	else {
		for (int i=0; i<n; i++) {
			if (!vst[i])
			{
				comp++;
				dfs(i);
				vst[i] = true;
			}
		}
	}
	for (int i=0; i<comp; i++) {
		ret = ((ret % M) * (long long)(m % M)) % M;
	}
	cout << ret << endl;
	return 0;
}

#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

struct dsu {
	dsu* parent = this;
	int ind;
	int rank = 1;

	dsu* head(){
		if(parent != parent->parent){
			parent = parent->head();
		}

		return parent;
	}
	void merge(dsu* sec){
		dsu* fir = head();
		sec = sec->head();

		if(fir->rank > sec->rank){
			sec->parent = fir;
		} else if(fir->rank < sec->rank){
			fir->parent = sec;
		} else {
			fir->parent = sec;
			sec->rank++;
		}
	}
};

const int maxn = 2005;
const ll mod = 1000000007;
dsu d[maxn];

int main(){
	ios::sync_with_stdio(false);

	int n, m, k;
	cin >> n >> m >> k;

	int actsize = k / 2;
	for(int i = 0; i < n; i++){
		d[i].ind = i;
	}
	if(k % 2 == 0){
		for(int i = 0; i < n; i++){
			if(actsize - 1 <= i and i + actsize < n){
				int other = i + 1;
				for(int j = i; j >= 0 and other < n and (other - j + 1) <= k; j--, other++){
					d[other].merge(&d[j]);
				}
			}
		}
	} else {
		for(int i = 0; i < n; i++){
			if(actsize <= i and i + actsize < n){
				int other = i + 1;
				for(int j = i - 1; j >= 0 and other < n and (other - j + 1) <= k; j--, other++){
					d[other].merge(&d[j]);
				}
			}
		}
	}

	ll val = 1;
	for(int i = 0; i < n; i++){
		if(d[i].head()->ind == i){
			val *= m;
			val %= mod;
		}
	}

	cout << val;
	return 0;
}

#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define put(x) cout<<#x<<" = "<<x<<endl;
#define X first
#define Y second
#define push push_back
#define pop pop_back
#define make make_pair
using namespace std;
typedef long long num;
typedef pair<int,int> point;
const int maxn=1e5+10,M=1e9+7;

int n,m,k;
int main()
{
    cin>>n>>m>>k;
    num ans=1;
    if(k==1 || k>n)
	{
	    rep(i,0,n)
		{
		    ans=(ans*m)%M;
		}
	}
    else if(k==n)
	{
	    rep(i,0,(n+1)/2)
		{
		    ans=(ans*m)%M;
		}
	}
    else if(k&1)
	{
	    ans=m*m;
	}
    else
	{
	    ans=m;
	}
    cout<<ans<<endl;
}

#include <iostream>
using namespace std;

const int MOD = 1000000007;
long long int pow_mod(long long int a,long long int p,long long int n){
    if(p == 0)  return 1;
    long long int ans = pow_mod(a,p/2,n);
    ans = ans * ans % n;
    if(p % 2 == 1)  ans = ans * a % n;
    return ans;
}

int main()
{
    int n,m,k;
    while(cin>>n>>m>>k){
        if(n < k)   cout<<pow_mod(m,n,MOD)<<endl;
        else if(n == k)  cout<<pow_mod(m,(n+1)/2,MOD)<<endl;
        else {
            if(k == 1)  cout<<pow_mod(m,n,MOD)<<endl;
            else if(k % 2)  cout<<m*m<<endl;
            else            cout<<m<<endl;
        }
    }
    return 0;
}

//  main.cpp
//  solve
//
//  Created by Ahmed on 11/16/16.
//  Copyright © 2016 Abdellah. All rights reserved.
//

#include<set>
#include<map>
#include <unordered_map>
#include <unordered_set>
#include<list>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<complex>
#include<sstream>
#include<iostream>
#include<fstream>
#include<algorithm>
#include<numeric>
#include<utility>
#include<functional>
#include<stdio.h>
#include<assert.h>
#include<memory.h>
#include<bitset>
#include<math.h>
#include <strings.h>

#define f first
#define s second
#define pb push_back
#define sz(a) (int)a.size()
#define lp(i,a,n) for(int (i)=(a);(i)<=(int)(n);(i)++)
#define lpd(i,n,a) for(int (i)=(n);(i)>=(a);--(i))
#define mp make_pair
#define clr(a,b) memset(a,b,sizeof a)
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e16
#define MX 1000000
#define X real()
#define Y imag()
#define polar(r,t) ((r)* exp(point(0,(t))))
#define length(a) hypot( (a).X , (a).Y )
#define angle(a) atan2( (a).Y , (a).X )
#define vec(a,b) ( (b) - (a) )
#define dot(a,b) (conj(a)*(b)).X
#define cross(a,b) (conj(a)*(b)).Y
#define lengthsqr(a) dot(a,a)
#define reflect(V,M) (conj((V)/(M)) * (M))
#define normalize(a)   ((a)/length(a))
#define ccw(a,b,c)   cross(vec(a,b) , vec(a,c)) > -eps
#define cosRule(a,b,c) (acos(((a)*(a)+(b)*(b)-(c)*(c))/(2*(a)*(b))))
#define cosDot(a,b) (acos(dot(a,b)/length(a)/length(b)))
#define EQ(a,b) (fabs((a) - (b)) <= eps) /* equal to */
#define NE(a,b) (fabs((a) - (b)) > eps)  /* not equal to */
#define LT(a,b) ((a) < (b) - eps)        /* less than */
#define GT(a,b) ((a) > (b) + eps)        /* greater than */
#define LE(a,b) ((a) <= (b) + eps)       /* less than or equal to */
#define GE(a,b) ((a) >= (b) - eps)       /* greater than or equal to */
#define mod1 100050001
#define mod2 100030001
#define base1 37
#define base2 31
#define que priority_queue<pair<int,int>, vector<pair<int,int>> , greater<pair<int,int> > >
#define rotate(v,t) ((v)*exp(point(0,t)))
#define rotateabout(v,t,a) (rotate(vec(a,v),t)+(a))
#define PI atan(1)*4

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
typedef complex<long double> point;
typedef pair<point, point> line;
typedef pair<double , point> Circle;

//const int N = 200002;
int n,m,k;

ll power(ll b,ll p) {
    if(!p) return 1;
    ll ret = power(b, p>>1);
    return ret*ret%mod*(p&1?b:1)%mod;
}
int main()
{

    scanf("%d%d%d",&n,&m,&k);

    if(k > n || k == 1)
        return printf("%lld\n",power(m, n)) ,0 ;
    if(k == n)
        return printf("%lld\n",power(m, ceil(n/2.0))) , 0;

    ll ans = m;

    if(k&1)
        ans = (ans + m*(m-1)%mod)%mod;
    printf("%lld\n",ans);
    return 0;
}

/*
 */
//freopen("output.txt","w",stdout);
//freopen("input.txt","r",stdin);
//ios::sync_with_stdio(0);cin.tie(0);

#include <iostream>

using namespace std;

long long mod = 1e9 + 7;

long long pow(long long a, long long n) {
    long long ans = 1;
    for (long long i = 1; i <= n; ++i) {
        ans *= a;
        ans %= mod;
    }
    return ans;
}

int main() {
    long long n, m, k;
    cin >> n >> m >> k;
    if (n == 1) {
        cout << m;
        return 0;
    }
    if (k > n || k == 1) {
        cout << pow(m, n);
        return 0;
    }
    if (k == n) {
        cout << pow(m, (n + 1) / 2);
        return 0;
    }
    if (k % 2 == 1) {
        cout << m * m;
    } else {
        cout << m;
    }
    return 0;
}

#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long INT;
int calc_power(int a,int b){
	if(!b) return 1;
	int ans=calc_power(a,b/2);
	ans=(INT)ans*ans%mod;
	if(b&1) ans=(INT)ans*a%mod;
	return ans;
}
int main(){
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n,m,k;
	cin>>n>>m>>k;
	if(k==1 or k>n)cout<<calc_power(m,n)<<endl;
	else if(n==k) cout<<calc_power(m,(n+1)/2);
	else if(k&1) cout<<m*m<<endl;
	else cout<<m<<endl;
	return 0;
}

#include<bits/stdc++.h>
#define reg register
#define inl inline
#define int long long
using namespace std;
const int Mod=1e9+7;
int n,m,k;
inl int Pow(reg int x,reg int y)
{
	reg int res=1;
	for(;y;y>>=1,x=x*x%Mod) if(y&1) res=res*x%Mod;
	return res;
}
signed main()
{
	scanf("%lld %lld %lld",&n,&m,&k);
	if(k==1 || k>n) printf("%lld\n",Pow(m,n));
	else if(k==n) printf("%lld\n",Pow(m,(n+1)/2));
	else if(k&1) printf("%lld\n",Pow(m,2));
	else printf("%lld\n",m);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
ll power(ll x,ll y){
  if(y<=0) return 1;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  else return ((z*z)%mod);
}
int main(){
  ll n,m,k,e;
  cin>>n>>m>>k;
  // let graph between ith and (length-i)th connecting each other means ith and (length-i)th  are equal
  // sol ans= m^e where e=components of graph
  if(k==1 || k>n) e=n;
  else if(k==n) e=(n+1)/2;
  else if(k%2==1) e=2;
  else if(k%2==0) e=1;

  cout<<power(m,e)<<endl;
}

#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int Mod = 1e9 + 7;
long long Power(long long a,long long p)
{
	long long ans = 1;
	for(int i = 1;i <= p;i ++)ans = ans * a % Mod;
	return ans;
}
int main ()
{
	long long n,m,k;
	scanf("%I64d%I64d%I64d",&n,&m,&k);
	if(k % 2 == 0 && k < n)printf("%I64d\n",m);
	if(k == 1 || k > n)printf("%I64d\n",Power(m,n) % Mod);
	else if(k == n)printf("%I64d\n",Power(m,(n + 1) >> 1) % Mod);
	else if(k & 1)printf("%I64d\n",1ll * m * m % Mod);
	return 0;
}

#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<ctime>

using namespace std;
int const M=1e9+7;
int n,m,k,cnt,ans;

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    if(k>n)
    {
        ans=1;
        for(int i=0;i<n;++i)
            ans=(ans*1LL*m)%M;
    }
    else
    if(n==k)
    {
        ans=1;
        for(int i=0;i<(n+1)/2;++i)
        {
            ans=(ans*1LL*m)%M;
        }
    }
    else
    {
        if(k&1)
        {
            if(k>1)
                ans=m*m;
            else
            {
                ans=1;
                for(int i=0;i<n;++i)
                {
                    ans=(ans*1LL*m)%M;
                }
            }
        }
        else
            ans=m;
    }
    printf("%d",ans);

    return 0;
}

/*
 * Quantity of Strings.cpp
 *
 *  Created on: 2012-2-18
 *      Author: jing
 */
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
using namespace std;
const int oo = 1000000000;
const int MOD = 1000000007;

int bspow (int a, int b)
{
    int ans = 1;
    while (b)
    {
        if (b & 1)
            ans = (long long)ans * a % MOD;
        a = (long long)a * a % MOD;
        b >>= 1;
    }
    return ans;
}

int n, m, k;

int main ()
{
    while (scanf ("%d%d%d", &n, &m, &k) != EOF)
    {
        if (k > n)
        {
            printf ("%d\n", bspow(m, n));
            continue;
        }
        if (k == 1)
        {
            printf ("%d\n", bspow(m, n));
            continue;
        }
        if (k % 2 == 0)
        {
            if (n == k)
                printf ("%d\n", bspow(m, k / 2));
            else
                printf ("%d\n", m);
        }
        else
        {
            if (n == k)
                printf ("%d\n", bspow(m, k / 2 + 1));
            else
                printf ("%d\n", m * m);
        }
    }
}

#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;

#define ll long long

const ll Mod = 1000000007;
const int Max = 2000;

vector< vector<int> > v;

int parent[Max];

void init(int n) {
    for (int i = 0; i < n; i++) {
        parent[i] = i;
    }
}

int findParent(int u) {
    if (parent[u] == u) {
        return u;
    }
    else {
        return parent[u] = findParent(parent[u]);
    }
}

bool unite(int u, int v) {
    u = findParent(u);
    v = findParent(v);

    if (u != v) {
        if (rand() & 1) {
            parent[u] = v;
        }
        else {
            parent[v] = u;
        }

        return true;
    }
    else {
        return false;
    }
}

int main() {
    int n, m, k;
    cin >> n >> m >> k;

    init(n);
    v.resize(n);
    int count = n;

    int center;

    if (k <= n) {
        if (k % 2 == 0) {
            for (int i = k / 2; i <= n - k / 2; i++) {
                int j1 = i - 1;
                int j2 = i;

                int cnt = k;
                while (cnt > 0) {
                    if (unite(j1, j2)) {
                        count--;
                    }
                    j1--;
                    j2++;
                    cnt -= 2;
                }
            }
        }
        else {
            for (int i = k / 2; i < n - k / 2; i++) {
                int j1 = i;
                int j2 = i;

                int cnt = k - 1;
                while (cnt >= 0) {
                    if (unite(j1, j2)) {
                        count--;
                    }
                    j1--;
                    j2++;
                    cnt -= 2;
                }
            }
        }

    }

    //cout << count << endl;

    ll res = 1;
    for (int i = 0; i < count; i++) {
        res = (res * m) % Mod;
    }

    cout << res << endl;

    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <memory.h>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define ppb pop_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;

vi p;

int dsu_get(int a)
{
    return (a==p[a] ? p[a] : p[a] = dsu_get(p[a]));
}

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    p = vi(n+2);
    for (int i = 1; i <= n; i++)
        p[i] = i;
    for (int i = 1; i <= n-k+1; i++)
        for (int j = i; j <= (i+(i+k-1)-1) >> 1; j++)
        {
            int tmp = dsu_get(i+(i+k-1)-j);
            int TMP = dsu_get(j);
            if (tmp != TMP)
                p[TMP] = tmp;
        }
    vi f(n+2);
    for (int i = 1; i <= n; i++)
        f[i] = dsu_get(i);
    int tmp = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            if (f[j] == i)
            {
                tmp++;
                break;
            }
    ll ans = 1;
    for (int i = 0; i < tmp; i++)
        ans = (ans*m) % (1000000007);
    cout << ans << endl;
    return 0;
}

        /*----------------------------------*\
        ******BISMILLAHIR RAHMANIR RAHIM******
        ********************
        *****************
        /*************************************/

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define NL printf("\n")
#define xx first
#define yy second
#define gc getchar
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define scani(x) scanf("%d",&x)
#define scanl(x) scanf("%lld",&x)//scanf("%I64d",&x)
#define scand(x) scanf("%lf",&x)
#define scans(x) scanf("%s",x)
#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(i=j;i<=k;i++)
#define REV(i,j,k) for(i=j;i>=k;i--)
#define READ(f) freopen(f,"r",stdin)
#define WRITE(f) freopen(f,"w",stdout)
#define cnd tree[idx]
#define lnd tree[idx*2]
#define rnd tree[(idx*2)+1]
#define lndp (idx*2),(b),((b+e)/2)
#define rndp (idx*2+1),((b+e)/2+1),(e)
#define pi 2.0*acos(0.0)
#define MOD 1000000007
#define MAX 100005
#define PRINT_CASE(x) printf("Case %d:",cs);

#define sc1(a)  scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)
#define sc3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define pi1(a) printf("%lld",a)
#define pi2(a,b) printf("%lld %lld",a,b)
#define pi3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define sp printf(" ")
#define yes printf("YES")
#define no printf("NO")

#define all(v) v.begin(),v.end()

template <typename T> inline T GCD (T a,T b ) {a = abs(a);b = abs(b);while ( b ) { a = a % b; swap ( a, b ); } return a;}
template <typename T> inline T LCM(T x,T y){T tp = GCD(x,y);if( (x / tp) * 1. * y > 9e18) return 9e18;return (x / tp) * y;}
template <typename T> inline T BigMod(T A,T B,T M){T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T InvMod (T A,T M){return BigMod(A,M-2,M);}
ll gcdr ( ll a, ll b )
{
  if ( a==0 ) return b;
  return gcdr ( b%a, a );
}
/*
ll poW(ll x, ll n)
{
    if(n==0)
        return 1;
    else if(n%2==0)
        return poW(x*x,n/2);
    else
        return x*poW(x*x,((n-1)/2));
}
*/
/*
int gcdr ( int a, int b )
{
  if ( a==0 ) return b;
  return gcdr ( b%a, a );
}

const int maxx=1000000;
int status[(maxx>>5)+2];

bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}
int Set(int N, int pos)
{
    return N=(N|(1<<pos));
}
vector<int>P_list;
void sieve()
{
    int i,j,sqrtN;
    sqrtN=int(sqrt(maxx))+1;
    P_list.push_back(2);
    for(int i=3;i<=maxx;i+=2)
    {
        if(check(status[i>>5],i&31)==0)
        {
            P_list.push_back(i);

            if(i<=sqrtN)
            for(j=i*i;j<=maxx;j+=(i<<1))
            {
                status[j>>5]=Set(status[j>>5],j & 31);
            }
        }
    }
}
*/
ll max(ll a,ll b){
    if(a>b) return a;
        return b;
}
ll min(ll a, ll b){
    if(a<b)return a;
            return b;
}
void FastIO()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cout.precision(20);
}
const ll size3=300005;
const ll size2=200005;
const ll size1=100005;
/*
void graph(ll n){
    if(n==0) return ;
    for(ll i=0;i<n;i++){
        ll x,y;
        sc2(x,y);
        G[x].pb(y);
        G[y].pb(x);
    }
    return ;
}
*/
ll visited[200000]={0};
int main()
{
    ///FastIO();
    ll t,i,j,m,x,y,n;
    //sc1(t);
    ll k;
    t=1;
    ll mod=1000000007LL;
    while(t--){
        sc1(n);sc1(m);sc1(k);
        /// Jodi k=1 hoy then shob dhoroner Combination Valid.... So ans Must be m^n..
        /// Jodi k>n hoy then shob dhoroner combination valid karon tokhon ar palindrom
        ///Banano possible na...
        if(k==1 || (k>n)){
            ll ans=1;
            for(i=1;i<=n;i++){
                ans=(ans*m)%mod;
            }
            pi1(ans);NL;
        }
        /// Jodi k==n hoy then akta Palindrome bivinno vabe hoite pare she khetre
        /// Majh orthat n/2+(n%2) porjonto check korlei hoy..... n/2 porjonto combination korte
        /// hobe baki ongshoto same e hobe..
        else if(k==n){
            ll mid=n/2+(n%2);
            ll ans=1;
            for(i=1;i<=mid;i++){
                ans=(ans*m)%mod;
            }
            pi1(ans);NL;
        }
        else{
            /// jodi k Bijor hoy then cbcbcbc ai dhoroner combination valid..
            /// ar ai combination a kebol first duita change hoy ar first duita
            /// change hote pare m^2 upaye.... Jemon - aa, ab, ba,bb (2^2)
            if(k%2){
                ll ans=1;
                ans=m*m;
                pi1(ans);NL;
            }
            /// jodi jor hoy then aaaa,bbbb,cccc ai dhorober Combination sara possible naa..
            else{
                ll ans=m;
                pi1(ans);NL;
            }
        }

    }

    return 0;
}

#include <bits/stdc++.h>

using namespace std;

constexpr int N = 1000;
constexpr int MOD = 1000000007;

long long ans, n, m, k;

long long pw (long long a, long long b) {
    return b ? (pw (a * a % MOD, b >> 1) * (b & 1 ? a : 1)) % MOD : 1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> m >> k;
    if (n < k) {
        ans = pw (m, n);
        cout << ans << '\n';
    }
    else if (n == k) {
        ans = pw (m, (k + 1) / 2);
        cout << ans << '\n';
    }
    else {
        if (k % 2 == 0) {
            cout << m << '\n';
        }
        else {
            if (k == 1)
                ans = pw (m, n);
            else
                ans = m * m;
            cout << ans << '\n';
        }
    }
    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <queue>
#include <complex>
#include <cassert>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(s) int((s).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define next _next
#define prev _prev
#define rank _rank

typedef long long ll;
typedef long long llong;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef complex <double> tc;

const int inf = int(1e9);
const double eps = 1e-9;
const double pi = 4 * atan(double(1));

int cc = 0;
int clr [2010];

int n,m,k;
void dfs( int v, int c ){

    clr[v] = c;
    for( int i = v-k+1; i <= v; i++ ){
        if( i<0 || (i+k-1)>=n ) continue;
        int m = 2*i + (k-1);
        int t = m-v;
        if( t>=0 && t<n &&!clr[t] )
            dfs(t,c);
    }
}

ll powmod( ll a, ll n, ll m ){
    ll res = 1;
    while (n) {
        if (n & 1)
            res = (res*a)%m;
        a = (a*a)%m;
        n >>= 1;
    }
    return res;
}

int main(){
    cin>>n>>m>>k;
    for( int i = 0; i < n; i++ ){
        if( clr[i] ) continue;
        dfs(i,++cc);
    }
    cout<<powmod(m,cc,1000000007);
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define ld long double
ll power(ll x,ll y)
{
    if(y==0)
    return 1ll;
    if(y==1)
    return  x;
    if(y%2==0)
    {
      ll  z=power(x,y/2)%mod;
        return (z*z)%mod;
    }
    else
    {
    return  (x%mod*power(x,y-1)%mod)%mod;
    }

}
int main()
{
	fast;
	ll n,m,k;
	cin>>n>>m>>k;
	if(k==1)
	{
		cout<<power(m,n);
		return 0;
	}
	if(n<k)
	cout<<power(m,n);
	else if(n==k)
	{
		if(k%2==1)
		cout<<power(m,n/2+1);
		else
		cout<<power(m,n/2);

	}
	else
	{
		if(k%2==0)
		cout<<m;
		else
		cout<<m*(m-1)+m;
	}
	return 0;
}

#include<cstdio>

#define MOD 1000000007
typedef long long LL;

LL powMod(LL x,int y,LL mod){
  if(y<1)return 1;
  if(y%2)return x*powMod(x,y-1,mod)%mod;
  return powMod(x*x%mod,y/2,mod);
}

int main(){
  int n,m,k;
  scanf("%d%d%d",&n,&m,&k);
  if(k==1 || k>n){
    printf("%d\n",(int)powMod(m,n,MOD));
  }else if(n==k){
    printf("%d\n",(int)powMod(m,(n+1)/2,MOD));
  }else{
    if(k%2){
      printf("%d\n",m*m);
    }else{
      printf("%d\n",m);
    }
  }
  return 0;
}

/**
 *   author: Shubham Srivastava
 *   created: 19 May 2019  19:03:53
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 0x7fffffff
#define sorti(v) sort(v.begin(),v.end())
#define sortd(v) sort(v.rbegin(),v.rend())
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;
ll parent[2000005];
ll power(ll x,ll n)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%MOD,n/2)%MOD;
    else
        return (x*power((x*x)%MOD,(n-1)/2))%MOD;

}

ll find_parent(ll x)
{
	if(x == parent[x])
		return x;
	return parent[x] = find_parent(parent[x]);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,k;cin>>n>>m>>k;
    for(int i=0;i<=n;i++)
    	parent[i] = i;
    for(int i=1;i<=(n-k)+1;i++)
    {
    	ll a,b;
    	a = i;
    	b = i+k-1;
    	while(a<b)
    	{
    		ll x,y;
    		x = find_parent(a);
    		y = find_parent(b);
    		if(x != y)
    			parent[x] = y;
    		a++;
    		b--;
    	}
    }
    set <ll> s;
    for(int i=1;i<=n;i++)
    {
    	s.insert(find_parent(parent[i]));
    }
    cout<<power(m,s.size());
return 0;
}

#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

#define MAXN 1000
#define INF 1000000000
int n, m, k;
long long C(int N, int K) {
    if (K == 0)
        return 1;
    if (N == 0)
        return 0;
    return (C(N - 1, K - 1) + C(N - 1, K)) % (INF + 7);

}

int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cin >> n >> m >> k;

    if (k == 1 || k > n) {
        long long ans = 1;
        for (int i = 0; i < n; i++) {
            ans *= m;
            ans %= (long long)(INF + 7);
        }
        cout << ans << endl;
        return 0;
    } else if (k == n) {
        long long ans = 1;
        long long p = n / 2;
        if (n % 2 == 1)
            p++;
        for (int i = 0; i < p; i++) {
            ans *= m;
            ans %= (long long)(INF + 7);
        }
        cout << ans << endl;
        return 0;
    } else {
        if (n == 1) {
            cout << m << endl;
        } else if (k % 2 == 0) {
            cout << m << endl;
        } else {
            cout << m * m << endl;
        }

    }

    return 0;
}

#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
typedef pair<int, int> pii;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}
ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
ll fonk(ll n){
	return n*(n+1)/2;
}
vector<vector<int>> vec(2005);
vector<bool> vis(2005);
void dfs(int cur){
	vis[cur] = true;
	for(auto &x: vec[cur]){
		if(!vis[x]) dfs(x);
	}
}
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, m, k; cin>>n>>m>>k;
	for(int i = 0; i < n; i++){
		if(i + k - 1 < n){
			for(int u = i; u < (i+k); u++){
				vec[u].push_back(k + 2*i - 1 - u);
			}
		}
	}
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(!vis[i]){
			dfs(i);
			cnt++;
		}
	}
	ll tmp = 1;
	for(int i = 0; i < cnt; i++) tmp = (tmp * m) % mod;
	cout<<tmp<<endl;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define fu(i,a,n) for(i=a;i<=n;i++)
#define fd(i,a,n) for(i=a;i>=n;i--)
#define rep(i,n)  for(i=0;i<n;i++)
#define si(i)  scanf("%d",&i)
#define ss(s)  scanf("%s",s)
#define sl(i)  scanf("%lld",&i)
#define pi(i)  printf("%d",i)
#define pl(i)  printf("%lld",i);
#define ps()   printf(" ");
#define pn()   printf("\n");
#define all(v)  v.begin(),v.end()
#define vi vector <int>
#define vl vector <ll>
#define N 2005
ll par[N];
void make(ll n)
{
  ll i;
  fu(i,1,n)
  {
    par[i]=i;
  }
}
ll fp(ll x)
{
  if(x==par[x])
  {
    return x;
  }
  return par[x]=fp(par[x]);
}
void uni(ll a,ll b)
{
  ll pa=fp(a);
  ll pb=fp(b);
  if(pa!=pb)
  {
    par[pa]=pb;
  }
}
int main()
{
  ll n,m,k,i,j,x,ans,l,r;
  ll mod=1e9+7;
  sl(n);sl(m);sl(k);
  make(n);
  fu(i,0,n-k)
  {
      l=i+1;
      r=i+k;
      while(l<r)
      {
        uni(l,r);
        l++;r--;
      }
  }
  ans=1;
  fu(i,1,n)
  {
    if(i==fp(i))
    {
      ans*=m;
      ans%=mod;
    }
  }
  pl(ans);pn();
  return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

long long binpow(int n, int m, int mod) {
  if (m == 0) {
    return 1;
  }
  if (m % 2 == 1) {
    return (binpow(n, m - 1, mod) * n) % mod;
  } else {
    long long c = binpow(n, m / 2, mod);
    return (c*c) % mod;
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  int n, m, k;
  cin >> n >> m >> k;
  long long mod = 1000000007;
  if (k > n || k == 1) {
    cout << binpow(m, n, mod);
  } else if (k == n) {
    cout << binpow(m, (n + 1) / 2, mod);
  } else if (k % 2 == 1) {
    cout << m * m;
  } else {
    cout << m;
  }
  return 0;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <cctype>
#include <algorithm>
#include <climits>
#include <queue>
#include <functional>
#include <map>

#define FOREACH(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)

#define ALL(c) (c).begin(), (c).end()
#define F first
#define S second
#define INS insert
#define MP make_pair
#define PB push_back
#define LL long long
#define ULL unsigned long long

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

template <class T> inline T MAX(T a, T b) { if (a > b) return a; return b; }
template <class T> inline T MIN(T a, T b) { if (a < b) return a; return b; }
template <class T> inline T ABS(T x) { if (x < 0) return -x; return x; }

inline void OPEN(const string &s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

const static int inf = 2123123123;

#define MOD 1000000007

int n,m,k;

int main(){
    scanf("%d%d%d",&n,&m,&k);
    if(k > n || k == 1){
        LL res = 1;
        REP(i,n){
            res = (res * m) % MOD;
        }
        printf("%I64d\n",res);
    }else{
        if(k % 2 == 0){
            if(n != k){
                printf("%d\n",m);
            }else{
                LL res = 1;
                REP(i,n/2 + (n%2)){
                    res = (res * m) % MOD;
                }
                printf("%I64d\n",res);
            }
        }else{
            if(n != k){
                LL ret = m * m % MOD;
                printf("%I64d\n",ret);
            }else{
                LL res = m;
                REP(i,n - (n/2) - (n%2)){
                    res = (res * m) % MOD;
                }
                printf("%I64d\n",res);
            }
        }
    }
    return 0;
}

/* long long or int */
/* xx 396*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

const int MAX_N=2e3+10;
const ll MOD=1e9+7;

vector <int> G[MAX_N];
ll ans=1;
int n,m,k,cnt=0;
bool vis[MAX_N];

void dfs(int x){
	for(int i=0;i<G[x].size();i++){
		int to=G[x][i];
		if(!vis[to]){
			vis[to]=1;
			dfs(to);
		}
	}
}

int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=0;i<=n-k;i++){
		for(int j=0;j<k/2;j++){
			G[j+i].push_back(k-1-j+i);
			G[k-1-j+i].push_back(j+i);
		}
	}
	for(int i=0;i<n;i++){
		if(!vis[i]){
			cnt++;
			vis[i]=1;
			dfs(i);
		}
	}
	for(int i=0;i<cnt;i++) ans=ll(ans*m)%MOD;
	printf("%lld",ans);
	return 0;
}

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n, m, k;
  cin >> n >> m >> k;
  int res = 0;
  if(k == 1 || k > n){
    res = 1;
    for(int i = 0; i < n; i++){
      res = mul(res, m);
    }
  }
  else if(k == n){
    res = 1;
    for(int i = 0; i < n / 2 + (n % 2); i++){
      res = mul(res, m);
    }
  }
  else if(k % 2 == 0){
    res = m;
  }
  else{
    res = mul(m, m - 1);
    res = add(res, m);
  }
  cout << res;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define N 100005
#define mp make_pair
#define pb push_back
#define f first
#define se second
#define p 1000000007
int bexpo(int x,int n){
	if(n==0)return 1;
	else if(n%2==0)return bexpo(x*x,n/2);
	else return x*bexpo(x*x,(n-1)/2);
}
ll power_mod(ll x,ll y){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
bool isPrime(ll n){if (n <= 1)
    return false; if (n <= 3)  return true; if (n%2 == 0 || n%3 == 0) return false;
    for (ll i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false;return true;}
    	int n,k;
bool check(int mid,int a[],int ind)
{
	int cnt=0,i;
	for(i=0;i<n;i++)
	{
		if(mid>=a[i] && cnt%2==ind)
			cnt++;
		else if(cnt%2!=ind)
			cnt++;
	}
	return cnt>=k;

}
ll gcd(ll a,ll b){if(!b)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
int main()
{

    	ll n,m,k;
    	cin>>n>>m>>k;
    	if(k==1 || k>n)
    		cout<<power_mod(m,n);
    	else if(k==n)
    		cout<<power_mod(m,(n+1)/2);
    	else if(k%2)
    		cout<<power_mod(m,2);
    	else
    		cout<<power_mod(m,1);

}

#include<bits/stdc++.h>
using namespace std;
typedef  long long d;
d a=1000000007;
int main()
{
int m,n,k,i;
d sum=1;
while(~scanf("%d%d%d",&n,&m,&k))//ֻҪ����������Ͳ��������
{
if(k<n&&k%2==0)//
{
cout<<m;
continue;
}
if(k==n)
{
if(n%2)
{
    sum=m;
	for(i=1;i<=k/2;++i)
	sum=sum*m%a;
}
else
{
	for(i=1;i<=k/2;++i)
	sum=sum*m%a;
}
}
else if(k>n||k==1)
{
	for(i=1;i<=n;++i)
	{
		sum=sum*m%a;
	}
}
else
{
if(!n%2)
{
	sum=m;
}
else
{
	sum=m*m;
}
}
cout<<sum;
}
return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<set>
#include<stack>
#include<map>
#include<ctime>
#include<bitset>
#define LL long long
#define ll long long
#define INF 4365899
#define maxn 200010
#define eps 1e-6
#define mod 1000000007
using namespace std;

LL pow1(int a,int n )
{
    if(n==0)return 1;
    LL ans=pow1(a,n/2) ;
    ans=ans*ans%mod;
    if(n&1)ans=ans*a%mod;
    return ans;
}
int main()
{
    int i,j;
    LL n ,m , k ;
    while(scanf("%I64d%I64d%I64d",&n,&m,&k ) != EOF )
    {
        if(k<n&&k != 1){
             if(k%2==0)
             {
                 cout << m << endl;
             }
             else cout << m*(m-1)+m << endl;
        }
        else if(k>n||k==1)
        {
            cout << pow1(m,n) << endl;
        }
        else
        {
            cout << pow1(m,(n+1)/2) << endl;
        }
    }
    return 0 ;

}
/*
7 4 20
10 23 9
529
*/

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <string.h>
#include <set>
#include <queue>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#define mo 1000000007
using namespace std;
int main()
{
	int n,m,k;
	while(cin>>n>>m>>k)
	{
		if(k < n)
		{
			int mark[2002];
			long long sum=1;
			memset(mark,0,sizeof mark);
			if(k%2==1 && k!=1)
			for(int i=2;i<n;i++)
			{
				bool b=0;
				int k=0;
				for(int j=0;j<n;j++)
				{
					if(mark[j]==0)
					{
						k=j;
						b=1;
						break;
					}
				}
				if(!b)
				break;
				sum*=m;
				sum%=mo;
				mark[k]=1;
				for(int j=k;j<n-i;j++)
				{
					mark[i+j]=1;
				}
			}
			else if(k!=n && k%2==0)
			sum=m;
			else if(k==1)
			for(int i=0;i<n;i++)
			{
				sum*=m;
				sum%=mo;
			}
			cout<<sum<<endl;
		}
		else
		{
			long long sum=1;
			if(n < k)
			for(int i=0;i<n;i++)
			{
				sum*=m;
				sum%=mo;
			}
			else
			{
				int p=0;
				if(n%2)
				p++;
				for(int i=0;i<n/2+p;i++)
				{
					sum*=m;
					sum%=mo;
				}
			}
			cout<<sum<<endl;
		}
	}
	return 0;
}

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

struct DSU {
	vector<int> rank, parent, size;
	int forsets;
	DSU(int n) {
		size = rank = parent = vector<int>(n + 1, 1);
		forsets = n;
		for (int i = 0; i <= n; i++) {
			parent[i] = i;
		}
	}
	int find_set(int v) {
		if (v == parent[v])
			return v;
		return parent[v] = find_set(parent[v]);
	}
	void link(int par, int node) {
		parent[node] = par;
		size[par] += size[node];
		if (rank[par] == rank[node])
			rank[par]++;
		forsets--;
	}
	bool union_sets(int v, int u) {
		v = find_set(v), u = find_set(u);
		if (v == u)
			return false;
		if (rank[v] < rank[u])
			swap(v, u);
		link(v, u);
		return true;
	}
	bool same_set(int v, int u) {
		return find_set(v) == find_set(u);
	}
	int size_set(int v) {
		return size[find_set(v)];
	}
};

const int mod = 1e9 + 7;
ll power(ll x, ll y) {
	if (y == 0)
		return 1;
	if (y == 1)
		return x;
	ll r = power(x, y >> 1);
	return (((r * r) % mod) * power(x, y & 1)) % mod;
}
int main() {
	run();
	int n, m, k;
	cin >> n >> m >> k;
	DSU uf(n);
	for (int i = 0; i <= n; i++) {
		for (int pos = 0, nxt = k - 1; pos < nxt && pos <= i; pos++, nxt--) {
			if (i + k - pos > n)
				continue;
			int j = i - pos + nxt;
			if (j < n)
				uf.union_sets(i, j);
		}
	}
	cout << power(m, uf.forsets) << endl;

}

#include<stdio.h>
typedef __int64 IN64;
int main(){
	IN64 n,m,k,pmod=1000000007,ans;
	scanf("%I64d%I64d%I64d",&n,&m,&k);
	if(k<=1)
	{
		for(ans=1;n;n--)
			ans=(ans*m)%pmod;
		printf("%I64d\n",ans);
	}
	else if(n<k )
	{
		for(ans=1;n;n--)
			ans=(ans*m)%pmod;
		printf("%I64d\n",ans);
	}
	else if(n==k)
	{
		if(k%2==0)
			n/=2;
		else
			n=(n/2)+1;
		for(ans=1;n;n--)
			ans=(ans*m)%pmod;
		printf("%I64d\n",ans);
	}
	else
	{
		if(k%2==0)
			printf("%I64d\n",m);
		else
			printf("%I64d\n",(m*m)%pmod);
	}
	return 0;
}

#include<iostream>
#include<cmath>
#define c 1000000007
using namespace std;
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    if(n==k)
    {
        long long count=1;
        for(int i=1;i<=(n+1)/2;i++)
        {
            count=count*m%c;
        }
        cout<<count;
    }
    else
    {
        if(k==1||k>n)
        {
            long long count=1;
            for(int i=1;i<=n;i++)
            count=count*m%c;
            cout<<count;
        }
        else
        {
            cout<<(int)pow(m,1+(k&1));
        }
    }

}

#include <iostream>
using namespace std;

int main()
{
    const long long M = 1000000007;
    long long n, m, k;

     cin >> n >> m >> k;

     long long output(1);
      if(k==1 || k>n){
    	for(long long i=0;i<n;i++){
    		output=(output*m)%M;
    	}
      }
      else if(k == n){
    	for(long long i=0;i<(n+1)/2;i++){
    		output=(output*m)%M;
    	}
      }
      else if(k%2==1){
    	output=(m*m)%M;
      }
      else if(k%2==0){
    	output=m;
      }
       cout << output << endl;
    return 0;
}

#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<memory.h>
#include<queue>
#include<complex>
using namespace std;

long long mod = 1000000007;
long long calc(int base, int p) {
	long long ans = 1;
	for(int i=0;i<p;i++)
		ans = (ans*base)%mod;
	return ans;
}

int main()	{
#ifndef ONLINE_JUDGE
	freopen("2.in","rt",stdin);
NEXT:
#endif

	int n,m,k;
	cin>>n>>m>>k;
	if(cin.fail()) return 0;

	long long ans = 0;
	if(k == 1 || k > n)
		ans = calc(m,n);
	else if(k == n)
		ans = calc(m,(n+1)/2);
	else if(k%2)
		ans = calc(m, 2);
	else
		ans = m;

	cout<<ans<<endl;

#ifndef ONLINE_JUDGE
	goto NEXT;
#endif
	return 0;
}

#include<stdio.h>
#include<string.h>

#define maxm 2050
#define mod 1000000007
#define ii __int64

int n,m,K,pre[maxm];

int find(int x){
    if(pre[x]==x) return x;
    return pre[x]=find(pre[x]);
}
void add(int ind);
ii big_mod(int b,int p,int m){

    if(p==0) return 1;
    if(p==1) return b%m;

    ii ret;
    ret=big_mod(b,p/2,m);
    ret*=ret; ret%=m;
    if(p%2) ret*=b;
    ret%=m;
    return ret;

}

int main(){

    int i,j,k,l,test,t=1;

    //freopen("in.txt","r",stdin);

    scanf("%d %d %d",&n,&m,&K);

    for(i=1;i<=n;i++){
        pre[i]=i;
    }

    for(i=1;i<=n-K+1;i++){
        add(i);
    }
    int ret=0;

    for(i=1;i<=n;i++){
        if(pre[i]==i) ret++;
    }
    int ans=big_mod(m,ret,mod);

    printf("%d\n",ans);

    return 0;
}

void add(int ind){

    int i,j,k,l;

    for(i=ind,j=ind+K-1;i<j;i++,j--){
        k=find(i);
        l=find(j);
        if(k==l) continue;
        pre[k]=l;
    }
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
const int maxn = 2000 + 10;
const int inf = numeric_limits<int>::max();
const int mod = 1000 * 1000 * 1000 + 7;
ll qmod_pow(ll a, ll p) {
	ll res = 1;
	while (p) {
		if (p & 1) {
			res *= a;
			res %= mod;
		}
		a *= a;
		a %= mod;
		p >>= 1;
	}
	return res;
}
ll An2(ll n) {
	return n*(n-1);
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n, m, k;
	while (cin >> n >> m >> k) {
		if (n < k) {
			cout << qmod_pow(m, n) << endl;
		}
		else if (n == k) {
			cout << qmod_pow(m, (n + 1) / 2) << endl;
		}
		else {
			if (k == 1) {
				cout << qmod_pow(m, n) << endl;
			}
			else if (k == 2) {
				cout << m << endl;
			}
			else {
				if (k & 1) {
					cout << (An2(m) + m) % mod << endl;
				}
				else {
					cout << m << endl;
				}
			}
		}
	}
	return 0;
}

#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
long long n,m,k;
long long rez;
long long rasp;
long long nr;
int main()
{
cin>>n>>m>>k;

    nr=(k+1)/2;
    rasp=1;
    if(k==1)
    {
        for(int i=1;i<=n;++i)
        {
        rasp=1LL*rasp*m;
        rasp=rasp%1000000007;
        }
        cout<<rasp;
        return 0;
    }
    if(k>n)
    {
        for(int i=1;i<=n;++i)
        {
        rasp=1LL*rasp*m;
        rasp=rasp%1000000007;
        }
            cout<<rasp;
        return 0;
    }
  //  printf("%d\n",nr);
  if(k==n)
  {
    for(int i=1;i<=nr;++i)
        {
        rasp=1LL*rasp*m;
        rasp=rasp%1000000007;
        }
    cout<<rasp;
    return 0;
  }
  if(k%2==0)
  {
      cout<<m;
      return 0;
  }
  cout<<m*m;
return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 4001, M = 1e9+7;
int n, m, k, pa[N];

int find(int u){return pa[u] == u? u: pa[u] = find(pa[u]);}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("read.txt","r",stdin);
    #endif
    scanf("%d%d%d", &n, &m, &k);
    for(int i = 1; i<=n; ++i)pa[i] = i;
    for(int i = 1; i<=n-k+1; ++i){
       int r = i+k-1, ls = i+k-1;
       for(int j = i; j<i+k/2; ++j){
          pa[find(j)] = find(ls);
          --ls;
       }
    }
    set<int> st;
    for(int i = 1; i<=n; ++i)st.insert(find(i));
    ll an = 1;
    int c = st.size();
    while(c--){
    	 an = (1ll * an%M * m%M)%M;
    }
    printf("%lld\n", an);
}

#include <stdio.h>

int n,m,k;

long long mod=1e9+7;
long long pow(long long a, long long p) {
	long long res=1;
	while(p) {
		if(p&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		p>>=1;
	}
	return res;
}
int main() {
	scanf("%d %d %d",&n,&m,&k);
	if(k>n)
		printf("%lld\n",pow(m,n));
	else if(k==n) {
		if(n%2==0)
			printf("%lld",pow(m,n/2));
		else
			printf("%lld",pow(m,n/2+1));
	}
	else if(k==1)
		printf("%lld",pow(m,n));
	else if(k%2==0)
		printf("%d",m);
	else
		printf("%d",m*m);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define int long long int
#define el "\n"
#define P 1000000007
const int N = (int)2e5 + 10;

int Pow(int m, int n) {
    int t = 1;
    while (n > 0) {
        if (n & 1) t = (t * m) % P;
        m = (m * m) % P, n /= 2;
    }
    return t % P;
}

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(16);

    int n, m, k;
    cin >> n >> m >> k;
    if (k == 1 or k > n) {
        return cout << Pow(m, n), 0;
    }

    if (k == n)
        cout << Pow(m, (n + 1) / 2);
    else if (k % 2 == 0)
        cout << m % P;
    else
        cout << Pow(m, 2);

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define mod 1000000007
vector<int> parent,len;
int n,m,k;

int binomialCoeff(int n, int k)
{
    int res = 1;

    // Since C(n, k) = C(n, n-k)
    if ( k > n - k )
        k = n - k;

    // Calculate value of
    // [n * (n-1) *---* (n-k+1)] / [k * (k-1) *----* 1]
    for (int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}

void init(){
    parent.resize(n+1);
    len.resize(n+1);
    for(int i=1;i<=n;i++){
        parent[i] = i;
        len[i] = 1;
    }
}

int find(int n){
    if(parent[n] == n)
        return n;
    return parent[n] = find(parent[n]);
}

void un(int a, int b){
    int x = find(a);
    int y = find(b);

    if(x == y)
        return;
    if(len[x] < len[y])
        swap(x,y);
    parent[y] = x;
    len[x] += len[y];
}

signed main()
{
    cin>>n>>m>>k;
    init();
    for(int i=1;i<=n-k+1;i++){
        int left = i,right=i+k-1;
        while(left<right){
            if(find(left) != find(right))
            un(left,right);
            left++;
            right--;
        }
    }

    int ans = 1;
    for(int i=1;i<=n;i++){
        if(parent[i] == i)
            ans = (ans*m)%mod;
    }

    // cout<<n<<" "<<count<<endl;c
    cout<<ans;

    return 0;
}

#include <iostream>
#include <cstdio>
#include <cassert>
#include <bitset>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <cstring>
#include <queue>
#include <numeric>
#include <iomanip>
#define ll long long
using namespace std;
int n,m,k,parent[2005];
int find(int u){
    return u == parent[u] ? u : parent[u] = find(parent[u]);
}
void mrg(int u,int v){
    u = find(u);
    v = find(v);
    if(u == v)return;
    parent[u] = v;
}
const long long mod = 1e9+7;
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)parent[i] = i;
    for(int i=1;i<=n;i++){
        int front = i;
        int back = i + k - 1;  //길이가 k임
        if(back > n) break;
        for(int len=0;len<=k/2;len++){
            mrg(front+len,back-len);
        }
    }
    long long ans = 1;
    for(int i=1;i<=n;i++){
        if(i == find(i)){
            ans *= m; ans %= mod;
        }
    }
    cout<<ans;
    return 0;
}

#include <iostream>
#include <vector>
#define ll long long
using namespace std;
ll MOD = 1e9 + 7;
void Generador(vector<int> prev, vector<vector<int> > & acum, int L, int M)
{
    if(prev.size() == L)
    {
        acum.push_back(prev);
        return;
    }
    prev.push_back(0);
    int n = prev.size()-1;
    for(prev[n] = 1;prev[n]<=M;prev[n]++)
    {
        Generador(prev,acum,L,M);
    }
}
bool EsPalindromo(vector<int> v)
{
    int n = v.size();
    for(int i = 0;i*2<=n;i++)
        if(v[i]!=v[n-i-1])
            return false;
    return true;
}
bool Chequer(vector<int> v, int K)
{
    int n = v.size();
    for(int i = 0;i+K<=n;i++)
    {
        vector<int> c;
        for(int j = i;j<i+K;j++)
            c.push_back(v[j]);
        if(!EsPalindromo(c))
            return false;
    }
    return true;
}
int main()
{
    ll M,N,K;
    cin>>N>>M>>K;
    /*vector<vector<int> > acum;
    Generador({},acum,N,M);
    int Rg = 0;
    for(auto & k : acum)
        Rg += Chequer(k,K);
    cout<<Rg<<endl;*/
    /*if(K > N)
    {
        cout<<0<<endl;
        return 0;
    }*/
    if(K == N)
    {
        N = (N+1)/2;
        ll R = 1;
        for(int i = 0;i<N;i++)
            R = (R*M)%MOD;
        cout<<R<<endl;
        return 0;
    }
    if(K == 1 || K > N)
    {
        ll R = 1;
        for(int i = 0;i<N;i++)
            R = (R*M)%MOD;
        cout<<R<<endl;
        return 0;
    }
    if(K%2 == 1)
    {
        cout<<(M*M)<<endl;
        return 0;
    }
    cout<<M<<endl;
    return 0;
}

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

// Use g++ compiler for this include to work.
#include <bits/stdc++.h>

using namespace std;

// Constants
#define INF 1e18
#define EPS 1e-9
#define MOD 1000000007

// // for using in pairs
#define F first
#define S second

// Macros
#define all(x) begin(x), end(x)

// aliases
using ll = long long;
using ull = unsigned long long;
using ui = unsigned int;
using ld = long double;

// Temporary macro.
#define int long long

// Operator overloads.

/**
 * Both types in the pair should have overload for << operator with ostream.
 */
template<typename T1, typename T2>
ostream& operator<<(ostream &ostream, pair<T1, T2>& p)
{
	ostream << p.first << " " << p.second;
	return ostream;
}

/**
 * The type of element in the vector should have overload for << operator with ostream.
 */
template<typename T>
ostream& operator<<(ostream &stream, vector<T>& v)
{
	for (const auto &it : v)
		stream << it << " ";
	return stream;
}

template<typename T1, typename T2>
istream& operator>>(istream &istream, pair<T1, T2>& p)
{
	istream >> p.first >> p.second;
	return istream;
}

template<typename T>
istream& operator>>(istream &istream, vector<T>& a)
{
	for (auto &it : a)
		istream >> it;
	return istream;
}

// Utility functions.

template<typename T>
int32_t size_i(T& container)
{
	return static_cast<int32_t>(container.size());
}

int GCD(int a, int b)
{
	if (!b)
		return a;
	return GCD(b, a % b);
}

int LCM(int a, int b)
{
	return (a * b) / GCD(a, b);
}

int modpow(int x, int n, int m = MOD)
{
	if (n == 0) return 1 % m;
	long long u = modpow(x, n / 2, m);
	u = (u * u) % m;
	if (n % 2 == 1)
		u = (u * x) % m;
	return u;
}

//////////////////// START CODE HERE ///////////////////////////

void solve(int tc)
{
	int n, m, k;
	cin >> n >> m >> k;

	if (k == 1 || k > n)
	{
		cout << modpow(m, n);
	}else if (k == n)
	{
		cout << modpow(m, (n + 1) / 2);
	}else
	{
		int ans = m;
		if (k & 1)
			ans *= m;
		cout << ans;
	}
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int t = 1;
	// cin >> t;
	for (int i = 1; i <= t; i++)
	{
		solve(i);
	}

	return 0;
}

#include<bits/stdc++.h>
using namespace std;

int n,m,k;
const int MOD = (int)1e9 + 7;
const int N = 2222;
int id[N];
typedef long long ll;
void mult(ll &a,ll b)
{
      a = (a*1LL*b)%MOD;
}

int main()
{
#ifdef Srinu73
      freopen("in.txt", "r", stdin);
#endif
      cin>>n>>m>>k;
      for(int i=0;i<n;i++) id[i] = i;
      for(int start = 0;start+k <= n;start++)
      {
            for(int i=0;i<k-i-1;i++)
            {
                  int a = id[start + i], b = id[start + k-i-1];
                  if(a != b)
                  {
                        for(int j=0;j<n;j++)
                              if(id[j] == a) id[j] = b;
                  }
            }
      }
      ll res = 1;
      for(int i=0;i<n;i++)
      {
            if(id[i] == i) mult(res, m);
      }
      printf("%I64d\n",res);
      return 0;
}

#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
long long ans=1,n,m,k;
int main()
{
	cin >> n >> m >> k;
	if (k == 1 || k>n){
		for (int i = 1; i <= n; i++){ ans = (ans*m) % 1000000007; }
		cout << ans;
	}
	else if (k == n){
		for (int i = 1; i <= int((n + 1) / 2); i++){
			ans = (ans*m) % 1000000007;
		}
		cout << ans;
	}
	else if (k % 2 == 1){
		cout << m*m;
	}
	else{
		cout << m;
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define nt _int128
#define mod 1000000007
# define ppi pair<ll,pair<ll,ll>>
ll parent[100005],weight[100005];
void init()
{
	for(ll i=0;i<100005;i++)
	{
		parent[i]=i;
		weight[i]=1;
	}
}
ll root(ll a)
{
	while(a!=parent[a])
	{
		parent[a]=parent[parent[a]];
		a=parent[a];
	}
	return a;
}
void union1(ll a,ll b)
{
	ll pa=root(a),pb=root(b);
	if(weight[pa]>weight[pb])
	{
		parent[pb]=pa;
		weight[pa]+=weight[pb];
	}
	else
	{
		parent[pa]=pb;
		weight[pb]+=weight[pa];
	}
}
void func(ll i,ll j,ll k)
{
	while(k--)
	{
		if(root(i)!=root(j))
			union1(i,j);
		i++,j--;
	}
}
int main()
{
#ifndef ONLINE_JUDGE
   	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    // cin >> t;
    t  = 1;
    while(t--)
    {
    	ll n,m,k;
    	cin>>n>>m>>k;
    	init();
    	for(ll i=1;i<=n-k+1;i++)
    	{
    		func(i,i+k-1,k);
    	}
    	ll ans=1;
    	bool visi[n+1]={false};
    	for(ll i=1;i<=n;i++)
    	{
    		if(visi[root(i)]==false)
    		{
    			// cout<<root(i)<<endl;
    			ans=(ans*m)%mod;
    			visi[root(i)]=true;
    		}
    	}
    	cout<<ans;

    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long

#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>

#define infi INT_MAX
#define infl LONG_LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll>
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define deb printf("***************************************************************************************\n");
#define moshi printf("moshi moshi ! \n");
#define hi printf("hi ! \n");
#define bye printf("bye bye ! \n");

//const ll N=2e6+7;
ll p=1e9+7;
//ll fac[N];

inline ll ceil(ll a,ll b)
{
  return (a+b-1)/b;
}

ll max(ll x,ll y,ll z)
{
  return max(x,max(y,z));
}

ll modpro(ll x,ll y,ll z=1)
{
  x%=p;
  y%=p;
  z%=p;
  ll res=(x*y)%p;
  res=(res*z)%p;
  return res;
}

ll modadd(ll x,ll y,ll z=0)
{
  ll res=(x+y)%p;
  res=(res+z)%p;
  return res;
}

ll pow_mod_p(ll a,ll b)
{
  a=a%p;
  ll res=1;
  while(b>0)
  {
    if(b&1) res=(res*a)%p;
    b=b>>1;
    a=(a*a)%p;
  }
  return res;
}

inline ll mod_inv(ll x)
{
  return pow_mod_p(x,p-2);
}

/*
ll nCr(ll x,ll y)
{
  if(x<y) return 0;
  ll res=fac[x];
  ll den=(fac[y]*fac[x-y])%p;
  ll deni=mod_inv(den);
  res=(res*deni)%p;
  return res;
}*/

void func()
{
  ll n,m,k;
  cin>>n>>m>>k;

  if(m==1)
  {
    cout<<"1\n";
    return;
  }

  if(k<n)
  {
    if(k==1)
    {
      ll ans=pow_mod_p(m,n);
      pr(ans) nl
      return;
    }

    if(k%2==0)
    {
      cout<<m<<endl;
      return;
    }
    ll ans=m*m;
    pr(ans) nl
  }

  else if(k==n)
  {
    ll x=(n+1)/2;
    ll ans=pow_mod_p(m,x);
    pr(ans) nl
  }

  else
  {
    ll ans=pow_mod_p(m,n);
    pr(ans) nl
  }
}

int main()
{
    //fast
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE*/

    ll ntc=1;
    //cin>>ntc;

    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }

    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define oo INT_MAX/2

int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    ll n,m,k,M=1e9+7;
    cin>>n>>m>>k;

    if(k==1 || k>n)
    {
        ll ats = 1;
        for(int i=1; i<=n; i++)
            ats= (ats*m)%M;

        cout<<ats;
    }
    else if(k==n)
    {
            ll ats = 1;
            for(int i=1; i<=n/2; i++)
                ats=(ats*m)%M;

            if(n&1)ats = (ats*m)%M;

            cout<<ats;
    }
    else if(k&1)cout<<(m*m)%M;
    else cout<<m%M;
}

#include <bits/stdc++.h>
using namespace std;
 #define MOD 1000000007
 #define A '@'
 #define B '*'
 #define C '#'
 #define max(a,b) ((a>b)?a:b)
 #define min(a,b) ((a<b)?a:b)
 #define endl "\n"
 struct frac {long x; long y;};
 frac operator+(frac a, frac b)
 {
 	frac res;
 	res.x=((a.x)*(b.y))%MOD+((b.x)*(a.y))%MOD;
 	res.x%=MOD;
 	res.y=a.y*b.y;
 	res.y%=MOD;
 	return res;
 }

 long long bow (long long a, long long x)
 {
 	if (!x) return 1;
	long long res=bow(a,x/2);
	res*=res; res%=MOD;
	if (x%2) res*=a;
	return (res)%MOD;
 }

 long long get_mod(long long x, long long y)
 {
 	long long d=__gcd(x,y);
 	x/=d;
 	y/=d;
 	x%=MOD;
 	y%=MOD;
 	return (x*(bow(y,MOD-2)))%MOD;
 }

typedef vector<int> vi;

// Union-Find Disjoint Sets Library
// PS: This library code does not include the `union by rank' heuristic yet
// 1000 is just a rough number, adjustable by user
vi pset(3000), setSize(3000);

int _numDisjointSets;

void initSet(int N) {
     setSize.assign(N, 1);
     _numDisjointSets = N;
     pset.assign(N, 0);
     for (int i = 0; i < N; i++) pset[i] = i;
}

int findSet(int i) {
    return (pset[i] == i) ? i : (pset[i] = findSet(pset[i]));
}

bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }

void unionSet(int i, int j) {
  if (!isSameSet(i, j)) {
    _numDisjointSets--;
    setSize[findSet(j)] += setSize[findSet(i)];
    pset[findSet(i)] = findSet(j); }
}

int numDisjointSets() { return _numDisjointSets; }

int sizeOfSet(int i) { return setSize[findSet(i)]; }

long long t,k,n,m, i,j,jj,mid,a,b,root;
vector <long long> cards;
long long p[2501],c[2501],res[2501];
vector <long long> child[2501];
vector<long long> ord[2501];
void dfs(int x)
{
	int a;
	for (int i=0; i<child[x].size();i++)
	{
		a=child[x][i];
	dfs(a);
	for (int j=0;j<ord[a].size();j++) ord[x].push_back(ord[a][j]);
	}
	if (c[x]>ord[x].size()) {cout<<"NO"; exit(0);}
	ord[x].insert(ord[x].begin()+c[x],x);
}
int main()
{
   ios::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   cin>>n>>m>>k;
   initSet(n);
   for (i=0;i<=n-k;i++)
   for (j=0;j<k;j++) unionSet(j+i,k-1-j+i);
   cout<<bow(m,numDisjointSets());
}
/*
1880/1900
*/

#include <cstdio>
#include<string.h>
#include <cstring>
#include <algorithm>
#include <cmath>
#include<iostream>
#include<string>
#include<queue>
#define ll long long int
using namespace std;
int a[1005];
const long long int mod =(long long int) 1e9+7;
int n,m,k;
int main()
{

	while (cin>> n>>m>>k)
	{
		ll res;

		if (n == k)
		{
			ll res = 1;
			int t = (n + 1) / 2;
			while (t--)
			{
				res = (res % mod)*m%mod;

			}cout << res % mod << endl;
				continue;
		}
		if (k == 1||k>n)
		{
			res = 1;
			while (n--)
			{
				res = (res%mod)*m%mod;
			}
			cout << res % mod << endl;
			continue;
	    }
		if (k == 2)
		{
			cout << m << endl;
			continue;
		}
		if (k == 3)
		{
			cout << m * m << endl;
			continue;
		}
		if (k<n&&k%2)
		{
			cout << m*m << endl;
			continue;
		}
		if (k % 2 == 0)
		{
			cout << m << endl;
			continue;
		}
	}
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

constexpr long long PMOD = (long long)1e9 + 7;

int p[2005], n, k, cnt;
long long m;

int findS(int a) {
    return (p[a] == a) ? a : (p[a] = findS(p[a]));
}

void unionS(int a, int b) {
    int x = findS(a), y = findS(b);
    if (x == y) return;
    --cnt;
    if (rand()%2) swap(x, y);
    p[x] = y;
}

long long powmod(long long a, int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    long long x = powmod(a, b/2);
    return ((x * x)%PMOD * powmod(a, b%2))%PMOD;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);

    cin >> n >> m >> k;
    for (int i = 0; i < n; ++i) p[i] = i;
    cnt = n;
    for (int i = 0; i+k <= n; ++i) {
        for (int j = 0; 2*j+1 < k; ++j) {
            // cout << i << ' ' << j << ' ' << i+j << ' ' << i+k-i-j << '\n';
            unionS(i+j, i+k-1-j);
        }
    }
    cout << powmod(m, cnt)  << '\n';
}

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <sstream>

#define pb push_back
#define mp make_pair
#define PI 3.14159265358979
#define sqr(x) (x)*(x)
#define forn(i, n) for(int i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define X first
#define Y second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;
typedef pair<int,int> pii;
const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;
const int maxn = 2010;
const int mod = 1000000007;
int res;
int p[maxn] = {};
int findset(int x) {
	if (p[x] == x) return x;
	return p[x] = findset(p[x]);
}
void unionset(int x, int y) {
	x = findset(x);
	y = findset(y);
	if (x != y) {
		res--;
		if (rand()&1)
			p[x] = y;
		else
			p[y] = x;
	}
}
int binpow(int x, int n) {
	ll ans = 1;
	ll t = x;
	while (n) {
		if (n&1) ans = ans*t%mod;
		t=t*t%mod;
		n>>=1;
	}
	return (int)ans;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	int n, m, k; scanf("%d%d%d", &n, &m, &k);
	res = n;
	for (int i = 0; i < n; ++i) p[i] = i;
	for (int i = 0; i+k<=n; ++i) {
		for (int l = i, r = i+k-1; l<r; ++l,--r)
			unionset(l,r);
	}
	int tt = binpow(m,res);
	printf("%d\n", tt);
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
typedef vector<int> vi;
typedef vector<vector<int> > Mat;
typedef pair<int, int> pi;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define MP make_pair
#define eb emplace_back
#define pb push_back
#define sz(o) (int)o.size()
#define fr(i, n) for(int i=0;i<n;++i)
#define tr(c, it) for(auto it = c.begin();it!=c.end();++it)
#define all(o) (o).begin(), (o).end()
#define F first
#define S second
#define mset(m, v) memset(m, v, sizeof(m))
#define debug(a) cerr << #a << ": " << a << ' ';
#define pr(v) tr(v, it)cout<<*it<<' ';cout<<'\n';
#define nl cerr<<'\n';
const string here = "here\n"; const string yes = "YES\n";const string no = "NO\n";
const int M = 1e9 + 7;const double PI = 2.0*acos(0);
int binpow(int a, int b){int res=1;for(;b;b>>=1ll){if(b&1)res=(1ll*res*a)%M;a=(1ll*a*a)%M;}return res;}
class DSU{
public:
    int* rank;int* par;
    int size; //number of elements
    DSU(int n){
        size = n;
        rank = new int[n];par = new int[n];
        for(int i=0;i<n;i++){par[i]=i;rank[i]=1;}
    }
    int find(int x){
        if(x==par[x])
            return x;
        else return par[x] = find(par[x]);
    }
    void merge(int x, int y){
        x=find(x);y=find(y);
        if(x==y)
            return;
        if(rank[x] < rank[y])
            swap(x, y);
        par[y]=x;
        rank[x]+=rank[y];
        size--;
    }
};
void pre(){

}
void solve(){
    int n,m,k,i,j,l,r;
    cin >> n >> m >> k;
    DSU ds(n);
    fr(i, n-k+1){
        fr(j, k)
            ds.merge(i+j, i+k-1-j);
    }
    cout<<binpow(m, ds.size)<<'\n';
}
int32_t main(){
    IOS;
    //clock_t begin = clock();
    //pre();
    //int t,_;cin>>t;_=t;while(t--)//{cout << "Case #" << _ - t << ": ";
        solve();
    //}
    //cerr<<((double)(clock() - begin)/CLOCKS_PER_SEC)<<'\n';
    return 0;
}

#include <limits.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <limits>
#include <cassert>
#include <string>
#include <vector>
#include <deque>
#include <fstream>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <queue>
#include <iterator>
#include <set>
static const int INF = std::numeric_limits<int>::max();
int MOD = 1000000007;
int main()
{
  int n, m, k;
  std::cin >> n >> m >> k;
  long long res = 0;
  if(n == k) {
    if(n%2 == 1) {
      res = m;
    } else {
      res = 1;
    }
    for(int i = 0; i < n/2; ++i) {
      res *= m;
      res %= MOD;
    }
  } else if(n > k) {
    if(k == 1) {
      res = 1;
      for(int i = 0; i < n; ++i) {
        res *= m;
        res %= MOD;
      }
    } else if(k%2 == 1) {
      res = m*m;
    } else {
      res = m;
    }
  } else {
    res = 1;
    for(int i = 0; i < n; ++i) {
      res *= m;
      res %= MOD;
    }
  }
  std::cout << res << std::endl;
}

/*
	Name: Harshit Jain
	Institution: IIIT Vadodara
*/
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <unordered_set>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <algorithm>

#define MOD (long long)(1e9 + 7)

using namespace std;

const int si = 2001;

struct s {
	int p, r;
};

vector<s> vec;

int find(int i) {
	if(vec[i].p != i) {
		return vec[i].p = find(vec[i].p);
	}
	return vec[i].p;
}

void uni(int x, int y) {
	int xroot = find(x);
	int yroot = find(y);

	if(vec[xroot].r < vec[yroot].r) {
		vec[xroot].p = yroot;
	}
	else if(vec[xroot].r > vec[yroot].r) {
		vec[yroot].p = xroot;
	}
	else {
		vec[xroot].p = yroot;
		vec[xroot].r++;
	}
}

long long m(long long a, long long b) {
	return (a % MOD * b % MOD) % MOD;
}

long long power(int a, int b) {
	if(b == 0) {
		return 1;
	}
	else if(b == 1) {
		return a;
	}
	else {
		int x = power(a, b/2);
		x = m(x, x);
		// if(x < 0) {
		// 	cout << x << endl;
		// }
		if(b%2)
			x = m(x, a);
		// if(x < 0) {
		// 	cout << x << endl;
		// }
		return x;
	}
}

int main() {
	int n, m, k;
	cin >> n >> m >> k;
	vec.resize(si);
	for(int i = 0; i < si; ++i) {
		vec[i].p = i;
	}
	for(int i = 0; i <= n-k; ++i) {
		// cout << i << " " << i + k / 2 << endl;
		for(int j = i; j < i + k / 2 + ((k) % 2 != 0); ++j) {
			// cout << j << " " << 2*i+k-j-1 << endl;
			uni(j, 2*i+k-j-1);
		}
	}
	set<int> se;
	for(int i = 0; i < n; ++i) {
		se.insert(find(i));
	}
	// cout << m << " " << se.size() << endl;
	cout << power(m, se.size()) << endl;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long int ll;
#define MOD 1000000007
#define pb push_back
#define vll vector<ll>
#define test ll t;cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void i_can()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}
ll power(ll a,ll b)
{
  ll res=1;
  a%=MOD;
  while(b)
  {
    if(b&1)
      res=(res*a)%MOD;
    a=(a*a)%MOD;
    b/=2;
  }
  return res;
}
int main()
{
  fast_io;
  i_can();
  ll n,m,k;
  cin>>n>>m>>k;
  if(k==1 || k>n)
    cout<<power(m,n)%MOD<<endl;
  else if(k==n)
    cout<<power(m,(n+1)/2)%MOD<<endl;
  else if(k%2==0)
    cout<<m<<endl;
  else if(k%2)
    cout<<power(m,2)%MOD<<endl;
  return 0;
}

#include <bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
ll power(ll x,ll n)
{
    ll r=1;
    while(n>0)
    {
        if(n%2!=0)
        r=(r*x)%M;
        x=(x*x)%M;
        n/=2;
    }
    return r;
}
int main()
{
    ll n,m,k,ans=0;
    cin>>n>>m>>k;
    ll i,j;
    if(k==1 || k>n)
    {
        ans=power(m,n);
    }
    else if(k==n)
    {
        ans=power(m,(n+1)/2);
    }
    else if(k%2==0)
    ans=m;
    else
    ans=m*m;
    cout<<ans;
}

#include <iostream>
#include <cstdio>
#include <string>
#include <string.h>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <cctype>
#include <algorithm>
#include <climits>
#include <queue>
#include <functional>
#include <map>

#define FOREACH(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)

#define ALL(c) (c).begin(), (c).end()
#define F first
#define S second
#define INS insert
#define MP make_pair
#define PB push_back
#define LL long long
#define ULL unsigned long long

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

template <class T> inline T MAX(T a, T b) { if (a > b) return a; return b; }
template <class T> inline T MIN(T a, T b) { if (a < b) return a; return b; }
template <class T> inline T ABS(T x) { if (x < 0) return -x; return x; }

inline void OPEN(const string &s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

const static int inf = 2123123123;

#define MOD 1000000007

int n,m,k;

int main(){
    scanf("%d%d%d",&n,&m,&k);
    if(k > n){
        LL res = 1;
        REP(i,n){
            res = (res * m) % MOD;
        }
        printf("%I64d\n",res);
    }else{
        if(k % 2 == 0){
            if(n != k){
                printf("%d\n",m);
            }else{
                LL res = 1;
                REP(i,n/2 + (n%2)){
                    res = (res * m) % MOD;
                }
                printf("%I64d\n",res);
            }
        }else{
            if(n != k){
                LL ret = m * m % MOD;
                printf("%I64d\n",ret);
            }else{
                LL res = m;
                REP(i,n - (n/2) - (n%2)){
                    res = (res * m) % MOD;
                }
                printf("%I64d\n",res);
            }
        }
    }
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout<<'\n'
#define sor(x) sort(x.begin(),x.end())
#define rev(v) reverse(v.begin(),v.end())
#define llmax 100000000000000000
#define deb(x) cout<<"value here is "<<x<<"\n"
#define pll pair<ll,ll>
#define vll vector <ll>
#define rub cout<<"ohlala"<<'\n';
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,k;
    cin>>n>>m>>k;
    if(k>n)
    {   ll ans=1;
        for(int i=1;i<=n;i++)
        {ans*=m;
        ans%=1000000007;}
        cout<<ans%1000000007;
        return 0;
    }
    if(k%2==0)
    cout<<m;
    else
    {
      ll ans=m*m;
      cout<<ans;
    }

}

#include <cstdio>
#include <iostream>

using namespace std;

const int MAXN = 4000000;

bool IsPrime[MAXN];
int prinum;
long long PrimeTable[MAXN];

void pre(){
    for (int i = 2; i < MAXN; i++) IsPrime[i] = true;
    for (int i = 2; i < MAXN; i++){
        if (IsPrime[i]){
            for (int j = i + i; j < MAXN; j += i){
                IsPrime[j] = false;
            }
        }
    }
    prinum = 0;
    for (int i = 2; i < MAXN; i++){
        if (IsPrime[i]) PrimeTable[prinum++] = i;
    }
}

int main(){
    long long n;
    pre();
    while (cin >> n){
        int cnt = 0;
        long long ans =1;
        int tot = 0;
        for (int i = 0; i < prinum && n != 1; i++){
            while (n % PrimeTable[i] == 0){
                tot++;
                n /= PrimeTable[i];
                if (cnt < 2){
                    ans *= PrimeTable[i];
                    cnt++;
                }
            }
        }
        if (n != 1) {
            tot++;
            if (cnt < 2){
                ans *= n;
            }
        }
        if (tot == 2) printf("2\n");
        else{
            printf("1\n");
            if (tot <= 1) printf("0\n");
            else{
               cout << ans << endl;
            }
        }
    }
    return 0;
}

#include <stdio.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <sstream>

#define pb push_back
#define mp make_pair
#define PI 3.14159265358979
#define forn(i, n) for(int i = 0; i < n; ++i)
#define ALL(x) x.begin(), x.end()
#define L(s) (int)((s).size())
#define ms(x) memset(x,0,sizeof(x));

typedef long long ll;
using namespace std;
typedef pair<int,int> pii;
const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;
const int ST = 100010;
const int ST1 = 1000010;
int mod = 1000000007;
ll Pow(ll n,ll a)
{
	ll ans = 1;
	while(a)
	{
		ans*=n;
		a--;
		ans%=mod;
	}
	return ans;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	int n,m,k;
	cin >> n >> m >> k;
	ll ans = 0;
	if(k == 1 || k > n)
		ans = m * n;
	else
		if(k == n)
			ans = (ll)Pow(m,(n+1)/2);
		else
			if(k % 2 == 1)
				ans = m*m;
			else
				ans = m;
	cout << ans;
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll color[2005];
vector < vector < ll > > neigh(2005);
void unite(ll c1 , ll c2){
    for(ll i = 0;i<neigh[c1].size();i++){
        neigh[c2].push_back( neigh[c1][i] );
        color[ neigh[c1][i] ] = c2;
    }
    neigh[c1].clear();
}
int main(){
    ll n , m , k , i , j;
    cin >> n >> m >> k;
    for(i = 1;i<=n;i++){
        color[i] = i;
        neigh[i].push_back(i);
    }
    set < ll > q;
    for(i = 1;i<=n - k + 1;i++){
        ll l = i , r = i + k - 1 , cnt = 0;
        for(j = i;j<=(l + r) / 2;j++){
            if (color[j] != color[r - cnt]){
                ll sz1 = neigh[  color[j] ].size() , sz2 = neigh[ color[r - cnt] ].size();
                    if (sz1 < sz2)
                        unite(color[j] , color[ r - cnt ]);
                    else
                        unite(color[ r - cnt ] , color[j]);
                cnt++;
            }
        }
    }
    for(i = 1;i<=n;i++)
        q.insert(color[i]);
    ll sz = q.size();
    ll ans = 1;
    for(i = 1;i<=sz;i++)
        ans*=m;
    cout << ans;
    return 0;
}

#include <cstdlib>
#include <iostream>

using namespace std;

const long long p = (long long) 1e9 + 7;

int main() {
  long long n, m, k, i;

  cin >> n >> m >> k;

  if (k > n) {
    long long ans = 1;
    //cout << (n+1)/2<< endl;
    for (i = 0; i < n; i++) {
      ans *= m;
      ans = ans % p;
    }
    cout << ans << endl;
    return 0;
  }

  if (n == k) {
    long long ans = 1;
    //cout << (n+1)/2<< endl;
    for (i = 0; i < (n+1)/2; i++) {
      ans *= m;
      ans = ans % p;
    }
    cout << ans << endl;
    return 0;
  }
  if (k == 1) {
    while (1) {}
    long long ans = 1;
    //cout << (n+1)/2<< endl;
    for (i = 0; i < n; i++) {
      ans *= m;
      ans = ans % p;
    }
    cout << ans << endl;
    return 0;
  }
  if (k % 2 == 1) {
    long long ans = 1;
    //cout << (n+1)/2<< endl;
    for (i = 0; i < m; i++) {
      ans *= 2;
      ans = ans % p;
    }
    cout << ans << endl;
  }
  else {
    cout << m << endl;
  }
  cin.get();
  cin.get();
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#define int64 long long
#define Sort sort

using namespace std;

int n,m,k;

int main()
{
	//freopen("x.in","r",stdin);
	//freopen("x.out","w",stdout);

	scanf("%d%d%d",&n,&m,&k);
	if (k % 2==0)
	{
		printf("%d\n",m);
		return 0;
	}
	if (m==1) { printf("1\n"); return 0; }
	printf("%d\n",m*(m-1)+m);

	return 0;
}

#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;

const long long OO = 1000;
const long long mod = 1e9 + 7;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }

void fast(){
#ifndef ONLINE_JUDGE
	freopen("F:\\solving\\input.txt", "r", stdin);
	freopen("F:\\solving\\output.txt", "w", stdout);
#endif
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL); cout.tie(NULL);
}
const int MAX = 2000+1;
int n, m, k;
long long a;

long long pwr(int a, int b){
	if (b == 0)return 1;
	if (b == 1)return a;

	long long ret = pwr(a, b / 2);
	return (ret%mod * ret%mod * pwr(a, b % 2)%mod)%mod;
}
int main(){
	fast();
	cin >> n >> m >> k;

	if (n == k){
		cout << pwr(m, (k + 1) / 2) << endl;
	}else if (n > k){
		if (k % 2){
			cout << m*m << endl;
		}
		else{
			cout << m << endl;
		}
	}
	else{
		cout << 0 << endl;
	}
	return 0;
}

#include <iostream>
using namespace std;

const int delta = 1e9 + 7;
long long pow(int p, int t) {
  if(t < 2)
    return (p - 1) * t + 1;
  long long op = pow(p, t / 2);
  op *= op;
  op %= delta;
  if(t % 2)
    op *= p;
  return op % delta;
}

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  if(k == 1 || k > n)
    cout << pow(m, n) << '\n';
  else if(n == k)
    cout << pow(m, (n / 2) + (n % 2)) << '\n';
  else
    cout << pow(m, n) << '\n';
  return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define for0(i, n) for (i = 0; i < n; i++)
#define for1(i, n) for (i = 1; i <= n; i++)

#define all(x) x.begin(), x.end()
#define mem(x, y) memset(x, y, sizeof(x))

#define sdi(x) scanf("%d", &x)
#define sdii(x, y) scanf("%d %d", &x, &y)
#define sdiii(x, y, z) scanf("%d %d %d", &x, &y, &z)
#define sdl(x) scanf("%lld", &x)
#define sdll(x, y) scanf("%lld %lld", &x, &y)
#define sdlll(x, y, z) scanf("%lld %lld %lld", &x, &y, &z)
#define sds(x) scanf("%s", x)
#define pfi(x) printf("%d\n", x)
#define pfii(x, y) printf("%d %d\n", x, y)
#define pfiii(x, y, z) printf("%d %d %d\n", x, y, z)
#define pfl(x) printf("%lld\n", x)
#define pfll(x, y) printf("%lld %lld\n", x, y)
#define pflll(x, y, z) printf("%lld %lld %lld\n", x, y, z)

#define eps 1e-9
#define pi 3.14159265358979
#define OK cerr << "ok\n"
#define DB(x) cerr << #x << " = " << x << endl

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> pii;

inline int setBit(int N, int pos) { return N = N | (1 << pos); }
inline int resetBit(int N, int pos) { return N = N & ~(1 << pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1 << pos)); }

//int kx[] = {+2, +1, -1, -2, -2, -1, +1, +2};
//int ky[] = {+1, +2, +2, +1, -1, -2, -2, -1}; //Knight Direction
//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

LL modpow(LL base, LL exp, LL modulus)
{
    base %= modulus;
    LL result = 1;
    while (exp > 0)
    {
        if (exp & 1)
            result = (result * base) % modulus;
        base = (base * base) % modulus;
        exp >>= 1;
    }
    return result;
}

int main()
{
    LL n, m, k;

    sdlll(n, m, k);

    if (k < n)
    {
        if (k % 2)
        {
            cout << m * (m - 1) + m << endl;
        }
        else
        {
            cout << m << endl;
        }
    }
    else if (k == n)
    {
        n = (n + 1) / 2;

        cout << modpow(m, n, 1000000007) << endl;
    }
    else
    {
        cout << modpow(m, n, 1000000007) << endl;
    }
}

#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <vector>
#include <map>
#include<set>
#include <string>
#include<cstdlib>
#include <queue>

using namespace std;

#define int long long
#define fi(i, a, b) for(int i = (a); (i) < (b); (i)++)

const int N = 100001;
const int M = 1000000007LL;
int r=0;
void add(int x){ r = (r+x)%M;}
void main()
{
#if defined(DEBUG) || defined(_DEBUG)
  ifstream cin("input.txt");
  ofstream cout("output.txt");
#endif
  int n,m,k;
  cin >>n>>m>>k;

  if(k>n) cout<<0;
  else{
      if(k==1){
          r=1;
          fi(i,0,n){
              r = (r*m)%M;
          }
          cout<<r;
      }
      else if(k==n){
          r=1;
          fi(i,0,(n+1)/2){
              r = (r*m)%M;
          }
          cout<<r;
      }
      else if(k&1){
          cout<<m*m;
      }
      else{
          cout<<m;
      }
  }
}

#include<bits/stdc++.h>
using namespace std;

const int mod = 1e9+7;

int mpow(long long a, int b)
{
    if(!b) return 1;
    if(b&1) return a*mpow(a,b-1)%mod;
    return mpow(a*a%mod,b/2);
}

int main()
{
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    if((k&1)==0) printf("%d\n",m);
    else if(k==1) printf("%d\n",mpow(m,n));
    else printf("%d\n",mpow(m,max(n,2)));
}

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <string.h>
#include <set>
#include <queue>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <stack>
#define mo 1000000007
using namespace std;
int main()
{
	int n,m,k;
	while(cin>>n>>m>>k)
	{
		if(k <= n)
		{
			int mark[2002];
			long long sum=1;
			memset(mark,0,sizeof mark);
			if(k%2==1)
			for(int i=2;i<n;i++)
			{
				bool b=0;
				int k=0;
				for(int j=0;j<n;j++)
				{
					if(mark[j]==0)
					{
						k=j;
						b=1;
						break;
					}
				}
				if(!b)
				break;
				sum*=m;
				sum%=mo;
				mark[k]=1;
				for(int j=k;j<n-i;j++)
				{
					mark[i+j]=1;
				}
			}
			else if(k!=n)
			sum=m;
			else
			{
				for(int i=0;i<n/2;i++)
				{
					sum*=m;
					sum%=mo;
				}
			}
			cout<<sum<<endl;
		}
		else
		{
			long long sum=1;
			for(int i=0;i<(k/2,n);i++)
			{
				sum*=m;
				sum%=mo;
			}
			cout<<sum<<endl;
		}
	}
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ld long double
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define all(x) (x).begin(), (x).end()
#define tr(x,it) for(auto it = x.begin();it!=x.end();++it)
#define fpresent(x,c) ((c).find(x) != (c).end())  //set,map
#define present(c,x) (find(all(c),x) != (c).end()) //vector
#define pr(a,b) cout<<a<<" "<<b<<endl
#define pr1(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define pr2(a,b,c,d) cout<<a<<" " <<b<<" "<<c<<" "<<d<<endl
#define pb push_back
#define mp make_pair
#define INF 1e18
#define N 300001
#define F first
#define S second
#define iPair pair<int, int>
int m;
int pp(int xx)
{
	if(xx == 0)
		return 1;
	int here = pp(xx/2);
	here*=here;
	here%=mod;
	if(xx%2)
		here*=m;
	return here%mod;
}

void code()
{
	int i, j, n, k, done = 0;
	cin>>n>>m>>k;
	if(k%2==0){
		if(n>k)
			cout<<m<<endl;
		else
			cout<<pp(n/2)<<endl;
	}
	else{
		if(n>k)
			cout<<m*m<<endl;
		else
			cout<<pp(n/2+1)<<endl;
	}
}

main()
{
	int tt,t;
	// cin>>t;
	t=1;
	for(tt = 1; tt<=t ; tt++){
		code();
	}
	return 0;
}

#include <cstdio>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int (i)=0,_n=(n);(i)<_n;(i)++)
#define FOR(i,a,b) for(int (i)=(a),_n=(b);(i)<=_n;(i)++)
#define FORD(i,a,b) for(int (i)=(a),_n=(b);(i)>=_n;(i)--)
#define FOREACH(it,arr) for (__typeof((arr).begin()) it=(arr).begin(); it!=(arr).end(); it++)

const int mod = 1000000007;

int main()
{
	int n, m, k;
	scanf( "%d %d %d", &n, &m, &k );
	int ans;
	if ( k > n ) ans = 0;
	else if ( n > k ) {
		ans = m;
		if ( k % 2 == 1 && n > 1 )
			ans = (ans + m * (m - 1)) % mod;
	}
	else if ( n == k ) {
		ans = 1;
		REP(i,(n+1)/2) ans = (ans * m) % mod;
	}
	printf( "%d\n", ans );
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
vector<int>mp;
vector<vector<int> >v;
void dfs(int t,int cnt)
{
	mp[t]=cnt;
	for(int i=0;i<v[t].size();i++)
	{
		if(mp[v[t][i]]==-1)
			dfs(v[t][i],cnt);
	}
}
void check(int& a,int b)
{
	long long x=long(a)*long(b);
	if(x>=mod)
		x%=mod;
	a=x;
}
int main()
{
    int n,m,k;
	cin>>n>>m>>k;
	v.resize(n);
	for (int i=0;i+k-1<n;i++)
	{
		for(int j=i;j<=i+k-1;j++)
		{
			v[j].push_back(i+k-1-(j-i));
			v[i+k-1-(j-i)].push_back(j);
		}
	}
	mp.assign(n,-1);
	int cnt=0;
	for(int i=0;i<n;i++)
	{
		if(mp[i]==-1)
		{
			dfs(i,cnt);
			cnt++;
		}
	}
	int sum=1;
	for(int i=0;i<cnt;i++)
		check(sum,m);
	cout<<sum;

	return 0;
}

//http://community.topcoder.com/stat?c=problem_statement&pm=10978
//http://codeforces.com/contest/17/problem/B
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <fstream>
#include <sstream>
#include <map>
#include <set>
#include <numeric>
#include <limits>
#define pb push_back

using namespace std;
typedef long long LL;

#define imax numeric_limits<LL>::max()
#define imin numeric_limits<LL>::min()
#define lmax numeric_limits<LL>::max()
#define lmin numeric_limits<LL>::min()
/*
LL oo =lmin;

LL Q = 1e9 + 7;

LL gcd(LL a, LL b)
{
    if (b == 0){
        return a;
    }
    return gcd(b, a%b);
}

LL prime[10000002];
LL small[10000002];
// 0 == prime
// 1 == not prime
vector<LL> r;
void seive()
{
    memset (small, -1, sizeof(small));
    prime[0]=1;
    prime[1]=1;

    for (LL i=2;i*i<=300002;i++){
        if (prime[i] == 0){
            for (LL j=i*i; j <= 300002;j += i){
                prime[j]=1;
                if (small[j] == -1){
                    small[j] = i;
                }
            }
        }
    }
    for (LL i=0;i<=300002;i++){
        if (prime[i] == 0){
            r.push_back(i);
        }
    }
}

*/

LL Q = 1e9 + 7;
long long poww(LL a, LL b)
{
    long long x=1,y=a;
    while(b > 0)
    {
        if(b%2 == 1)
        {
            x=(x*y);
            if(x>Q) x%=Q;
        }
        y = (y*y);
        if(y>Q) y%=Q;
        b /= 2;
    }
    return x;
}
LL C[52][52];

void binomialCoeff()
{
    LL i, j;
    for (i = 0; i <= 50; i++)
    {
        for (j = 0; j <= 50; j++)
        {

            if (j == 0 || j == i)
                C[i][j] = 1;
            else
                C[i][j] = C[i-1][j-1] + C[i-1][j];
        }
    }
}

int main()
{
    int n, m, k;
    cin>>n>>m>>k;
    int ans=0;
    if (k == 1 || k > n){
        ans = poww(m, n);
    }else if (k % 2 != 0){
        ans=m*(m);
        ans %= Q;
    } else {
        ans=m;
        ans %= Q;
    }
    cout<<ans<<"\n";
    return 0;
}

//
//  main.cpp
//  D
//
//  Created by Liza Kondakova on 17.02.12.
//  Copyright (c) 2012 likogra@gmail.com. All rights reserved.
//

#include <iostream>
using namespace std;
long long p=1000000007;
long long pow(long long a,long long b){
    long long ans=1;
    for(int i=0;i<b;i++){
        ans*=a;
        ans%=p;
    }
    return ans;
}
int main ()
{
    long long n,k,m;
    cin>>n>>m>>k;
    if(k>n){
        cout<<pow(m,n);
    }
    if(k==n){
        cout<<pow(m,(n+1)/2);
    }
    if(k==1){
        cout<<pow(m,(n));
    }
    if(k<n){
        cout<<pow(m,(k)%2+1);
    }
    cout<<endl;
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

const int OO = 0x3f3f3f3f ,N = 2e3+5 ,mod = 1e9+7 ;
const double pi = acos(-1) ,EPS = 1e-12 ;
#define read(FILE)  freopen(FILE, "r", stdin);
#define write(FILE) freopen(FILE, "w", stdout);
#define BeatMeIFUCAN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll ;

int n ,m ,k ,ans=1 ;
bool vis[N] ;
void dfs(int i){
    vis[i]=1;
    for(int j=max(0,i-k+1);j<=i&&j+k-1<n;++j)if(2*j+k-i-1>=0&&2*j+k-i-1<n&&!vis[2*j+k-i-1]){
        dfs(2*j+k-i-1);
    }
}
int main(){
    cin>>n>>m>>k;
    for(int i=0;i<n;++i)if(!vis[i]){
        ans=(1ll*ans*m);
        dfs(i);
    }
    cout<<ans;
	return 0;
}

#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <sstream>
#include <numeric>

#pragma comment(linker, "/STACK:64000000")

#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
#define EPS 1e-9
#define INF INT_MAX
#define sqr(X) (X) * (X)
#define round(x) (int)((x) + 0.5 + EPS)
#define between(x, a, b) ((x) >= (a) && (x) <= (b))
#define contains(T, x) ((T).find(x) != (T).end())

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long int64;

typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <uint> vu;
typedef vector <ull> vull;
typedef vector <pii> vpii;
typedef vector <vpii> vvpii;
typedef vector <string> vs;
typedef stringstream ss;

#define TASK "test"

const int P = 1000000007;

int main()
{
#ifndef ONLINE_JUDGE
    freopen(TASK ".in", "r", stdin);
    freopen(TASK ".out", "w", stdout);
#endif

    int n, m, k;
    cin >> n >> m >> k;

    if (k == 1)
    {
        int64 ans = 1;
        for (int i = 0; i < n; i++)
        {
            ans *= m;
            ans %= P;
        }
        cout << ans;
        return 0;
    }
    if (k % 2 == 0)
    {
        cout << m;
        return 0;
    }
    cout << sqr(m);

    return 0;
}

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define LL long long
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define L l,mid,i<<1
#define R mid+1,r,i<<1|1
using namespace std;

const int N = 310;
const int mod = 1e9 + 7;

int Pow(int m, int n){
    for(int i = 0; i < n; i++){
        m *= m;
        m %= mod;
    }
    return m;
}

int main(){
    int m, n, k;
    cin >> m >> n >> k;
    if(k == 1 || k > m)
        cout << Pow(n, m);
    else if(!(k % 2))
        cout << n;
    else if(k % 2)
        cout << (n*n)%mod;
    return 0;
}

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#define eps 1e-8
using namespace std;
long double proba=0;

long long modExp(long long b, long long e, long long m)
{
long long remainder;
long long x = 1;

while (e != 0)
{
remainder = e % 2;
e= e/2;

if (remainder == 1)
x = (x * b) % m;
b= (b * b) % m; // New base equal b^2 % m
}
return x;
}
long long mod=1000000007LL;
long long bicoef[2001][3];
int main(){
bicoef[1][0]=1;
bicoef[1][1]=1;
bicoef[1][2]=0;
for (int i=2;i<2001;i++){
    bicoef[i][0]=1;
    bicoef[i][1]=(bicoef[i-1][0]+bicoef[i-1][1])%mod;
    bicoef[i][2]=(bicoef[i-1][1]+bicoef[i-1][2])%mod;
}
long long ans;
long long n,m,k;
cin>>n>>m>>k;
if (k<=1){
    cout<<modExp(m,n,mod);
    goto here;
}
if (k%2==0){cout<<m<<endl;
goto here;
}
else cout<<bicoef[m][2]<<endl;

here:
//system("pause");
return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

const int N = 2e3 + 5, mod = 1e9 + 7;

ll pw(ll a, ll b) {
	if(!b)
		return 1;
	ll ans = pw(a, b / 2);
	ans *= ans;
	ans %= mod;
	if(b & 1)
		ans *= a;
	return ans % mod;
}

ll dp[N][N];

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
		if(n < k || n == 1)
			return cout << pw(m, n) << "\n", 0;
		if(n == k)
			return cout << pw(m, (k + 1) / 2) << "\n", 0;
		if(k % 2 == 1)
			return cout << pw(m, 2) << "\n", 0;
		else {
			return cout << m << "\n", 0;
		}
}

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<string>
#include<cmath>
#define pb push_back
#define mp make_pair
using namespace std;
typedef __int64 big;
const big mod=1000000007;
big n,m,k,f[2030];
big pw(big a,big b)
{
    big ans=1,t=a;
    while(b)
    {
        if(b&1)ans=ans*t%mod;
        t=t*t%mod;
        b>>=1;
    }
    return ans;
}
int main()
{
    cin>>n>>m>>k;
    int i,j;
    big A=0,tmp;
    if(k==1)
    {
        cout<<pw(m,n);
    }
    else
    {
        if(k&1)
        {
            cout<<m*(m-1)%mod;
        }
        else
        {
            cout<<m;
        }
    }
}

#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;
long long n,m,k;
long long rez;
long long rasp;
long long nr;
int main()
{
cin>>n>>m>>k;

    nr=(k+1)/2;
    rez=max(nr-(n-k),1LL*1);
    rasp=1;
    if(k>n)
    {nr+=k-n;
    nr=min(nr,n);
        for(int i=1;i<=n;++i)
        {
        rasp=1LL*rasp*m;
        rasp=rasp%1000000007;
        }
            cout<<rasp;
        return 0;
    }
  //  printf("%d\n",nr);
    for(int i=1;i<=rez;++i)
        {
        rasp=1LL*rasp*m;
        rasp=rasp%1000000007;
        }
    cout<<rasp;
return 0;
}

#include <cstdio>

int n,m,k;

int main(){
    scanf("%d%d%d",&n,&m,&k);
    if (k>1)
        printf("%d",m);
    else {
        int ans=n;
        for (int i=0;i<m;++i)
            ans=(ans*m)%1000000007;
        printf("%d",ans);
    }
}

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e3+5;
const int mod=1e9+7;
int fa[N],vis[N];
int f(int x)
{
    if(x==fa[x]) return x;
    else         return fa[x]=f(fa[x]);
}

ll qp(int a,int b)
{
    ll res=1;
    while(b)
    {
        if(b&1) res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res;
}
int main()
{
    ll n,m,k;
    scanf("%lld%lld%lld",&n,&m,&k);
    for(int i=1;i<=n;i++) fa[i]=i;
    for(int i=1;i+k-1<=n;i++)
    {
        int len=i+k-1;
        for(int j=0;j<k;j++)
        {
            int x=f(i+j),y=f(len-j);
            if(x!=y) fa[y]=x;
        }
    }ll t=0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[f(i)]) t++,vis[f(i)]=1;
    }
    ll ans=qp(m,t);
    printf("%lld\n",ans);
    return 0;
}

/* ****revpro**** */
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
ll expo(ll base, ll exponent, ll mod=hell) {								//return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}
ll edges;
pair <ll,pii> edgelist[N];
vi link(N),size(N,1);
ll find(ll x)
{
	while(x!=link[x]) x=link[x];
	return x;
}
bool same(ll i,ll j)
	{return find(i)==find(j);}
void unite(ll a,ll b)
{
	a=find(a);
	b=find(b);
	if(size[a]<size[b]) swap(a,b);
	size[a]+=size[b];
	link[b]=a;
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n,m,k;
		cin>>n>>m>>k;
		rep(i,1,n+1)link[i]=i;
		rep(i,1,n-k+1){
			rep(j,0,k/2+1) if(!same(i+j,i+k-1-j)) unite(i+j,i+k-1-j);
		}
		ll cnt=0;
		rep(i,1,n+1) if(find(i)==i) cnt++;
		cout<<expo(m,cnt);
	}
	return 0;
}

#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
    IOS
    ll n, m, k;
    ll mod = 1000000007;

    cin >> n >> m >> k;
    if(k == 1 || k > n)
    {
        ll ans = 1;
        for(ll i = 0; i < n; i++)
            ans = (ans*m)%mod;
        cout << ans << endl;
        return 0;
    }
    if(n > k)
    {
        ll ans = (m*(m-1))%mod;
        if(m > 2)
        ans = ((ans + m)%mod + mod)%mod;
        cout << ans;
        return 0;
    }
    ll i;
    ll ans = 1;
    for(i = 0; i < k/2 - 1; i++)
    {
        ans = (ans * m)%mod ;
    }
    if(k&1)
    {
        ans = (ans*m)%mod;
        ans = (ans*m)%mod;
    }
    cout << ans << endl;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define vi vector<ll>
#define graph vector<vector< int > >
#define vpi vector<pair<int ,int> >
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define SIZE 200009
#define wh(a) cout<<#a<<"  is  "<<a<<endl;
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))

ll po(ll a,ll b){
	ll ans=1,mul=a%mod;
	while(b){
		if(b%2==1){
			ans=(ans*mul)%mod;
		}
		mul=(mul*mul)%mod;
		b=b/2;
	}
	return ans;
}

void solve(){
	ll n,m,k;
	cin>>n>>m>>k;
	ll ans=0;
	if(n<k){
		ans=po(m,n);
	}
	else if(n==k){
		ans=po(m,(k+1)/2);
	}
	else{
		if(k%2==0){
			ans=m;
		}
		else{
			ans=(m+(m*(m-1))%mod)%mod;
		}
	}
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt", "r", stdin);
	// #endif
	int t=1;
	// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

#include <stdio.h>

const int MOD = 1e9 + 7;

int powMod(int a, int n){
    int res = 1;
    while (n){
        if (n % 2) res = (res*a) % MOD;
        a = (a*a) % MOD;
        n/=2;
    }
    return res;
}

int main(){
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    printf("%d", powMod(m, n/k));
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

# define ll long long
# define pb push_back
# define ppb pop_back
# define pf push_front
# define ppf pop_front

const ll N = 1e5 + 10;
const ll mod = 1e9 + 7;
const ll INF = 1e18;
const ll inf = -1e18;

ll n, m, k, ans = 1;

int main() {
    //freopen("in.cpp", "r", stdin);
    //freopen("out.cpp", "w", stdout);
    //ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    cin >> n >> m >> k;
    if(k == 1 || k > n) {
        for(int i = 1;i <= n;i++) {
            ans = (ans * m) % mod;
        }
        cout << ans;
        return 0;
    }
    cout << m;
    return 0;
}

#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

/*int main()
{
    int n,k,l,c,d,p,nl,np;
    cin>>n>>k>>l>>c>>d>>p>>nl>>np;
    l*=k;
    d*=c;
    cout<<min(l/nl,min(d,p/np))/n;
    return 0;
}*/
/*
int main()
{
    string a[100],s;
    int n;
    int kilk1[100]={0},kilk2[100]={0},kilk3[100]={0};
    cin>>n;
    char c1,c2,c0,c3,c4,c5,c6;
    int k;
    for (int i=0;i<n;i++)
    {
        cin>>k;
        cin>>a[i];
        for (int j=0;j<k;j++)
        {
            cin>>s;
            c1=s[0];
            c2=s[1];
            c3=s[3];
            c4=s[4];
            c5=s[6];
            c6=s[7];
            if (c1==c2&&c2==c3&&c3==c4&&c4==c5&&c5==c6)
            {
                kilk1[i]++;
            }
            else
            if (c1>c2 && c2>c3 && c3>c4&& c4>c5&&c5>c6)
            {
                kilk2[i]++;
            }
            else
                kilk3[i]++;
        }
    }
    int max1=kilk1[0];
    int max2=kilk2[0];
    int max3=kilk3[0];
    int k1=0,k2=0,k3=0;
    for (int i=0; i<n;i++)
    {
        if (max1<=kilk1[i]) {max1=kilk1[i];k1=i;}
        if (max2<=kilk2[i]) {max2=kilk2[i];k2=i;}
        if (max3<=kilk3[i]) {max3=kilk3[i];k3=i;}
    }
    printf("If you want to call a taxi, you should call:");
    for (int i=0;i<k1;i++)
        if (max1==kilk1[i]) cout<<" "<<a[i]<<",";
    cout<<" "<<a[k1]<<"."<<endl;
    printf("If you want to order a pizza, you should call:");
    for (int i=0;i<k2;i++)
        if (max2==kilk2[i]) cout<<" "<<a[i]<<",";
    cout<<" "<<a[k2]<<"."<<endl;
    printf("If you want to go to a cafe with a wonderful girl, you should call:");
    for (int i=0;i<k3;i++)
        if (max3==kilk3[i]) cout<<" "<<a[i]<<",";
    cout<<" "<<a[k3]<<"."<<endl;
    return 0;
}*/
/*
int main()
{
    long long a;
    cin>>a;
    long long k=0;
    long long l=1;
    long long b=a;
    if (a==2) {cout<<"1\n0"; return 0;}
    while (a%2==0)
    {
        k++;
        a/=2;
        if (k<=2) {l*=2;} else {cout<<1<<endl<<l; return 0;}
    }

    for (long long i=3;(i*i<=a);i=i+2)
    {
        while (a%i==0)
        {
            k++;
            if (k<=2) {l*=i; } else {cout<<1<<endl<<l; return 0;}
            a/=i;
        }
    }
    if (a==1)
    {
        if (k<2) cout<<"1\n0"; else cout<<2;
    }
    else
        if (k==0) cout<<"1\n0"; else
        {
        if (k<2) cout<<"2"; else cout<<1<<endl<<l;
        }
    return 0;
}*/
const long long mod=1000000007;
int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    if (k==1)
    {
        long long res=1;
        for (int i=0;i<n;i++)
        {
            res*=m;
            res%=mod;
        }
        cout<<res;
    }
    else
        if (k==2)
        {
            cout<<m;
        }
        else
    if (k>n)
    {
        cout<<0;
    }
    else
    if (n>k)
    {
        if (k%2==1)
        cout<<m*m; else cout<<m;
    }
    else
    {
        long long res=1;
        for (int i=0;i<(k+1)/2;i++)
        {
            res*=m;
            res%=mod;
        }
        cout<<res;
    }
    return 0;
}

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstring>
#include <climits>
#include <set>
#include <stack>
#include <queue>

using namespace std;

int pw(int n,int k)
{
    int c=1;
    while( k > 1 ) {
           if ( k%2 ) {
              c*=n;
              c%=1000000007;
           }
           n*=n;
           k/=2;
           n%=1000000007;
    }
    n*=c;
    n%=1000000007;
    return n;
}
int main()
{
    long long n,m,k;
    cin >> n >> m >> k;
    long long ans=1;
    if ( k == 1 ) {
         ans=pw(m,n);
    }
    else if ( k == n ) {
         ans=pw(m,(n+1)/2);
    }
    else if ( k % 2 ) {
         ans=m*m;
    }
    else
         ans=m;
    cout << ans << endl;
//    system("pause");
    return 0;
}

#include<cstdio>
#include<cstring>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
const int mod=1000000007;
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    long long  ans=1;
    if (k==1 || k>n){
        ans=1;
        for (int i=0;i<n;i++){
            ans=(long long)ans*m%mod;
        }
        cout<<ans<<endl;
    }   else if (k%2==0){
        cout<<m<<endl;
    }   else {
        cout<<m*m%mod<<endl;
    }

    return 0;
}

#include <iostream>
#include <cstdio>
#include <cstring>
#include <list>
#include <vector>
#include <algorithm>
#include <map>
#include <bitset>
#include <cmath>
#include <ctime>
#include <string>
#include <set>

using namespace std;
#define MOD 1000000007
#define ll long long
ll n, m, k, ans;
void init() {
	cin >> n >> m >> k;
}
void work() {
	ans = 1;
	if (m == 1) {
		cout << 1 << endl;
		return;
	}
	if (k % 2) {
		if (k < n) {
			if (k == 1) {
				for (int i = 1; i <= n; i ++)
					ans = (ans * m) % MOD;
			} else
			ans = m * m;
		} else if (k == n) {
			for (int i = 1; i <= k / 2 + 1; i ++)
				ans = (ans * m) % MOD;
		}
	} else {
		if (k < n) {
			ans = m;
		} else if (k == n) {
			for (int i = 1; i <= k / 2; i ++)
				ans = (ans * m) % MOD;
		}
	}
	cout << ans % MOD << endl;

}
int main() {
	init();
	work();
}

#include <stdio.h>

int n,m,k;

long long mod=1e9+7;
long long pow(long long a, long long p) {
	long long res=1;
	while(p) {
		if(p&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		p>>=1;
	}
	return res;
}
int main() {
	scanf("%d %d %d",&n,&m,&k);
	if(k==1)
		printf("%lld",pow(m,n));
	else if(k%2==0)
		printf("%d",m);
	else
		printf("%d",m*m-m);
	return 0;
}

#include<iostream>
#include<stack>
#include<queue>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<cmath>
#define ll long long
#define oo 1000000007
#define MAXN 100005
using namespace std;
int n,m,k;
ll C[2005][2005];
int main()
{
      int i,j;
      for (i=0;i<=2000;i++) C[i][0]=C[i][i]=1;
      for (i=1;i<=2000;i++)
        for (j=1;j<=i;j++)
          C[i][j]=(C[i][j-1]+C[i-1][j])%oo;
      while (~scanf("%d%d%d",&n,&m,&k))
      {
             if (k<n) printf("%d\n",m);
             else
             {
                   if (n%2) printf("%d\n",(C[n][1]*C[n-1][n/2])%oo);
                   else printf("%d\n",C[n][n/2]);
             }
      }
      return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

const int N = 2e3 + 5, mod = 1e9 + 7;

ll pw(ll a, ll b) {
	if(!b)
		return 1;
	ll ans = pw(a, b / 2);
	ans *= ans;
	ans %= mod;
	if(b & 1)
		ans *= a;
	return ans % mod;
}

ll dp[N][N];

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	if(n < k)
		return cout << pw(m, n) << "\n", 0;
	else if(n == k)
		return cout << pw(m, (k + 1) / 2) << "\n", 0;
	else {
		if(n % k)
			return cout << m << "\n", 0;
		else {
			return cout << pw(m, (k + 1) / 2) << "\n", 0;
		}
	}
}

#include<bits/stdc++.h>
using namespace std;

long long powz(long long a,long long b )
{
    long long res=1;
    while(b)
    {
        if(b&1)res*=a;
        b/=2;
        a*=a;

    }
    return res;
}

int main()
{
    long long n,m,k;
    cin>>n>>m>>k;
    if(k&1)
    {
        cout<<m*m;

    }

    else{

        cout<<m;

    }

}

/**
 *   author: Shubham Srivastava
 *   created: 06 July 2019  12:27:13
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
vector <ll> parent(20004);
ll find_parent(ll n)
{
    if(n == parent[n])
        return n;
    return parent[n] = find_parent(parent[n]);
}

ll fast_power(ll n, ll k)
{
    if(k==0)
        return 1;
    if(k%2)
    {
        ll res = fast_power(n,k/2);
        return res*res;
    }
    else
        return n*fast_power(n,k-1);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,k;cin>>n>>m>>k;
    for(int i=0;i<=n;i++)
        parent[i] = i;
    for(int i=0;i<=n-k;i++)
    {
        for(int j=i;j<i+k-1;j++)
        {
            ll a,b;
            a = find_parent(parent[j]);
            b = find_parent(parent[j+1]);
            if(a!=b)
                parent[a] = parent[b];
        }
    }
    set <ll> s;
    for(int i=0;i<n;i++)
        s.insert(find_parent(parent[i]));
    cout<<fast_power(m,k);
return 0;
}

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>

#include<cmath>
#include<iostream>
#include<fstream>

#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>
#include<iterator>
using namespace std;

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define myabs(a) ((a)<0?-(a):(a))
#define pi acos(-1.0)
#define inf (1<<29)
#define CLR(a) memset(a,0,sizeof(a))
#define SET(a) memset(a,-1,sizeof(a))
#define pb push_back
#define all(a) a.begin(),a.end()
#define eps 1e-9
#define i64 long long
#define MX 1000002
#define MOD 1000000007

typedef pair<int,int> pii;
i64 pw(i64 m,i64 n){
	i64 res=1;
	while(n--){
		res*=m;
		res%=MOD;
	}
	return res;
}

int main()
{
	//freopen("in.txt","r",stdin);
	i64 n,m,k,res;
	while(cin>>n>>m>>k){
		if(k==1){
			res=pw(m,n)	;
		}
		else if(k>n)res=0;
		else if(k==n){
			res=pw(m,(n+1)/2);
		}
		else res=m;
		cout<<res<<endl;
	}
	return 0;
}

//#include <stdafx.h>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <ctime>
#include <cassert>

using namespace std;

const long long con=1e9+7;

long long n,m,k;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	cin>>n>>m>>k;
	if (k>n)
	{
		printf("0");
		exit(0);
	}
	if (k==n)
	{
		long long answer=1;
		long long limit;
		if (n % 2==0)
			limit=n/2;
		else limit=n/2+1;
		for (long it=1;it<=limit;it++)
		{
			answer=answer * m;
			answer=answer % con;
		}
		cout<<answer;
		exit(0);
	}
	if (k % 2==0)
	{
		cout<<m;
		exit(0);
	}
	assert(false);
	if (k==1)
	{
		long long answer=1;
		for (long it=1;it<=n;it++)
		{
			answer=answer * m;
			answer=answer % con;
		}
		cout<<answer;
		exit(0);
	}
	long long answer=m+m*(m-1);
	answer=answer % con;
	cout<<answer;
}

#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <chrono>
#include <cmath>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iso646.h>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
/*                           mnciitbhu                        */
//
//  |\    /| |\    |    --  |  |  -------  |⎻⎻\   |   |  |    |
//  | \  / | | \   |   /    |  |     |     |   |  |   |  |    |
//  |  \/  | |  \  |  (     |  |     |     |--<   |---|  |    |
//  |      | |   \ |   \    |  |     |     |   |  |   |   \  /
//  |      | |    \|    --  |  |     |     |__/   |   |    --
//
#include <queue>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
using namespace std::chrono;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#if not defined(ONLINE_JUDGE) && not defined(_MSVC_LANG) && defined(DEBUG_)
#include "myconfig.hpp"
#else
#define LOL(x) ;
#define LOLX(...) ;
#endif
	template <typename T>
T MODPow(T base, T exp, T modulus)
{
	base %= modulus;
	T result = 1;
	while (exp > 0) {
		if (exp & 1) result = (result * base) % modulus;
		base = (base * base) % modulus;
		exp >>= 1;
	}
	return result;
}

int main()
{
	cout << boolalpha;
	ios::sync_with_stdio(false);
	cin.tie(0);

	const ll mod = 1'000'000'007LL;
	ll n, m, k;
	cin >> n >> m >> k;
	if(k == 1)
	{
		ll a = ::MODPow(m, n, mod);
		cout << a;
	}
	else if(k == 3)
	{
		ll a = (m * n) % mod;
		cout << a;
	}
	else if(k <= n)
	{
		cout << m;
	}
	else if(k > 2 * n)
	{
		cout << ::MODPow(m, n, mod);
	}
	else
	{
		cout << ::MODPow(m, (k + 1) / 2, mod);
	}

	return 0;
}

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef  long long  int ll;
typedef long double db;
#define pb push_back
#define mp make_pair
#define ub(v,val) upper_bound(v.begin(),v.end(),val)
#define np(str) next_permutation(str.begin(),str.end())
#define lb(v,val) lower_bound(v.begin(),v.end(),val)
#define sortv(vec) sort(vec.begin(),vec.end())
#define rev(p) reverse(p.begin(),p.end());
#define v vector
#define pi 3.1415926535
#define len length()
#define repc(i,s,e) for(ll i=s;i<e;i++)
#define fi first
#define se second
#define mset(a,val) memset(a,val,sizeof(a));
#define mt make_tuple
#define repr(i,n) for(i=n-1;i>=0;i--)
#define rep(i,n) for( i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll M = 1e9 + 7;
ll inf = 1e18;

ll n, m;

// modular exponentiation
ll binpow(ll val, ll deg)
{
	if (!deg)
		return 1 % M;
	if (deg & 1)
		return binpow(val, deg - 1) * val % M;
	ll res = binpow(val, deg >> 1);
	return (res * res) % M;
}
int main() {
	// your code goes here
	IOS;

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ll i, j, t, k, x, y, z,  N;
	cin >> n >> m >> k;
	ll ans = 0;
	if (k < n) {
		if (k != 1)
			(ans += m) %= M;
		if (k % 2 && k > 1) {
			(ans += m * (m - 1)) %= M;
		}
		if (k == 1) {
			(ans += binpow(m, n)) %= M;
		}
		cout << ans;
	}
	if (k == n) {
		x = n / 2;
		if (n % 2)
			x++;
		(ans += binpow(m, x)) %= M;
	}
	cout << ans;
	return 0;

}

//********************************************************************//
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define fi first
#define se second
#define RANGE(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define DFOR(i, a, b) for(int i = a; i > b; --i)
#define DEB(x) cout << #x << ": " << x << endl
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define DISPV(v) { for(auto x___: v) cout << x___ << " "; cout << endl; }
#define DISPM(m) { for(auto x____: m){ cout << x____.first << ": " << x____.second << endl; } };
#define DISPMV(m) { for(auto x_____: m){ cout << x_____.first << ": " ;DISPV(x_____.second);} };
using LL = long long;
using VI = vector <int>;
using VC = vector <char>;
using VS = vector <string>;
using VL = vector <long long>;
using VVI = vector<VI>;
using VVL = vector <VL>;
using MII = map<int, int>;
using MIVI = map<int, VI>;
using MSS = map<string, string>;
using MLL = map<LL, LL>;
int READ_INT(){int temp;cin>>temp;return temp;}      // read an int
LL READ_LONG(){LL temp;cin>>temp;return temp;}      // read a long long
void mcs(VI &series, int &max_sum){                    // maximum contigous sub sum(kadane)
    int s=0;
    for(auto x: series){
        s += x;
        max_sum = max(max_sum, s);
        if(s < 0)s = 0;
    }
}
template<typename T>
T MAX(T t){ return t;}
template <typename T, typename... Args>
T MAX(T t, Args... args){ return max(t, MAX(args...)); }
const int MOD = int(1e9) + 7;
const int INF = 1e9 + 5;
const double PI = acos(-1.0); //M_PI;
const double EPS = 1e-9;
//********************************************************************//

int main(){
    ios::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m, k, mod = 1e9+7;
    cin >> n >> m >>k;
    int ans = 1;
    if(k > n){
        RANGE(i, n)
            ans = (ans * m) % mod;
    }
    else if(k == n){
        for(int i = 0; i < ceil(k/2); ++i)
            ans = (ans * m) % mod;
    }
    else{
        if(k % 2 == 1)
            ans = (m * m) % mod;
        else
            ans *= m;
    }
    if(m > 1)
        cout << ans << endl;
    else
        cout << 1 << endl;

    return 0;
}

/* complie flags
-Wall -Wextra -pedantic -std=c++11 -O2 -Wshadow -Wformat=2 -Wfloat-equal -Wconversion -Wlogical-op -Wshift-overflow=2 -Wduplicated-cond -Wcast-qual -Wcast-align -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover -fstack-protector
*/

#include<cstdio>
#include<iostream>
using namespace std;
int m, n, k;
long long b=1000000007 ;
/*long long rec(int l, int r)
{
    long long otv=1;
    if (l>r) return 1;
    if ( l==r ) return m;
    otv=m*rec(l+1, r-1)%b;
    return otv;
}*/
long long ans=0;
int mas[2100];
bool pr(int l, int r)
{
    while (l<r)
    {
        if (mas[l]!=mas[r] ) return 0;l++; r--;
    }
    return 1;
}
void rec(int t)
{
    if ( t==n+1)
    {
        for (int i=1;i<=n;i++ )
        {
            if (i+k-1>n ) break;
            if ( pr(i, i+k-1)==0 ) return ;
        }
        ans++;
    }
    else
    {
        for (int i=1;i<=m;i++)
        {
            mas[t]=i;
            rec(t+1);

        }
    }
}
int main ()
{
    scanf("%d%d%d", &n, &m, &k);
   /* if (k!=1)
    {
        printf("%d\n", m);
    }
    else
    {
        long long otv=1;
        for (int i=1;i<=n;i++)
        {
            otv=(long long)otv*m%b;
        }
        //printf("%d\n", otv);
        cout<<otv<<endl;
    }*/
    if (k==1)
    {
        ans=1;
        for (int i=1;i<=n;i++)
        {
            ans=ans*m%b;
        }
        cout<<ans;
        return 0;
    }
    {
        if (k==n)
        {   ans=1;
            for (int i=1;i<=(n+1)/2;i++)
            ans=ans*m%b;
            cout<<ans;
            return 0;

        }
    }
    if ( k%2==0)
    {
        printf("%d", m);
    }
    else
    printf("%d", m*m);
   // printf("%d", ans);
}

#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <iostream>
#include <map>
#include <queue>
#include <set>

using namespace std;

long long  n,m,k,i;
main()
{
      cin>>n>>m>>k;
      if (k>n)
      {
              cout<<0<<endl;
              return 0;
              }

      if (k==1)
      {
               for (i=1;i<=n-1;i++)
               m=((m*m) % 1000000007);
               cout<<m<<endl;
               return 0;
               }

      if (k%2==1)
      {
                cout<<m*m<<endl;
                return 0;
                 }

                 cout<<m<<endl;

}

#include <cstdio>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int (i)=0,_n=(n);(i)<_n;(i)++)
#define FOR(i,a,b) for(int (i)=(a),_n=(b);(i)<=_n;(i)++)
#define FORD(i,a,b) for(int (i)=(a),_n=(b);(i)>=_n;(i)--)
#define FOREACH(it,arr) for (__typeof((arr).begin()) it=(arr).begin(); it!=(arr).end(); it++)

const int mod = 1000000007;

int main()
{
	int n, m, k;
	scanf( "%d %d %d", &n, &m, &k );
	int ans;
	if ( k > n ) ans = 0;
	else if ( n > k ) {
		ans = m;
		if ( k % 2 == 1 && n > 1 )
			ans = (ans + m * (m - 1)) % mod;
	}
	else if ( n == k ) {
		ans = 1;
		REP(i,(n+1)/2) ans = (ans * m) % mod;
	}
	printf( "%d\n", ans );
	return 0;
}

#include <iostream>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

#define sqr(x) ((x)*(x))
#define PB(a) push_back(a)
#define MP(a) make_pair(a)
#define ll long long

int i,n,m,k,p;
string s;
int pr[10000];
bool f[10000];

const int mod=1000000007;

int get(int x) {
	if (pr[x]==x) return x;
	int k=get(pr[x]);
	return pr[x]=k;
}

void unionn(int i, int j) {
	pr[get(i)]=get(j);
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	cin >> n >> m >> k;
	ll ans=1;

	if (k>n) {
		cout << 0;
		return 0;
	}

	for (int i=0; i<n; i++) pr[i]=i;

	for (int i=0; i<n-k+1; i++) {
		for (int j=0; j<k/2; j++)
			unionn(i+j,i+k-j-1);
	}

	for (int i=0; i<n; i++) {
		if (!f[get(i)]) {
			ans=(ans*m)%mod;
		}
		f[get(i)]=true;
	}
	cout << ans;
	return 0;
}

//in the name of allah :)
#include<bits/stdc++.h>
using namespace std;
const int N=10e9+7;

int n , m , k , t , rang ;
vector < int > a[2010] ;
bool visited[2010]; // bfs;
long long s=1;
queue < int > q; // bfs ;

void bfs(int i){

	q.push(i);
	visited[i]=true;
//	cerr<<i<<endl;

	while(q.size()>0){
		int t=q.front();
		for(int j=0 ; j<a[t].size() ; j++){
			if(visited[a[t][j]]==false){
				visited[a[t][j]]=true;
				q.push(a[t][j]);
			}
		}
		q.pop();
	}

}

int main(){

	cin>>n>>m>>k;
	k--;
	t=0;

	while(k>0){
		for(int i=t ; i<n-t ; i++){
			if(i+k<n-t){
				a[i].push_back(i+k);
				a[i+k].push_back(i);
			//	cerr<<i<<" "<<i+k<<endl;
			}
		}
		t++;
		k-=2;
	}

	rang++;
	bfs(0);

	for(int i=0 ; i<n ; i++){
		if(visited[i]==false){
			rang++;
			bfs(i);
		//	cerr<<i<<endl;
		}
	}

	//cerr<<rang<<endl;

	for(int i=0 ; i<rang ; i++){
		s*=m;
		s%=N;
	}

	cout<<s;
	return 0;
}

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O4")
#include<bits/stdc++.h>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define x first
#define y second
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    int n, m ,k;
    cin>> n >> m >> k;
    if(k > n){
        ll ans = 1;
        while(n){
            n--;
            ans *= m;
            ans %= 1000000007;
        }
        cout<<ans<<endl;
    }
    else if(n == k){
        if(n < 3) cout<<m<<endl;
    else{
        ll ans = 1;
        n = (n-1)/2+1;
        while(n--){
            ans *= m;
            ans %= 1000000007;
        }
        cout<<ans<<endl;
    }
    }else{
        if(k%2 == 0) cout<<m<<endl;
        else cout<<m*m<<endl;
    }
    return 0;
}

#include<iostream>
#include<set>
#include<vector>
using namespace std;

int n,m,k;
int root[2012];
vector<int> prime;
bool isPrime(int x)
{
	if(x==2) return true;
	if(x%2==0) return false;
	int i;
	for(i=3;i*i<=x;i+=2)
		if(x%i==0) return false;
	return true;
}
void findPrime()
{
	int i;
	prime.push_back(2);
	for(i=3;i<=2012;i+=2)
		if(isPrime(i)) prime.push_back(i);
}
int find(int i)
{
	int ii=i;
	while(root[ii]!=-1) ii=root[ii];
	if(i!=ii)
		return root[i]=ii;
	return i;
}
void un(int c,int f)
{
	int rc=find(c);
	int rf=find(f);
	if(rc!=rf) root[rc]=rf;
}
long long Com(long long m,long long p)
{/*
	if(p+p>m) p=m-p;
	vector<long long> vm;
	vector<long long> vp;
	long long i;
	for(i=1;i<=p;++i)
	{
		vp.push_back(i);
		vm.push_back(m-i+1);
	}
	findPrime();
	for(i=0;i<prime.size()&& prime[i]<=p;++i)
	{
		int cnt=0;
		int j;
		for(j=0;j<p;++j)
		{
			while(vp[j]%prime[i]==0)
			{
				vp[j]/=prime[i];
				++cnt;
			}
		}
		int cnt2=0;
		while(cnt2!=cnt)
		{
			for(j=0;j<p;++j)
			{
				if(vm[j]%prime[i]==0)
				{
					++cnt2;
					vm[j]/=prime[i];
				}
				if(cnt2==cnt) break;
			}
		}

	}*/
	long long ans=1;
	int i;
	for(i=0;i<p;++i)
	{
		ans*=m-i;
		ans%=1000000007;
	}
	return ans;
}
int main(int argc, char *argv[])
{
	cin>>n>>m>>k;
	int i;
	for(i=0;i<2012;++i)
		root[i]=-1;
	for(i=0;i+k-1<n;++i)
	{
		int j;
		for(j=0;j+j<k;++j)
			un(i+k-j-1,i+j);
	}
	set<int> si;
	for(i=0;i<n;++i)
	{
		si.insert(find(i));
	}
	int p=si.size();
	if(m<p) cout<<0<<endl;
	else
	{
		cout<<Com(m,p)<<endl;
	}
	return 0;
}

#include <iostream>
#define MOD 1000000007

using namespace std;

inline int Pow(int x, int p)
{
    int i,sol=1;
    for(i=1;i<=p;++i) sol=(1LL*sol*x)%MOD;
    return sol;
}

int main()
{
    int n,m,k;
    cin>>n>>m>>k;
    if(k==n) cout<<Pow(m,n/2);
    else cout<<m;
    return 0;
}

#include <iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define M 1000000007
bool vst[2010];
int main(int argc, char *argv[]) {
	int n, m, k;
	cin >> n >> m >> k;
	memset(vst, false, sizeof(vst));
	int comp = 0;
	for (int i=0; i<n; i++) {
		if (vst[i]) continue;
		comp++;
		int idx = (i + k - 1) % n;
		vst[i] = true;
		while (idx != i) {
			vst[idx] = true;
			idx = (idx + k - 1) % n;
		}
	}
	int ret = 1;
	if (n < k) comp = n;
	for (int i=0; i<comp; i++) {
		ret = (ret % M) * (m % M) % M;
	}
	cout << ret << endl;
	return 0;
}

#include <iostream>
#include <string>
#include <cmath>
#include <deque>
#include <queue>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cassert>

using namespace std;

void prepare ()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int mod=1000000007;

long long bpow(long long x, int n)
{
	if (n==1)
		return x%mod;
	long long b=bpow(x, n/2);
	if (n&1)
		return ((x*b)%mod*b)%mod;
	return (b*b)%mod;
}

vector<long long> fact(2012);

int C(long long m)
{
	if (m==1)
		return 0;
	long long ans;
	fact[0]=1;
	for (long long i=1;i<=m;++i)
		fact[i]=fact[i-1]*i%mod;
	ans=fact[m]*bpow(fact[m-2],mod-2)%mod;
	return ans;
}

void solve()
{
	assert(bpow(10,3)==1000);
	assert(bpow(2,10)==1024);
	long long n,m,k;
	cin>>n>>m>>k;
	if (k>n)
	{
		cout<<0;
		return;
	}
	if (k==1)
	{
		cout<<bpow(m,n)<<endl;
		return;
	}
	if (k&1)
	{
		cout<<m+C(m)<<endl;
	}
	else
		cout<<m<<endl;
}

int main()
{
	prepare();
	solve();
	return 0;
}

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <complex>
#include <bitset>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define allof(c) begin(c),end(c)
#define mp make_pair

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

const int MOD=1e9+7;

int solve(int n,int m,int k)
{
	if(k>n)
		return 0;
	if(k==1){
		ll res=1;
		rep(i,n)
			res=(res*m)%MOD;
		return res;
	}
	if(k<n){
		if(k&1){
			if(n&1)
				return m*m;
			else
				return m*(m+1)/2;
		}
		else
			return m;
	}

	ll res=1;
	per(i,(k+1)/2)
		res=(res*m)%MOD;
	return res;
}

int main()
{
	for(int n,m,k;cin>>n>>m>>k && n|m|k;){
		//dump(n); dump(m); dump(k);
		cout<<solve(n,m,k)<<endl;
	}

	return 0;
}

//
//  main.cpp
//  D
//
//  Created by Liza Kondakova on 17.02.12.
//  Copyright (c) 2012 likogra@gmail.com. All rights reserved.
//

#include <iostream>
using namespace std;
long long p=1000000007;
long long pow(long long a,long long b){
    long long ans=1;
    for(int i=0;i<b;i++){
        ans*=a;
        ans%=p;
    }
    return ans;
}
int main ()
{
    long long n,k,m;
    cin>>n>>m>>k;
    if(k>n){
        cout<<pow(m,n);
    }
    if(k==n){
        cout<<pow(m,(n+1)/2);
    }
    if(k==1){
        cout<<pow(m,(n));
    }
    if(k<n){
        cout<<pow(m,(k)%2+1);
    }
    cout<<endl;
    // insert code here...
    //std::cout << "Hello, World!\n";
    return 0;
}

//#pragma comment(linker,"/STACK:16777216") /*16Mb*/
//#pragma comment(linker,"/STACK:33554432") /*32Mb*/
#define _CRT_SECURE_NO_DEPRECATE
#include <cassert>
#include <sstream>
#include<iostream>
#include<numeric>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<memory>
#include<string>
#include<vector>
#include<cctype>
#include<list>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
using namespace std;

typedef unsigned long long      ui64;
typedef long long               i64;
typedef vector<int>             VI;
typedef vector<bool>            VB;
typedef vector<VI>              VVI;
typedef vector<string>          VS;
typedef pair<int,int>           PII;
typedef map<string,int>         MSI;
typedef set<int>                SI;
typedef set<string>             SS;
typedef map<int,int>            MII;
typedef pair<double,double>     PDD;

#define PB                      push_back
#define MP                      make_pair
#define X                       first
#define Y                       second
#define FOR(i, a, b)            for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)           for(int i = (a) - 1; i >= (b); --i)
#define CLEAR(a, b)             memset(a, b, sizeof(a))
#define SZ(a)                   int((a).size())
#define ALL(a)                  (a).begin(), (a).end()
#define RALL(a)                 (a).rbegin(), (a).rend()
#define INF                     (2000000000)

#ifdef _DEBUG
#define eprintf(...) fprintf (stderr, __VA_ARGS__)
#else
#define eprintf(...) assert (true)
#endif

const i64 MOD = 1000000007ll;

int main()
{
    int n,m,k;
    while(cin >> n >> m >> k) {
        if( k%2==0 ) {
            if( k>n ) {
                i64 res = 1;
                FOR(i,0,n)
                    res = (res*m)%MOD;
                cout << res << endl;
                continue;
            }
            if( k==n ) {
                i64 res = 1;
                FOR(i,0,k/2)
                    res = (res*m)%MOD;
                cout << res << endl;
                continue;
            }
            if( k<n ) {
                cout << m << endl;
                continue;
            }
        }
        // k%2==1
        if( k>n ) {
            i64 res = 1;
            FOR(i,0,n)
                res = (res*m)%MOD;
            cout << res << endl;
            continue;
        }
        if( k==n ) {
            i64 res = 1;
            FOR(i,0,k/2 + 1)
                res = (res*m)%MOD;
            cout << res << endl;
            continue;
        }
        if( k<n ) {
            cout << m%MOD << endl;
            continue;
        }
    }

    return 0;
}

#include <iostream>
#include <vector>
using namespace std;

#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vll vector<ll>
#define vvll vector<vll>
template<typename T, typename U>
static inline void amin(T &x, U y){
	if(x>y)
		x = y;
}
template<typename T, typename U>
static inline void amax(T &x, U y){
	if(x<y)
		x = y;
}
#define rep(i,n) for(int i = 0; i < n; ++i)
#define irep(i,k,n) for(int i = k; i <= n; ++i)
#define irepr(i,k,n) for(int i = k; i >= n; --i)

const ll mod = 1e9+7;
int p[2019];
int rk[2019];

int find(int x){
	return (p[x] == x) ? x : p[x] = find(p[x]);
}

void merge(int x, int y){
	x = find(x);
	y = find(y);
	if(x==y){
		return;
	}
	if(rk[x] > rk[y]){
		swap(x ,y);
	}
	p[x] = y;
	if(rk[x]==rk[y]){
		rk[y]++;
	}
}

ll power(ll x, ll y){
	if(y == 0){
		return 1;
	}
	ll p = power((x*x)%mod, y / 2);
	if(y%2){
		return (p*x)%mod;
	}
	return p;
}

int main(){
	int n, m, k;
	cin>> n>> m>> k;
	rep(i, n){
		p[i] = i;
		rk[i] = 0;
	}
	rep(i, n){
		if(i+k-1 >= n){
			break;
		}
		rep(j, k/2){
			merge(i+j, i+k-1-j);
		}
	}
	vi present(2019, 0);
	int distinct = 0;
	rep(i, n){
		if(present[find(i)] == 0){
			present[find(i)] = 1;
			distinct++;
		}
	}
	ll ans = 1;
	ll deno = 1;
	ll r = distinct;
	for(int i = m-r+1; i <= m; ++i){
		ans = ans*i;
		ans %= mod;
		deno *= (i - m + r);
		deno %= mod;
	}
	ans = (ans * power(deno, mod - 2))%mod;
	cout << ans << "\n";
	return 0;
}

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

#define MOD 1000000007

typedef __int64 LL;

LL pow(LL x,LL y)
{
    LL rt=1;
    while(y--) rt=rt*x%MOD;
    return rt;
}

int main()
{
    LL n,m,k,res;
    cin>>n>>m>>k;
    if(k>n)
    {
        res=0;
    }
    if(k==1)
    {
        res=pow(m,n);
    }
    else if(k<n)
    {
        if(k%2) res=m*(m-1);
        else res=m;
    }
    else
    {
        res=pow(m,(n+1)/2);
    }
    cout<<res<<endl;
    return 0;
}

#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int Mod = 1e9 + 7;
long long Power(long long a,long long p)
{
	long long ans = 1;
	for(int i = 1;i <= p;i ++)ans = ans * a % Mod;
	return ans;
}
int main ()
{
	long long n,m,k;
	scanf("%I64d%I64d%I64d",&n,&m,&k);
	if(k % 2 == 0 && k < n)printf("%I64d\n",m);
	if(k == 1)printf("%I64d\n",Power(m,n) % Mod);
	else if(k > n)puts("0");
	else if(k == n)printf("%I64d\n",Power(m,(n | 1) >> 1) % Mod);
	else if(k & 1)printf("%I64d\n",1ll * m * m % Mod);
	return 0;
}

// Always write optimized code.
// Those who can't acknowledge themselves will invariably fail.

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long

ll bin(int n, int k)
{

    if (k == 0 || k == n)
        return 1;

    return bin(n - 1, k - 1) +
                bin(n - 1, k);
}

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    ll ans=0;
    ans+=m;
    if(n>1 && k==2  &&  m>k  &&  n>=k  ){
        ans+= bin(m, 2)*2;
        ans%=mod;

    }
     cout << ans << endl;
}

#include<iostream>
#include<cstdlib>
#include<vector>
#include<map>
#include<cstring>
#include<string>
#include<algorithm>
#include<ctype.h>
#include<fstream>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<stack>
#include<queue>
#include<ctime>
#include<conio.h>
using namespace std;

const int INF=0x7FFFFFFF;
const double eps=1e-10;
const double pi=acos(-1.0);

#define S(a) scanf("%d",&a)
#define SS(a,b) scanf("%d%d",&a,&b)
#define SSS(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define P(a) printf("%d\n", a)
#define PP(a,b) printf("%d %d\n",a,b)
#define PPP(a,b,c) printf("%d %d %d\n",a,b,c)
#define chmin(a,b) ((a)<(b)?(a):(b))
#define chmax(a,b) ((a)>(b)?(a):(b))

template<class T> inline T gcd(T a,T b)//NOTES:gcd(
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b)//NOTES:lcm(
  {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
int dir_4[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
int dir_8[8][2]={{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}};
//�£����£������ϣ��ϣ����ϣ��ң����¡�

long long poww(long long A,long long B)
{
    long long ans=1;
    for(int i=0; i<B; i++)
    {
        ans*=A;
        ans%=1000000007;
    }
    return ans;
}

int main()
{
    long long n,m,k;
    while(cin>>n>>m>>k)
    {
        if(k>n)
        printf("%I64d\n",poww(m,n)%1000000007);
        else if(k == n)
        {
            printf("%I64d\n",poww(m,(n+1)/2)%1000000007);
        }
        else
        {
            if(k%2)
            {
                printf("%I64d\n",(m*(m%1000000007))%1000000007);
            }
            else
            {
                printf("%I64d\n",m%1000000007);
            }
        }
    }
}

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <list>
#include <fstream>
#include <set>
using namespace std;

#define REP(i,n) for (int i = 1; i <= n; i++)
#define in(i) scanf("%d",&i)
#define out(i) printf("%d\n",i)

typedef long long ll;
const ll MOD = 1000000007;
const int maxn=1e+5;
typedef vector<vector<ll> > matrix;

int n,m,k;
int main(int argc, const char * argv[])
{
    in(n);in(m);in(k);
    ll ans =1;
    if(k>n || k<1)
    {
        for(int i=0; i<n; i++)
        {
            ans=(ans*m)%MOD;
        }
    }
    else if(k==n)
    {
        for(int i=0; i<(n+1)/2 ;++i)
        {
            ans = (ans*m)%MOD;
        }
    }
    else if(k%2==1)
    {
        ans=m*m;
    }
    else    ans = m;
    cout<<ans;
    return 0;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};

const int nmax=2500;
ll fac[nmax],finv[nmax],inv[nmax];
void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<nmax;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}

ll com(int n,int k){
  if(n<k||n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

// 繰り返し二乗法 n*nが64bitにおさまる必要
ll pow_mod(ll n,ll k,ll m){
  ll res=1;
  for(;k>0;k>>=1){
    if(k&1){
      res=(res*n)%m;
    }
    n=(n*n)%m;
  }
  return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    ll n,m,k;cin >> n >> m >> k;
    if(n<k){
        cout << 0 << endl;
        return 0;
    }
    if(k&1){
        cout << m*m%mod << endl;
    }
    else{
        cout << m%mod << endl;
    }
}

#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
#include<set>
#include<vector>
#include<map>
#include<math.h>
#include<string>
#include<string.h>
#include<queue>
#define mod 1000000007LL
using namespace std;
int par[3000];
int find(int k){
    if(par[k]!=k){
        par[k]=find(par[k]);
    }
    return par[k];
}
void _union(int a,int b){
    a=find(a);
    b=find(b);
    par[b]=a;
}
long long powm(long long a,long long b){
    if(b==0)return 1;
    if(b==1)return a%mod;
    long long ret=pow(a,b/2);
    long long r=1;
    if(b%2==1){
        r*=a;
    }
    ret=ret*ret;
    ret%=mod;
    ret=ret*r;
    ret%=mod;
    return ret;
}
int main(){
    int n,m,k;
    cin >> n >> m >> k;
    for(int i=0;i<n;i++)par[i]=i;
    for(int i=0;i<n;i++){
        if(i+k>n)break;
        for(int j=0;j<k;j++){
            //printf("%d %d\n",i+j,i+k-j-1);
            _union(i+j,i+k-j-1);
        }
    }
    set<int> s;
    for(int i=0;i<n;i++)s.insert(find(i));
    cout << powm(m,s.size())<<endl;
    return 0;
}

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <ctime>
#include <set>
#include <string>

using namespace std;

#define ll long long
#define pii pair <int, int>

const int MN = 2000 + 10;
const ll mod = 1000000007;

int u[MN];

ll dp[MN];

int n, m, k;

int up(int v) {
	if (u[v] == v)
		return u[v];
	return u[v] = up(u[v]);
}

void join(int a, int b) {
	a = up(a);
	b = up(b);
	if (rand() & 1)
		u[a] = b;
	else u[b] = a;
}

int arr[MN], ans = 0;

bool is_pal(int lf, int rg) {
	while (lf < rg) {
		if (arr[lf] != arr[rg])
			return false;
		lf ++, rg --;
	}
	return true;
}

void solve(int pos) {
	if (pos == n) {
		bool f = true;
		for(int i = 0; i + k - 1 < n; i ++)
			f &= is_pal(i, i + k - 1);
		if (f) {
			for(int i = 0; i < n; i ++)
				cout << arr[i] << " ";
			ans ++;
			cout << endl;
		}
		return;
	}
	for(int i = 1; i <= m; i ++) {
		arr[pos] = i;
		solve(pos + 1);
	}
}

int main() {
	//freopen("input.txt", "r", stdin);
	srand(time(0));

	cin >> n >> m >> k;
	for(int i = 0; i < n; i ++)
		u[i] = i;
	for(int i = 0; i + k - 1 < n; i ++) {
		int lf = i, rg = i + k - 1;
		while (lf < rg) {
			if (up(lf) != up(rg))
				join(lf, rg);
			lf ++, rg --;
		}
	}
	dp[1] = m;
	for(int i = 2; i <= n; i ++) {
		if (i % 2 == 0 || up(i) == up(i - 1))
			dp[i] = dp[i - 1];
		else
			dp[i] = (dp[i - 1] * m) % mod;
	}
	cout << dp[n] << endl;

	/*cout << endl;
	solve(0);*/
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn=1e6+7;
const int inf=INT_MAX;
const ll inff=1e18;
const ll mod=1e9+7;
#define pii pair<int,int>
#define mkp make_pair
#define F first
#define S second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define int ll

#ifdef HNO2
#define IOS
#else
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0);
#endif // HNO2

int n,m,k;

int ppow(int x,int y)
{
    if (y==0) return 1;
    int ret=ppow(x,y/2);
    ret=ret*ret%mod;
    if (y&1) ret=ret*x%mod;
    return ret;
}

int32_t main()
{
    IOS
    cin>>n>>m>>k;
    if (k>n) cout<<ppow(m,n)<<endl;
    else if (k==n) cout<<ppow(m,(n+1)/2)<<endl;
    else if (k==1||(k&1)==0) cout<<m<<endl;
    else cout<<m*m<<endl;
}

#include<bits/stdc++.h>
#define ll __int64
using namespace std;
const int mod = 1e9+7;
const int maxn = 2000+5;
int n, m, k;
int fa[maxn];

int findset(int x){
    return fa[x] == -1 ? x : fa[x] = findset(fa[x]);
}

int Union(int x, int y){
    int fx = findset(x);
    int fy = findset(y);
    if(fx != fy){
        fa[x] = fy;
        return 1;
    }
    return 0;
}

ll Solve(int x, int y){
    ll res = 1;
    while(y){
        if(y & 1)   res *= x;
        res %= mod;
        x  = (x*x)%mod;
        y /= 2;
    }
    return res;
}

int main(){
    cin>>n>>m>>k;
    memset(fa, -1, sizeof fa);
    int num = n;
    for(int i = 0;i<n;i++){
        int tmp = i+k-1;
        if(tmp >= n) break;
        int hehe = 1;
        for(int j = i;j<i+k;j++){
            int tt = j+k-hehe;
            num -= Union(j, tt);
            if(j == tt || j == tt-1)  break;
            hehe += 2;
        }
    }
  //  cout<<num<<endl;
    if(num <= 0)    num = 1;
    ll ret = Solve(m, num);
    cout<<ret<<endl;
    return 0;
}

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#define CLR(s) memset(s,0,sizeof(s))
#define PB push_back
using namespace std;
typedef long long LL;

LL n,m,k;

int main(){
	cin >> n >> m >> k;

	/*if (k==3 && n>=k){
		LL ans = (m*m)%1000000007;
		cout << ans << endl;
		return 0;
	}*/

	if (k<n && k>1){
		cout << m << endl;
	}else if (k==n){
		LL ans = 1;
		for (int i=0;i<(n+1)/2;++i){
			ans = (ans * m) % 1000000007;
		}
		cout << ans << endl;
	}else{
		LL ans = 1;
		for (int i=0;i<n;++i){
			ans = (ans * m) % 1000000007;
		}
		cout << ans << endl;
	}

	return 0;
}

#include <bits/stdc++.h>
using namespace std;
int *size,*p;
int m;
void initialise(int n)
{
    size=new int[n];
    p=new int [n];
    for(int i=0;i<n;i++)
    {
        p[i]=i;
        size[i]=1;
    }
}
int root(int i)
{
    if(p[i]==i)
    return i;
    p[i]=root(p[i]);
    return p[i];
}
void Union(int A,int B)
{
    int a=root(A);
    int b=root(B);
    if(a==b)
        return ;
    if(size[a]>size[b])
    swap(a,b);
    p[a]=b;
    if(size[a]==size[b])
       size[a]++;
    return ;
}
int multiply(int aa,int bb)
{
    return (aa*bb)%1000000007;
}
int power(int a,int n)
{
    if(n==0)
        return 1;
        if(n==1)
            return a;

    a=power(a,n/2);
     a=multiply(a,a);
    if(n%2==1)
      a=multiply(a,m);

    return a;
}

int main()
{
   int n,k;
   cin>>n>>m>>k;
    if(k>n)
    {
      cout<<power(m,n);
      return 0;
    }
   initialise(n);
   for(int i=0;i<=n-k;i++)
    for(int j=i;j<i+k/2;j++)
    Union(j,i+k-j);
   int cnt[n+1]={0};
   for(int i=0;i<n;i++)
        cnt[p[i]]++;
   int cou=count(cnt,cnt+n,0);

    cout<<power(m,n-cou-1);
    return 0;
}

#include<cstdio>
#include<iostream>
using namespace std;
const long long modul=1e9;
int n,m,k;
int main()
{
    cin>>n>>m>>k;
    if (k>n){cout<<0<<endl;return 0;}
    if (k%2==0){cout<<m<<endl;return 0;}
    cout<<m*m<<endl;
return 0;
}

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
const int M=1e3+30;
const int N=1003;
const int mo=1e9+7;
const LL inf=1e16+1;
LL qpow(LL a,LL b)
{
	LL res=1;
	while(b>0)
	{
		if(b&1)
			res=res*a%mo;
		b>>=1;
		a=a*a%mo;
	}
	return res;
}
//-------------------------

int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	LL res;
	if(n<k)
		res=qpow(m,n);
	else if(k&1)
		res=m*m;
	else
		res=m;
	printf("%I64d\n",res);

	return 0;
}

#include <iostream>
#include <cstring>
#include <cstdio>
#define modd 1000000007

using namespace std;

long long  n, m, k;
int main()
{
    cin>>n>>m>>k;

    if( k > n ) {
        cout<<0<<endl;
        return 0;
    }

    long long result = 0;
    if(k == 1) {
        result = 1;
        for(int i = 0;i < n;i++) {
            result = (result*m) %modd;
        }
    }
    else if( k % 2 == 0 ) {
        if(k==n) {
            result = 1;
            for(int i = 0;i < n/2;i++) {
                result = (result*m) %modd;
            }
        }
        else {
            result = m;
        }
    }
    else {
        if(k==n) {
            result = 1;
            for(int i = 0;i < n/2+1;i++) {
                result = (result*m) %modd;
            }
        }
        else {
            result = (m*m)%modd;
        }
    }
    cout<<result<<endl;
}

#include <cstdio>

using namespace std;

#define mod 1000000007

int n, m, k;

int lgput(int nr, int exp)
{
    long long sol=1;
    for(int i=1; i<=exp; ++i)
        sol=(sol*nr)%mod;
    return sol;
}

int main()
{
 //   freopen("data.in", "r", stdin);
 //   freopen("data.out", "w", stdout);

    scanf("%d%d%d", &n, &m, &k);
    if(k==1)
    {
        printf("%d\n", lgput(m, n));
        return 0;
    }
    if(k>=n)
    {
        printf("%d\n", lgput(m, k/2+k%2));
        return 0;
    }
    printf("%d\n", m);

    return 0;
}

#include<iostream>
using namespace std;
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	long long i,n,m,k;
	long long res,mod=1000000007;
	cin>>n>>m>>k;
	if(k>n)
	{
		cout<<0;
		return(0);
	}
	if(k==n)
	{
		res=1;
		for(i=0;i<n/2+n%2;i++)
			res=res*m%mod;
		cout<<res;
		return(0);
	}
	if(k%2==0)
	{
		cout<<m;
		return(0);
	}
	cout<<m*m;
}

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

#define MOD 1000000007
#define LL long long

int main() {
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);
    if (n > k)
        printf("%d\n", m);
    else if (n == k) {
        int v = 1, p = (n + 1) / 2;
        for (int i = 0; i < p; ++i)
            v = ((LL)v * m) % MOD;
        printf("%d\n", v);
    } else {
        puts("0");
    }
    return 0;
}

#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2e3 + 10, MOD = 1e9 + 7;

int root[MAX_N];

void build () {
  for (int i = 0; i < MAX_N; i++) root[i] = i;
}

int get (int u) {
  return root[u] = (root[u] == u) ? u : get(root[u]);
}

void merge (int u, int v) {
  u = get(u), v = get(v);
  if (u < v) swap(u, v);
  root[u] = v;
}

int modPow (int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = (1LL * ret * a) % MOD;
    a = (1LL * a * a) % MOD;
    b >>= 1;
  }
  return ret;
}

int n, m, k;

int main () {
  cin >> n >> m >> k;
  if (k > n) {
    puts("0");
    return (0);
  }
  vector <int> pib;
  for (int l = 0; l < n; l++) {
    for (int r: pib) {
      r -= l;
      if (l < r) {
        merge(l, r);
      }
    }
    int r = l + k - 1;
    if (r < n) merge(l, r), pib.push_back(r);
  }
  set <int> st;
  for (int i = 0; i < n; i++) st.insert(get(i));
  cout << modPow(m, st.size()) << endl;
  return (0);
}

//
//  B.cpp
//  codeforces
//
//  Created by Bakhodir Ashirmatov on 2/17/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

int main(){
    long long p = 1000000007;
    long long m;
    int n, k;
    cin>>n>>m>>k;
    int color;
    if (k==1|| k>n)
        color=n;
    else if (k==n)
        color=n/2;
    else
        color=1;
    long long res=1;
    for (int i=0; i<color; i++)
        res=(res*m)%p;
    cout<<res;
}

#include <stdio.h>

#define MOD 1000000007

int n, m, k;

unsigned long long pow(unsigned long long b, int e)
{
    if (e == 0)
        return 1;
    else {
        unsigned long long c = pow(b, e / 2);
        c *= c;
        if (e % 2 == 1) c *= b;
        c %= MOD;
        return c;
    }
}

int main()
{
    scanf("%d %d %d", &n, &m, &k);

    unsigned long long rv = 0;

    if (k < n) {
        if (k % 2 == 0)
            rv = m;
        else
            rv = m * (m - 1);
    }
    else if (k == n) {
        if (n % 2 == 0)
            rv = pow(m, n / 2);
        else
            rv = pow(m, n / 2 + 1);
    }
    else {
        rv = pow(m, n);
    }

    rv %= MOD;

    printf("%d\n", (int)rv);
}

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

const int mod = 1e9 + 7;
ll power(ll x, ll y) {
	if (y == 0)
		return 1;
	if (y == 1)
		return x;
	ll r = power(x, y >> 1);
	return (((r * r) % mod) * power(x, y & 1)) % mod;
}
int main() {
	run();
	int n, m, k;
	cin >> n >> m >> k;
	if (k == 1 || k > n)
		cout << power(m, n) << endl;
	else if (k == 2)
		cout << m << endl;
	else if (k & 1)
		cout << (m * m) % mod << endl;
	else
		cout << m << endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
// 繰り返し二乗法 n*nが64bitにおさまる必要
ll pow_mod(ll n,ll k,ll m){
  ll res=1;
  for(;k>0;k>>=1){
    if(k&1){
      res=(res*n)%m;
    }
    n=(n*n)%m;
  }
  return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,k;cin >> n >> m >> k;
    if(k==1){
        cout << pow_mod(m,n,mod) << endl;
        return 0;
    }
    if(n<k){
        cout << 0 << endl;
        return 0;
    }
    if(k==n){
        cout << pow_mod(m,(n+1)/2,mod) << endl;
        return 0;
    }
    if(k&1){
        cout << m*m%mod << endl;
    }
    else{
        cout << m%mod << endl;
    }
}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <map>

using namespace std;

const int mod = 1000000007;

__int64 pp( int b, int p )
{
	__int64 res = 1;

	for( int i = 0; i < p; ++i )
	{
		res *= b;
		res %= mod;
	}

	return res;
}

int main()
{
	int n, m, k;

	while( cin >> n >> m >> k )
	{
		if( k == 1 )
			printf("%I64d\n", pp(m, n));
		else if( n < k )
			printf("0\n");
		else if( n == k )
			printf("%I64d\n", pp(m, (k+1)/2));
		else
		{
			if( k % 2 )
				printf("2\n");
			else
				printf("1\n");
		}
	}

	return 0;
}

#include<iostream>
using namespace std ;

#define modm  1000000007

#define ll long long int
int main()
{

    ll n , m , k ;
    cin>> n>> m>> k ;
    if(n!=k && k%2==0 )
    {

        cout<< m<<endl ;
         return 0   ;

    }

    if(n==k || k==1)
    {

ll ans =1  ;
    for(ll i =0 ; i<(n+1)/2 ;i++  )
        ans = (ans*m )%modm ;

        cout<<ans <<endl ;

        return 0 ;

    }

// m fully type
    ll ans = m  ;

    ans = (ans + m*(m-1)/2 )%modm  ;

    cout<<ans<<endl ;

}

/*
若k==n，那么就是可以组成的回文的个数 m^(n/2)
k=1或k是偶数:全等
k是奇数：分奇偶串后全等即可
*/
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
ll n,m,k;
ll Pow(ll a,ll b){
	ll c=1;
	while(b){
		if(b%2)c=c*a%mod;
		b>>=1;a=a*a%mod;
	}
	return c;
}
int main(){
	cin>>n>>m>>k;
	if(k<1 || k>n){
		cout<<Pow(m,n);
		return 0;
	}
	if(k<n){
		if(n%2==2){
			cout<<m;
			return 0;
		}
		cout<<m*m;
		return 0;
	}
	cout<<Pow(m,(n-1)/2+1);
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
LL n, m, k;
const LL mood = 1000000007LL;
int main()
{
    cin>>m>>m>>k;
    if(n == 1) {
        cout<<m % mood<<endl;
    } else if(k == 1) {
        cout<<m%mood<<endl;
    } else if(k % 2 == 0) {
        if(n == k) {
            LL ans = 1;
            for(int i = 0 ; i < n/2; i++) {
                ans = ans * m % mood;
            }
            cout<<ans<<endl;
        } else {
                cout<<m%mood<<endl;
        }
    }
        else {
        if(n > k) {
            cout<<(m * m % mood)<<endl;
        } else {
            LL ans = 1;
            for(int i = 0 ; i < n/2; i++) {
                ans = ans * m % mood;
            }
            cout<<ans<<endl;
        }
    }
}

#include <cstdio>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int (i)=0,_n=(n);(i)<_n;(i)++)
#define FOR(i,a,b) for(int (i)=(a),_n=(b);(i)<=_n;(i)++)
#define FORD(i,a,b) for(int (i)=(a),_n=(b);(i)>=_n;(i)--)
#define FOREACH(it,arr) for (__typeof((arr).begin()) it=(arr).begin(); it!=(arr).end(); it++)

const int mod = 1000000007;

int main()
{
	int n, m, k;
	scanf( "%d %d %d", &n, &m, &k );
	int ans = m % mod;
	if ( k % 2 == 1 && n > 1 ) ans = (ans + m * (m - 1)) % mod;
	printf( "%d\n", ans );
	return 0;
}

#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stdio.h>
#include<math.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ld long double
long long n,m,k;
set <long long> a;
vector <long long> b;
const long long INF=1000000007;
int main()
{
	cin>>n>>m>>k;
	if(n<k)
		cout<<"0";
	else
	{
		if(k==1)
		{
			long long t=1;
			while(m!=0)
				t=(t*m)%INF,m--;
			long long x=1;
			for(long long i=0;i<n;i++)
				x=(x*t)%INF;
			cout<<x%INF;
		}
		else
			if(n==k)
			{
				long long t=1;
				while(m!=0)
					t=(t*m)%INF,m--;
				long long x=1;
				for(long long i=0;i<(n+1)/2;i++)
					x=(x*t)%INF;
				cout<<x%INF;
			}
			else
				if(k%2==0)
					cout<<m;
				else
				{
					long long t=1;
					while(m!=0)
						t=(t*m)%INF,m--;
					cout<<(t*t)%INF;
				}
	}

	return 0;
}

#include <string>
#include <vector>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>

using namespace std;

const int BASE = 1000000007;

int c[2001][2001];
int n, m, k, kk;
int a[5001];
int col[2001];

void create();

int main() {
  create();
  cin >> n >> m >> k;
  if (k > n) {
    long long res = 1;
    for (int i = 1; i <= n; i ++)
      res = (res * m) % BASE;
    cout << res << endl;
    return 0;
  }
  int l = 1;
  int r = k;
  int t = 0;
  while (l <= r) {
    t ++;
    a[l] = a[r] = t;
    l++;
    r--;
  }
  for (int p = 2; p <= k; p ++) {
    int l = p;
    int r = p + k - 1;
    if (r > n) break;
    a[r] = 10000;
    while (l <= r) {
      int tmin = min(a[r], a[l]);
      for (int ii = 1; ii <= k; ii ++)
	if (a[ii] == a[r]) a[ii] = tmin;
	else if (a[ii] == a[l]) a[ii] = tmin;
      l ++;
      r --;
    }
  }

  int tcount = 0;
  for (int i = 1; i <= k; i ++)
    col[a[i]] = 1;
  for (int i = 1; i <= 2000; i ++)
    if (col[i] == 1) tcount ++;

  long long res = 1;
  for (int i = 1; i <= tcount; i ++) {
    res = (m * res) % BASE;
  }
  cout << res << endl;
  return 0;
}

void create() {
  for (int i = 0; i <= 2000; i ++) c[0][i] = 1;
  for (int i = 1; i <= 2000; i ++)
    for (int j = i; j <= 2000; j ++) {
      c[i][j] = (c[i][j - 1] + c[i - 1][j - 1]) % BASE;
    }

}

#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <time.h>
#include <string.h>
#include <iostream>
using namespace std;
int n,m,k;
const long long mod=1000000007;
int main()
{
    int i;
    while (scanf("%d%d%d",&n,&m,&k)==3)
    {
          if (n<k)
          printf("0\n");
          else if (k==1)
          {
          long long             ans=1;
             for (i=1;i<=n;i++)
               ans=ans*m%mod;
               printf("%I64d\n",ans);
          }
          else if (n==k)
          {
               long long ans=1;
               int c;
               if (k%2==0)
               c=k/2;
               else
               c=k/2+1;
               for (i=1;i<=c;i++)
               ans=ans*m%mod;
               printf("%I64d\n",ans);
          }
          else
          {
               if (k%2==0)
               {
                          printf("%d\n",m);
               }
               else
               printf("%d\n",m*m);
          }
    }
}

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vt vector
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)(x).size()

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int N = 1e5 + 1;

vt<bool> V(N);
vt<vt<int>> G(N);
int n, m, k, cc;

void dfs(int u) {
  V[u] = 1;
  for (int v : G[u]) {
    if (V[v]) continue;
    dfs(v);
  }
}

void solve() {
  cin >> n >> m >> k;
  for (int i = 0; i < n - k + 1; i++) {
    for (int j = 0; j < k; j++) {
      int a = i + j;
      int b = i + k - 1 - j;
      G[a].pb(b);
      G[b].pb(a);
    }
  }

  for (int i = 0; i < n; i++) {
    if (V[i]) continue;
    dfs(i);
    cc++;
  }

  //cout << cc << endl;
  cout << ((ll) pow(m, cc)) << endl;
}

int main(){solve();}

#include<bits/stdc++.h>
#define ll long long
#define vll vector<ll>
#define vpll vector<pair<ll,ll> >
#define mll map<ll,ll>
#define sll set<ll>
#define fo(i,n) for(i=0;i<n;i++)
#define MOD 1000000007
#define mp make_pair
#define pb push_back
using namespace std;

int main()
{
    ios::sync_with_stdio(false);

    ll n,i,j,k,t,m;

    cin>>n>>m>>k;

    if(k==1)
    {
        j=1;
        fo(i,n)
            j=(j*m)%MOD;
        cout<<j;return 0;
    }
    if(j%2==0)
        cout<<m;
    else
        cout<<m*m;
    return 0;
}

#include <bits/stdc++.h>
using namespace std;

int const MOD = 1e9 + 7;

int main(){
	int n, m, k;
	scanf("%d%d%d", &n, &m, &k);

	if(k == 1 || k > n){
		long long ans = 1;
		for(int i = 0; i < n; ++i)
			ans = (ans * m) % MOD;
		printf("%lld\n", ans);
		return 0;
	}

	if(k == n){
		long long ans = 1;
		int tmp = n + 1;
		tmp /= 2;
		for(int i = 0; i < tmp; ++i)
			ans = (ans * m) % MOD;

		printf("%lld\n", ans);
		return 0;
	}

	if(k % 2 == 0){
		printf("%d\n", m);
		return 0;
	}

	if(k % 2 == 1){
		long long ans = 1;

		for(int i = 0; i < n; i += k)
			ans = (ans * m) % MOD;
		printf("%lld\n", ans);
	}

	return 0;
}

// https://codeforces.com/problemset/problem/150/B
// B. Quantity of Strings

#include <iostream>
#include <string>

#define lld long long int
#define MODULO 1000000007

using namespace std;

lld _power(int n, int m)
{
	lld result = 1;
	for(int i = 1; i <= m; ++i)
		result = (result * n) % MODULO;
	return result;
}

int main(void)
{
	int n, m, k;
	cin >> n >> m >> k;

	if(k == 1 || n < k)
		cout << _power(m, n) << endl;
	else if(n == k)
		cout << _power(m, k / 2 + 1) << endl;
	else if(k % 2)
		cout << _power(m, 2) << endl;
	else
		cout << m << endl;
	return 0;
}

#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int Mod = 1e9 + 7;
long long Power(long long a,long long p)
{
	long long ans = 1;
	for(int i = 1;i <= p;i ++)ans = ans * a % Mod;
	return ans;
}
int main ()
{
	long long n,m,k;
	scanf("%I64d%I64d%I64d",&n,&m,&k);
	if(k % 2 == 0 && k < n)printf("%I64d\n",m);
	if(k == 1)printf("%I64d\n",Power(m,n) % Mod);
	else if(k > n)puts("0");
	else if(k == n)printf("%I64d\n",Power(m,(n | 1) >> 1) % Mod);
	else if(k & 1)printf("%I64d\n",1ll * m * m % Mod);
	return 0;
}

#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
    IOS
    ll n, m, k;
    cin >> n >> m >> k;

    ll mod = 1000000007;
    ll ans = 1, i;
    if(k > n)
    {
        for(i = 0; i < n; i++)
        {
            ans = (ans*m)%mod;
        }
        cout << ans << endl;
        return 0;
    }
    if(k == n)
    {
        for(i = 0; i <= n/2; i++)
        {
            ans = (ans*m)%mod;
        }
        cout << ans << endl;
        return 0;
    }
    if(k%2 == 0)
    {
        cout << m << endl;
        return 0;
    }
    ans = (m*m)%mod;
    cout << ans << endl;

    return 0;
}

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<string>
#include<cstring>
#include<cmath>
#include<set>
#include<vector>
#include<map>
#define int long long
#define MOD 1000000007
using namespace std;
int por(int q,int w)
{
    if(!w)
        return 1;
    if(w%2)
        return (q*por(q,w-1))%MOD;
    int u=por(q,w/2);
    cout<<u*u<<"\n";
    return (u*u)%MOD;
}
main()
{
    int n,m,k;
    cin>>n>>m>>k;
    if(k==1 || k>n)
        cout<<por(m,n);
    else if(m==1)
        cout<<1;
    else if(n==k)
        cout<<por(m,(n+1)/2);
    else if(k%2==0)
        cout<<m;
    else
        cout<<m*m;
    //system("PAUSE");
    return 0;
}

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int MOD = static_cast<int>(1e9) + 7;

int combination(int n, int r, vector<vector<int>> &cache);

int main() {
	ios::sync_with_stdio(false);

	int n, m, k;
	cin >> n >> m >> k;

	int ret;

	if (k == 1 || k > n) {
		ret = 1;
		for (int i = 0; i < n; i++)
			ret = (ret * m) % MOD;
	}
	else if (n != k) {
		if (k % 2)
			ret = (m * (m - 1)) / 2;
		else
			ret = m;
	}
	else {
		ret = (k % 2 ? m : 1);
		vector<vector<int>> cache(4000, vector<int>(2000, -1));
		ret = static_cast<int>(ret * static_cast<long long> (combination(n / 2 + m - 1, m - 1, cache)));
	}

	cout << ret << '\n';
}

int combination(int n, int r, vector<vector<int>> &cache) {
	int &ret = cache[n][r];

	if (ret != -1)
		return ret;

	if (n == r || r == 0) {
		ret = 1;
		return ret;
	}

	ret = (combination(n - 1, r, cache) + combination(n - 1, r - 1, cache)) % MOD;
	return ret;
}

#include <iostream>

using namespace std;

int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    const int MOD = 1000 * 1000 * 1000 + 7 ;

    int n , m , k ;

    cin >> n >> m >> k;

    if ( k > n )
    {

        long long p = 1;
        long long x = m;

        for(int i = 0; i<n;++i)
            p = ( p * x ) % MOD ;

        cout << p  << endl;
    }
    else if ( k  == 1 )
    {
        //m^n
        long long p = 1;
        long long x = m;
        for(int i = 0; i<n;++i)
            p = ( p * x ) % MOD ;

        cout << p  << endl;
    }
    else if ( k == n)
    {
        int n2 = ( n + 1 ) / 2 ;

        //m^n2
        long long p = 1 ;
        long long x = m ;

        for(int i = 0; i< n2; ++i)
            p = ( p * x ) % MOD ;

        cout << p << endl;
    }
    else
    {
        // 1 < k < n
        cout << m << endl;
    }
}