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