#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  if (k > n || k == 1) {
    long long ans = 1;
    for (int i = 1; i <= n; i++) ans = (ans * m) % mod;
    printf("%I64d\n", ans);
    return 0;
  }
  if (k == n) {
    long long ans = 1;
    for (int i = 1; i <= (n + 1) / 2; ++i) ans = (ans * m) % mod;
    printf("%I64d\n", ans);
    return 0;
  }
  if (k % 2 == 1) {
    long long ans = (m * m) % mod;
    printf("%I64d\n", ans);
    return 0;
  }
  printf("%d\n", m);
  return 0;
}
