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