#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
ostream cnull(NULL);
const int INF = 1000 * 1000 * 1000;
const long long LINF = 1LL * INF * INF;
const int MAX = 100010;
const long double PI = acos(-1.);
const double EPS = 1e-6;
const long long mod = INF + 7;
int n, m, k;
long long binpow(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n % 2) {
      res *= a;
      res %= mod;
    }
    a *= a;
    a %= mod;
    n /= 2;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  if (k > n) {
    cout << binpow(m, n) << endl;
    return 0;
  }
  if (k == n) {
    cout << binpow(m, (n + 1) / 2) << endl;
    return 0;
  }
  if (k == 1) {
    cout << binpow(m, n) << endl;
    return 0;
  }
  if (k % 2 == 1) {
    cout << m * m << endl;
    return 0;
  }
  cout << m << endl;
  return 0;
  return 0;
}
