#include <bits/stdc++.h>
using namespace std;
long long n, m, k, mod = 1e9 + 7;
long long tav(long long a, long long b) {
  long long ans = 1;
  for (int i = 0; i < b; i++) {
    ans *= (1ll * a);
    ans %= mod;
  }
  return ans;
}
int main() {
  cin >> n >> m >> k;
  if (k > n || k == 1)
    cout << tav(m, n) % mod;
  else if (k == n)
    cout << tav(m, (n + 1) / 2);
  else if (k % 2)
    cout << (m * m) % mod;
  else
    cout << m;
  return 0;
}
