#include <bits/stdc++.h>
using namespace std;
long long a[10000], b[10000];
long long pow2(long long x, long long y, long long c) {
  if (y == 0) return 1;
  long long i = pow2(((x * x) % c), ((y / 2)), c);
  if (y % 2) i *= x;
  i %= c;
  return i;
}
long long get(long long v) {
  if (a[v] == v)
    return v;
  else
    a[v] = get(a[v]);
  return a[v];
}
void merge(long long x, long long y) {
  long long l = get(x);
  long long k = get(y);
  if (l == k)
    return;
  else
    a[l] = k;
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  for (long long i = 1; i <= n; i++) a[i] = i;
  for (long long i = 1; i <= (n - k + 1); i++) {
    long long l = i, r = i + k - 1;
    while (l <= r) {
      merge(l++, r--);
    }
  }
  long long c = 0;
  for (long long i = 1; i <= n; i++)
    if (a[i] == i) c++;
  cout << (((long long)pow2(m, c, 1000000007)) % 1000000007);
}
