#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000;
int pr[maxn];
int w[maxn];
bool used[maxn];
int get(int v) {
  if (v == pr[v]) return v;
  return pr[v] = get(pr[v]);
}
void fdjkalsdfkjasdlkfjhaslkjdhf(int s, int t) {
  s = get(s), t = get(t);
  if (s == t) return;
  if (w[s] == w[t]) w[s]++;
  if (w[s] > w[t])
    pr[t] = s;
  else
    pr[s] = t;
}
const int MOD = (int)1e9 + 7;
int main() {
  int n, m, k;
  while (scanf("%d%d%d", &n, &m, &k) >= 1) {
    for (int i = 0; i < n; i++) pr[i] = i, w[i] = 0;
    for (int i = 0; i <= n - k; i++)
      for (int j = 0; j < k; j++)
        fdjkalsdfkjasdlkfjhaslkjdhf(i + j, i + k - 1 - j);
    memset(used, 0, sizeof(used));
    int ans = 0;
    for (int i = 0; i < n; i++)
      if (pr[i] == i) ans++;
    long long res = 1;
    for (int i = 0; i < ans; i++) res = (res * m) % MOD;
    printf("%I64d\n", res);
  }
  return 0;
}
