#include <bits/stdc++.h>
long long power(int m, int pow) {
  if (pow == 1)
    return m;
  else {
    long long val = power(m, pow / 2);
    val = (val * val) % 1000000007;
    if (pow % 2) val = (val * (long long)m) % 1000000007;
    return val;
  }
}
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  if (k == 1)
    printf("%d\n", power(m, n));
  else {
    if (n > k) {
      if (k % 2)
        printf("%d\n", (m * m) % 1000000007);
      else
        printf("%d\n", m);
    } else if (n == k) {
      int pow = k / 2 + k % 2;
      printf("%I64d\n", power(m, pow));
    } else {
      printf("%d\n", power(m, n));
    }
  }
  return 0;
}
