#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000 * 1000 * 1000 + 7;
const double PI = 3.14159265358979323846264;
const pair<long long int, long long int> steps[] = {
    {1, 0}, {0, 1}, {-1, 0}, {0, -1}, {1, -1}, {1, 1}, {-1, -1}, {-1, 1}};
template <typename... T>
void read(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void write(T&&... args) {
  ((cout << args << " "), ...);
}
void fio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
void setUpLocal() {}
const long long int maxN = 2 * 1e3;
const long long int gp_size = maxN;
vector<long long int> gp[gp_size];
long long int vis[gp_size];
long long int cnt[gp_size];
void dfs(long long int i) {
  vis[i] = 1;
  for (long long int child : gp[i])
    if (!vis[child]) dfs(child);
}
long long int modPow(long long int n, long long int k) {
  long long int ret = 1;
  while (k) {
    if (k & 1) ret = ret * n % mod;
    k >>= 1;
    n = n * n % mod;
  }
  return ret;
}
void solve() {
  long long int n, m, k;
  cin >> n >> m >> k;
  for (long long int i = 1; i <= n - k + 1; i++) {
    for (long long int f = i, b = i + k - 1; f <= b; f++, b--) {
      gp[f].push_back(b);
      gp[b].push_back(f);
    }
  }
  long long int cc = 0;
  for (long long int i = 1; i <= n; i++) {
    if (!vis[i]) {
      cc++;
      dfs(i);
    }
  }
  cout << modPow(m, cc);
}
int32_t main() {
  fio();
  setUpLocal();
  return solve(), 0;
}
