#include <bits/stdc++.h>
using namespace std;
int const N = 1000000007;
long long exp(long long a, long long b) {
  if (b == 0) return 1;
  long long tmp = exp(a, b / 2);
  if (b % 2 == 0)
    return (tmp * tmp) % N;
  else
    return (((a * tmp) % N) * tmp) % N;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  if (k == 1) {
    cout << exp(m, n) << endl;
  } else if (k < n && k % 2 == 1) {
    cout << exp(m, 2) << endl;
  } else if (k < n && k % 2 == 0) {
    cout << m << endl;
  } else if (k == n) {
    cout << exp(m, (k + 1) / 2) << endl;
  } else {
    cout << exp(m, n) << endl;
  }
}
