#include <bits/stdc++.h>
using namespace std;
const int N = 2018, M = 1000000007;
int n, m, k, dsu[N];
int find(int x) { return dsu[x] == x ? x : dsu[x] = find(dsu[x]); }
void Union(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  dsu[x] = y;
}
int connect(int l, int r) {
  while (l < r) {
    Union(l, r);
    ++l;
    --r;
  }
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) dsu[i] = i;
  for (int i = 1; i <= n - k + 1; ++i) connect(i, i + k - 1);
  int ans = 1;
  for (int i = 1; i <= n; ++i)
    if (dsu[i] == i) ans = (1LL * m * ans) % M;
  cout << ans << endl;
  return 0;
}
