#include <bits/stdc++.h>
using namespace std;
int pnt[4000];
int find(int x) {
  if (x != pnt[x]) pnt[x] = find(pnt[x]);
  return pnt[x];
};
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) pnt[i] = i;
  for (int i = 0; i + k <= n; i++) {
    for (int j = 0; j < k; j++) {
      int t = i + j;
      int rt = i + k - j - 1;
      pnt[find(t)] = find(rt);
    }
  }
  int ans = 1;
  for (int i = 0; i < n; i++)
    if (i == pnt[i]) {
      ans = (long long)ans * m % 1000000007;
    }
  printf("%d\n", ans);
  return 0;
}
