#include <bits/stdc++.h>
using namespace std;
inline long long in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline string getStr() {
  char ch[1000000];
  scanf("%s", ch);
  return ch;
}
inline char getCh() {
  char ch;
  scanf(" %c", &ch);
  return ch;
}
template <class P, class Q>
inline P smin(P &a, Q b) {
  if (b < a) a = b;
  return a;
}
template <class P, class Q>
inline P smax(P &a, Q b) {
  if (a < b) a = b;
  return a;
}
const long long MOD = 1e9 + 7;
const long long MAX_N = 1e5 + 10;
const long long MAX_LG = 21;
const long long base = 29;
const long long MAX_DIF = 2001;
long long res = 1;
long long pr[MAX_N], sz[MAX_N];
inline long long root(long long p) {
  return (pr[p] == p ? p : (pr[p] = root(pr[p])));
}
inline void merge(long long p, long long q) {
  p = root(p), q = root(q);
  if (p == q) return;
  if (sz[p] < sz[q]) swap(p, q);
  pr[q] = p;
  sz[p] += sz[q];
}
int32_t main() {
  long long n = in(), m = in(), k = in();
  long long rem = 0;
  for (long long i = 0; i < n; i++) pr[i] = i, sz[i] = 1;
  for (long long i = 0; i + k - 1 < n; i++) {
    for (long long pt = i; pt < (i + k / 2); pt++) {
      merge(pt, i + k - 1 - (pt - i));
    }
  }
  for (long long i = 0; i < n; i++)
    if (root(i) == i) rem++;
  for (long long i = 0; i < rem; i++) res = 1LL * res * m % MOD;
  cout << res << "\n";
}
