#include <bits/stdc++.h>
using namespace std;
const long long MX = 100000;
const long long MOD = 1000000007;
long long fast_exp(long long base, long long exp, long long mod) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % mod;
    base = (base * base) % mod;
    exp /= 2;
  }
  return res;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n) {
    cout << fast_exp(m, n, MOD);
  } else if (k == n) {
    cout << fast_exp(m, (n + 1) / 2, MOD);
  } else if (k < n) {
    if (k % 2 == 0)
      cout << m;
    else
      cout << m * m;
  }
  return 0;
}
