#include <bits/stdc++.h>
const long long MOD = 1000000007LL;
long long exp(int a, int b) {
  long long ans = 1;
  for (int i = 1; i <= b; i++) ans = (ans * a) % MOD;
  return ans;
}
int main() {
  int n, m, k;
  while (scanf("%d%d%d", &n, &m, &k) == 3) {
    if (k == 1 || k > n)
      printf("%I64d\n", exp(m, n));
    else if (k == n)
      printf("%I64d\n", exp(m, (n + 1) / 2));
    else if (k % 2 == 0)
      printf("%d\n", m);
    else
      printf("%d\n", m * m);
  }
  return 0;
}
