#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[2001];
bool vis[2001];
void dfs(long long x) {
  vis[x] = 1;
  for (int i = 0, sz = adj[x].size(); i < sz; i++) {
    long long y = adj[x][i];
    if (!vis[y]) dfs(y);
  }
  return;
}
int main() {
  long long n, m, k, component, res;
  while (scanf("%lld %lld %lld", &n, &m, &k) == 3) {
    component = 0;
    for (long long i = 1; i + k - 1 <= n; i++) {
      long long x = k;
      for (long long j = i; x > 1; j++, x -= 2) {
        adj[j].push_back(j + x - 1);
        adj[j + x - 1].push_back(j);
      }
    }
    memset(vis, 0, sizeof vis);
    for (long long i = 1; i <= n; i++)
      if (!vis[i]) dfs(i), component++;
    res = 1;
    for (long long i = 0; i < component; i++) res = (res * m) % 1000000007;
    printf("%lld\n", res);
    for (long long i = 1; i <= n; i++) adj[i].clear();
  }
  return 0;
}
