#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e3 + 10;
const int MOD = 1e9 + 7;
int n, m, k;
int main() {
  scanf("%d %d %d", &n, &m, &k);
  if (k > n) {
    ll ans = m;
    for (int i = 1; i < n; ++i) ans = (ans * m) % MOD;
    printf("%lld\n", ans);
  } else if (k == n) {
    ll ans = m;
    for (int i = 1; i < (n + 1) / 2; ++i) ans = (ans * m) % MOD;
    printf("%lld\n", ans);
  } else if (k % 2 == 0 or n == 1)
    printf("%d\n", m);
  else if (k == 1) {
    ll ans = m;
    for (int i = 1; i < n; ++i) ans = (ans * m) % MOD;
    printf("%lld\n", ans);
  } else {
    if (m == 1) {
      puts("1");
      return 0;
    }
    ll ans = (m * (m - 1)) % MOD;
    ans = (ans + m) % MOD;
    printf("%lld\n", ans);
  }
  return 0;
}
