#include <bits/stdc++.h>
using namespace std;
long long root[2020];
void init(long long n) {
  for (long long i = 0; i <= n + 1; i++) root[i] = -1;
}
long long find(long long n) {
  if (root[n] < 0)
    return n;
  else
    return root[n] = find(root[n]);
}
void merge(long long a, long long b) {
  a = find(a), b = find(b);
  if (a != b) root[b] = a;
}
signed main() {
  long long n, m, k;
  cin >> n >> m >> k;
  init(n);
  for (long long i = 0, j = k - 1; j < n; i++, j++) {
    for (long long x = i, y = j; x < y; x++, y--) merge(x, y);
  }
  long long cc = 0;
  for (long long i = 0; i < n; i++) cc += (root[i] < 0);
  long long ans = 1;
  for (long long i = 0; i < cc; i++) ans = (ans * m) % 1000000007;
  cout << ans << "\n";
}
