#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int n, m, k;
long long ipow(long long base, int p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = (r * base) % MOD;
    base = (base * base) % MOD;
    p >>= 1;
  }
  return r;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  long long res = 0;
  if (n < k)
    res = ipow(m, n);
  else if (n == k) {
    int p = (n + 1) / 2;
    res = ipow(m, p);
  } else if (k == 1)
    res = ipow(m, n);
  else if (k % 2 == 0)
    res = m;
  else {
    res = ipow(m, 2);
  }
  printf("%lld", res);
  return 0;
}
