#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long modex(long long a, long long b) {
  long long ans = 1LL;
  while (b > 0) {
    if (b % 2) {
      ans *= a;
      ans %= MOD;
    }
    a *= a;
    a %= MOD;
    b /= 2LL;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, k;
  cin >> n >> m >> k;
  if (n < k || k == 1)
    cout << modex(m, n) << "\n";
  else if (n == k)
    cout << modex(m, (n + 1) / 2) << "\n";
  else if (k % 2)
    cout << m * m << "\n";
  else
    cout << m << "\n";
  return 0;
}
