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