#include <bits/stdc++.h>
using namespace std;
const int maxn = 2500;
int pv[maxn];
int rk[maxn];
int findSet(int x) { return x == pv[x] ? x : pv[x] = findSet(pv[x]); }
void unionSets(int x, int y) {
  x = findSet(x), y = findSet(y);
  if (rk[x] < rk[y])
    pv[x] = y;
  else if (rk[y] < rk[x])
    pv[y] = x;
  else {
    pv[x] = y;
    ++rk[y];
  }
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int i;
  for (i = 0; i < n; ++i) {
    pv[i] = i;
    rk[i] = 0;
  }
  int j;
  for (i = n - k; i >= 0; --i)
    for (j = 0; j < k; ++j) unionSets(i + j, i + k - j - 1);
  set<int> s;
  for (i = 0; i < n; ++i) s.insert(findSet(i));
  long long mod = 1000000007LL;
  long long ans = 1;
  for (i = 1; i <= s.size(); ++i) ans = (ans * m) % mod;
  cout << ans << endl;
  return 0;
}
