#include <bits/stdc++.h>
using namespace std;
int f[2005];
const int inf = 1000000007;
int fin(int x) {
  if (f[x] != x) {
    f[x] = fin(f[x]);
  }
  return f[x];
}
void add(int x, int y) {
  int i = fin(x), j = fin(y);
  if (i == j) return;
  f[i] = j;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    f[i] = i;
  }
  for (int i = 0; i <= n - k; i++) {
    for (int j = i, d = k + i - 1; j < i + k; j++, d--) {
      add(j, d);
    }
  }
  long long ans = 1;
  for (int i = 0; i < n; i++) {
    if (f[i] == i) ans = (ans * m) % inf;
  }
  cout << ans;
  return 0;
}
