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