#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  return res % 1000000007;
}
long long par[2005];
long long vis[2005][2005];
long long fint(long long x) {
  if (par[x] == x)
    return x;
  else
    return par[x] = fint(par[x]);
}
int main() {
  long long i, j, k, l, m, n, t, ans, r, len, p, q, M, L, R;
  cin >> n >> m >> k;
  if (k > n || k == 1) {
    cout << power(m, n) << '\n';
    return 0;
  }
  for (i = 1; i <= n; i++) par[i] = i;
  memset(vis, 0, sizeof vis);
  M = n - k + 1;
  l = 1;
  r = l + k - 1;
  while (M--) {
    L = l, R = r;
    while (L < R) {
      if (vis[L][R]) break;
      vis[L][R] = 1;
      p = fint(L);
      q = fint(R);
      par[p] = q;
      L++;
      R--;
    }
    l++;
    r++;
  }
  set<long long> total;
  for (i = 1; i <= n; i++) {
    total.insert(fint(i));
  }
  len = total.size();
  cout << power(m, len) << '\n';
}
