#include <bits/stdc++.h>
using namespace std;
long long n, m, k, p[2005], res;
long long ope(long long x) { return x == p[x] ? x : p[x] = ope(p[x]); };
long long fpower(long long x, long long k) {
  long long ans = 1;
  while (k) {
    if (k & 1) ans = (ans * x) % 1000000007;
    k >>= 1;
    x = (long long)(x * x) % 1000000007;
  }
  return ans;
}
int main() {
  scanf("%I64d%I64d%I64d", &n, &m, &k);
  for (long long i = 1; i <= n; i++) p[i] = i;
  for (long long i = 1; i <= n - k + 1; i++) {
    for (long long j = 0; j < k / 2; j++)
      if (ope(i + j) != ope(i + k - 1 - j)) p[p[i + j]] = p[i + k - 1 - j];
  }
  for (long long i = 1; i <= n; i++) res += (p[i] == i);
  printf("%I64d\n", fpower(m, res));
  return 0;
}
