#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9;
const long long inf64 = 1e18;
const long long MOD = inf + 7;
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;
}
long long modinv(long long k) { return pow(k, MOD - 2, MOD); }
int32_t main() {
  long long n, m, k;
  cin >> n >> m >> k;
  if (k == 1)
    cout << pow(m, n, MOD);
  else if (k > n)
    cout << pow(m, n, MOD);
  else if (k == n)
    cout << pow(m, ceil(n / 2.0), MOD);
  else if (k & 1)
    cout << pow(m, 2, MOD);
  else
    cout << m;
}
