#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007LL;
long long powmod(long long b, long long e) {
  if (!e) return 1;
  if (e & 1) return (b * powmod(b, e - 1)) % mod;
  long long r = powmod(b, e / 2);
  return (r * r) % mod;
}
bool vis[2001];
int n, k, m;
void dfs(int at) {
  vis[at] = true;
  for (int pos = 0; pos < k / 2; pos++) {
    int nxt = at - 2 * pos + k - 1;
    if (at - pos >= 0 && at - pos + k - 1 < n && !vis[nxt]) dfs(nxt);
  }
  for (int pos = 0; pos < k / 2; pos++) {
    int nxt = at + 2 * pos - k + 1;
    if (nxt - pos >= 0 && nxt - pos + k - 1 < n && !vis[nxt]) dfs(nxt);
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  int qtd = 0;
  memset(vis, 0, sizeof vis);
  for (int i = 0; i < n; i++) {
    if (!vis[i]) {
      qtd++;
      dfs(i);
    }
  }
  cout << powmod(m, qtd) << endl;
  return 0;
}
