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