#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long power(long long A, long long B) {
  long long result = 1;
  long long temp = A;
  while (B != 0) {
    if (B % 2 == 1) {
      result *= temp;
      result %= MOD;
    }
    temp *= temp;
    temp %= MOD;
    B /= 2;
  }
  return result;
}
long long solve(long long n, long long m, long long k) {
  if (k > n)
    return power(m, n);
  else if (k == n)
    return power(m, (n + 1) / 2);
  else {
    if (k % 2 == 1) {
      if (k == 1)
        return power(m, n);
      else
        return power(m, 2);
    } else
      return power(m, 1);
  }
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  cout << solve(n, m, k);
  return 0;
}
