#include <bits/stdc++.h>
using namespace std;
const long long N = 2010, M = 1e9 + 7;
int n, m, k, cmp, par[N];
int root(int u) { return (par[u] == u) ? u : par[u] = root(par[u]); }
long long _pow(int a, int b) {
  if (!b) return 1;
  if (b == 1) return a;
  return (b % 2) ? (1LL * _pow(a, b / 2) * _pow(a, b / 2) * a) % M
                 : (1LL * _pow(a, b / 2) * _pow(a, b / 2)) % M;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
  cin >> n >> m >> k;
  cmp = n;
  for (int i = 0; i < n; i++) par[i] = i;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i && (2 * j) + 1 < k; j++) {
      if (i + k - j - 1 < n && root(i) != root(i + k - (2 * j + 1))) {
        par[root(i)] = par[i + k - (2 * j + 1)];
        cmp--;
      }
    }
  }
  long long ans = 1;
  for (int i = 0; i < cmp; i++) {
    ans *= m;
    ans %= M;
  }
  cout << ans;
  return 0;
}
