#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T bigmod(T p, T e, T M) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  }
  return (T)ret;
}
template <class T>
inline T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
template <class T>
inline T modinverse(T a, T M) {
  return bigmod(a, M - 2, M);
}
template <class T>
inline T bpow(T p, T e) {
  long long int ret = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) ret = (ret * p);
    p = (p * p);
  }
  return (T)ret;
}
int toInt(string s) {
  int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int toLlint(string s) {
  long long int sm;
  stringstream ss(s);
  ss >> sm;
  return sm;
}
int ts, kk = 1;
char s[10];
int m, n;
bool chk() {
  int i, j, k;
  for (i = 0; i < 8 - m + 1; i++) {
    k = i + m - 1;
    for (j = 0; j < m; j++, k--)
      if (s[i + j] != s[k]) break;
    if (j < m) return 0;
  }
  return 1;
}
void rec(int i) {
  if (i == 8) {
    s[i] = 0;
    if (chk()) printf("%s\n", s);
    return;
  }
  int j;
  for (j = 0; j < 4; j++) {
    s[i] = 'a' + j;
    rec(i + 1);
  }
}
int main() {
  int t, i, j, k;
  scanf("%d%d%d", &n, &m, &t);
  if (t == 1 || t > n) {
    printf("%lld\n", bigmod((long long int)m, (long long int)n, 1000000007LL));
    return 0;
  }
  if (t == n) {
    long long int rs =
        bigmod((long long int)m, (long long int)n / 2, 1000000007LL);
    if (n & 1) {
      rs *= m;
      if (rs >= 1000000007LL) rs %= 1000000007LL;
    }
    printf("%lld\n", rs);
    return 0;
  }
  long long int rs;
  if (t & 1) {
    rs = m * m;
  } else
    rs = m;
  printf("%lld\n", rs);
  return 0;
}
