#include <bits/stdc++.h>
using namespace std;
const int MAX = 2000;
const int INF = 1000000001;
vector<int> G[MAX];
bool vis[MAX];
int n, m, k;
void dfs(int v) {
  vis[v] = true;
  for (__typeof((G[v]).begin()) u = (G[v]).begin(); u != (G[v]).end(); ++u)
    if (!vis[*u]) dfs(*u);
}
int main(int argc, char *argv[]) {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; ++i) {
    int ii = i;
    int j = i + k - 1;
    if (j < n)
      while (ii < j) {
        G[ii].push_back(j);
        G[j].push_back(ii);
        ++ii;
        --j;
      }
  }
  long long res = 1;
  for (int i = 0; i < n; ++i)
    if (!vis[i]) res = (res * m) % 1000000007, dfs(i);
  printf("%d\n", (int)res);
  return 0;
}
