#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long binpow(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res *= a;
      res %= mod;
    }
    a *= a;
    a %= mod;
    n >>= 1;
  }
  return res;
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  if (k == 1 && n != 1)
    cout << binpow(m, n);
  else if (k > n)
    cout << binpow(m, n);
  else if (k < n && k % 2 == 1)
    cout << binpow(m, 2);
  else if (k < n && k % 2 == 0)
    cout << m;
  else
    cout << binpow(m, (n + 1) / 2);
}
