#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2020;
long long n, m, k, p[maxn];
long long getpa(long long x) {
  if (p[x] == x)
    return p[x];
  else
    return p[x] = getpa(p[x]);
}
long long Qpower(long long a, long long b) {
  long long res = 1;
  a %= 1000000007;
  while (b) {
    if (b & 1) res = res * a % 1000000007;
    a = a * a % 1000000007;
    b >>= 1;
  }
  return res;
}
signed main() {
  cin >> n >> m >> k;
  for (register long long i = (1); i <= (n); ++i) p[i] = i;
  for (long long i = 1; i + k - 1 <= n; i++) {
    for (register long long j = (i); j <= (i + (k - 1) / 2); ++j) {
      p[getpa(j)] = getpa(i * 2 + k - j - 1);
    }
  }
  long long cnt = 0;
  for (register long long i = (1); i <= (n); ++i)
    if (p[i] == i) cnt++;
  cout << Qpower(m, cnt) << endl;
  return 0;
}
