#include <bits/stdc++.h>
using namespace std;
const int M = 1000000000 + 7;
long long powm(int m, int n) {
  long long ans = 1;
  for (int i = 0; i < n; ++i) ans = (ans * m) % M;
  return ans;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  long long ans = 0;
  if (k == 1 || k > n)
    ans = powm(m, n);
  else {
    int b[2000];
    for (int i = 0; i < n; ++i) b[i] = 2000;
    for (int i = 0; i < k / 2 + k % 2; ++i) b[i] = b[k - i - 1] = i;
    bool pr;
    do {
      pr = false;
      for (int q = 0; q + k - 1 < n; ++q)
        for (int p = 0; p < k / 2; ++p) {
          pr = pr || b[q + p] != b[q + k - p - 1];
          b[q + p] = b[q + k - p - 1] = min(b[q + p], b[q + k - p - 1]);
        }
    } while (pr);
    char c[2000];
    memset(c, 0, sizeof(c));
    ;
    for (int i = 0; i < n; ++i) c[b[i]] = 1;
    for (int i = 0; i < 2000; ++i) ans += c[i];
    ans = powm(m, ans);
  }
  cout << ans << endl;
  return 0;
}
