#include <bits/stdc++.h>
using namespace std;
int pr[3000];
int find(int p) { return pr[p] == p ? p : (pr[p] = find(pr[p])); }
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  int i, j, u, v, pu, pv;
  for (i = 0; i < n; i++) pr[i] = i;
  for (i = 0, j = k - 1; j < n; i++, j++) {
    u = i;
    v = j;
    while (u < v) {
      pu = find(u);
      pv = find(v);
      if (pu != pv) {
        pr[pu] = pv;
      }
      u++;
      v--;
    }
  }
  set<int> s;
  for (i = 0; i < n; i++) s.insert(find(i));
  int p = s.size();
  long long b = m, r = 1;
  while (p) {
    if (p & 1) r = (r * b) % 1000000007;
    b = (b * b) % 1000000007;
    p >>= 1;
  }
  cout << r << '\n';
  return 0;
}
