#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long exp(long long base, long long expz) {
  long long res = 1;
  while (expz > 0) {
    if (expz % 2 == 1) res = (res * base) % mod;
    base = (base * base) % mod;
    expz /= 2;
  }
  return res % mod;
}
long long inverse(long long a) { return exp(a, mod - 2); }
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n, m, k;
  cin >> n >> m >> k;
  if (k < n && k != 1) {
    if (k % 2) {
      cout << m * m << "\n";
    } else {
      cout << m << "\n";
    }
  } else if (k == n) {
    long long by = (k + 1) / 2;
    cout << exp(m, by) << "\n";
  } else {
    cout << exp(m, n) << "\n";
  }
  return 0;
}
