#include <bits/stdc++.h>
using namespace std;
long long gcd(long long n1, long long n2) {
  if (!n1) return n2;
  if (!n2) return n1;
  if (n1 % n2 == 0) return n2;
  return gcd(n2, n1 % n2);
}
long long powmod(long long base, long long exponent) {
  long long ans = 1;
  while (exponent) {
    if (exponent & 1) ans = (ans * base) % 1000000007;
    base = (base * base) % 1000000007;
    exponent /= 2;
  }
  return ans;
}
int main() {
  int n, m, k, i, j;
  long long answer = 0;
  cin >> n >> m >> k;
  if (k > n)
    answer = powmod(m, n);
  else {
    if (k == 1)
      answer = powmod(m, n);
    else if (k == n) {
      answer = powmod(m, (n + 1) / 2);
    } else {
      if (k % 2 == 0)
        answer = m;
      else
        answer = m * m;
    }
  }
  cout << answer;
  return 0;
}
