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