#include <bits/stdc++.h>
using namespace std;
long long n, total, m, qq, _inf = 1000000007;
int base[2101], gg[2101], gl, len;
void Bfs(int root) {
  int i, u, v;
  base[root] = ++len;
  for (gl = 1, gg[1] = root, i = 1; i <= gl; ++i) {
    u = gg[i];
    for (int j = 1; j <= qq; ++j) {
      if (u < j) break;
      if (u > (j + m - 1)) continue;
      v = j + j + m - 1 - u;
      if (base[v] == 0) {
        base[v] = len;
        gg[++gl] = v;
      }
    }
  }
}
int main() {
  cin >> n >> total >> m;
  if (m == 1) {
    long long ans = 1;
    for (int i = 1; i <= n; ++i) {
      ans *= total;
      if (ans >= _inf) ans %= _inf;
    }
    cout << ans << endl;
    return 0;
  }
  if (m == 2) {
    cout << total << endl;
    return 0;
  }
  memset(base, 0, sizeof(base));
  len = 0;
  qq = n - m + 1;
  for (int i = 1; i <= n; ++i)
    if (base[i] == 0) Bfs(i);
  long long ans = 1;
  for (int i = 1; i <= len; ++i) {
    ans *= total;
    if (ans >= _inf) ans %= _inf;
  }
  cout << ans << endl;
  return 0;
}
