#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000;
const long long q = 1000000007;
int n, m, k;
long long cnt, w, res;
int p[maxn], h[maxn];
bool used[maxn];
int getp(int x) {
  if (p[x] != x) p[x] = getp(p[x]);
  return p[x];
}
void unite(int a, int b) {
  a = getp(a);
  b = getp(b);
  if (a == b) return;
  if (h[a] < h[b]) swap(a, b);
  if (h[a] == h[b]) h[a]++;
  p[b] = a;
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    h[i] = 0;
    used[i] = false;
  }
  for (int i = 0; i + k <= n; i++) {
    for (int j = 0; j < (k + 1) / 2; j++) {
      unite(i + j, i + (k - j - 1));
    }
  }
  cnt = 0;
  for (int i = 0; i < n; i++) {
    int w = getp(i);
    if (!used[w]) {
      cnt++;
      used[w] = true;
    }
  }
  w = m;
  res = 1;
  for (long long i = 0; i < cnt; i++) {
    res = (res * w) % q;
  }
  printf("%I64d\n", res);
  return 0;
}
