#include <bits/stdc++.h>
using namespace std;
const long long N = 2005;
const long long MOD = 1e9 + 7;
long long n, m, k;
long long pow(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m >> k;
  if (k == 1 || k > n)
    cout << pow(m, n, MOD);
  else if (k == n)
    cout << pow(m, (n + 1) / 2, MOD);
  else if (k % 2 == 0)
    cout << m;
  else
    cout << pow(m, 2LL, MOD);
  return 0;
}
