#include <bits/stdc++.h>
using namespace std;
bool isPowerOfTwo(long long int x) { return x && (!(x & (x - 1))); }
long long int Modular_Exponentiation(long long int x, long long int n,
                                     long long int M = 1000000007) {
  if (n == 0) return 1;
  if (n % 2)
    return (x * Modular_Exponentiation((x * x) % M, n / 2, M)) % M;
  else
    return (Modular_Exponentiation((x * x) % M, n / 2, M)) % M;
}
void solve() {
  long long int n, m, k;
  cin >> n >> m >> k;
  if (k == 1 or k > n)
    cout << Modular_Exponentiation(m, n);
  else if (k == n)
    cout << Modular_Exponentiation(m, (n + 1) / 2);
  else if (k & 1)
    cout << m * m;
  else
    cout << m;
}
int32_t main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  while (T--) solve();
  return 0;
}
