#include <bits/stdc++.h>
using namespace std;
int N, M, K, F[2005];
int Get(int u) {
  if (F[u] == u) return u;
  return F[u] = Get(F[u]);
}
void Join(int u, int v) {
  int fx = Get(u), fy = Get(v);
  if (fx != fy) F[fx] = fy;
}
int main() {
  scanf("%d%d%d", &N, &M, &K);
  for (int i = 1; i <= N; i++) F[i] = i;
  for (int i = 1; i <= N - K + 1; i++) {
    int l = i, r = i + K - 1;
    for (int k = 1; k <= K / 2; k++) Join(l + k - 1, r - k + 1);
  }
  int Ans = 1;
  for (int i = 1; i <= N; i++)
    if (Get(i) == i) Ans = (1ll * Ans * M) % 1000000007;
  printf("%d\n", Ans);
}
