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