#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long int n, m, k;
long long int fexp(long long int base, long long int e) {
  long long int ans = 1;
  while (e > 0) {
    if (e % 2 == 1) {
      ans = base * ans % mod;
    }
    e >>= 1;
    base = base * base % mod;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  long long int ans = 1;
  if (k > n || k == 1) {
    ans = fexp(m, n);
  } else if (k == n) {
    ans = fexp(m, (n + 1) / 2);
  } else {
    if (k % 2 == 0)
      ans = m;
    else {
      ans = m * m % mod;
    }
  }
  cout << ans << endl;
  return 0;
}
