#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
long long n, m, k;
long long binpow(long long n, long long m) {
  if (m == 0) return 1;
  if (m == 1) return n;
  long long ret = binpow(n, m / 2) % 1000000007;
  ret = ret * ret % 1000000007;
  if (m % 2) ret *= n;
  ret = ret % 1000000007;
  return ret;
}
int main(int argc, char const *argv[]) {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  if (k > n or k == 1) {
    cout << binpow(m, n) << endl;
  } else if (k == n) {
    long long ret = binpow(m, n / 2);
    if (n % 2) ret *= m;
    ret = ret % 1000000007;
    cout << ret << endl;
  } else if (k % 2) {
    cout << binpow(m, 2) << endl;
  } else {
    cout << m << endl;
  }
  return 0;
}
