#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
int main() {
  long long int n, m, k;
  scanf(" %I64d %I64d %I64d", &n, &m, &k);
  if (k == 1 || k > n) {
    long long int res = 1LL;
    for (long long int i = 1; i <= n; i++) res = (res * m) % MOD;
    printf("%I64d\n", res);
  } else if (k == n) {
    long long int res = 1LL;
    for (long long int i = 1; i <= (n + 1) / 2; i++) res = (res * m) % MOD;
    printf("%I64d\n", res);
  } else if (k % 2)
    printf("%I64d\n", (m * m) % MOD);
  else
    printf("%I64d\n", m);
  return 0;
}
