#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long BM(long long b, long long p, long long mod) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = (ret * b) % mod;
    p /= 2;
    b = (b * b) % mod;
  }
  return ret;
}
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  long long ans;
  if (k == 1 || k > n)
    ans = BM(m, n, mod);
  else if (k == n)
    ans = BM(m, (n + 1) / 2, mod);
  else if (k % 2 == 0)
    ans = m;
  else
    ans = m * m;
  printf("%lld\n", ans);
}
