#include <bits/stdc++.h>
using namespace std;
void split(const string &s, vector<string> &tokens, char delimiter) {
  string token;
  istringstream tokenStream(s);
  while (getline(tokenStream, token, delimiter)) tokens.push_back(token);
}
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n)
    cout << modpow(m, n, (long long)1000000007);
  else if (k == n)
    cout << modpow(m, (n + 1) / 2, (long long)1000000007);
  else if (k % 2)
    cout << m * m;
  else
    cout << m;
  return 0;
}
