#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  cin.sync_with_stdio(false);
  solve();
  return 0;
}
const int mod = 1000000007;
int dsu[2222];
int get(int a) {
  if (dsu[a] == a)
    return a;
  else
    return dsu[a] = get(dsu[a]);
}
void ob(int a, int b) { dsu[get(a)] = get(b); }
long long binpow(long long a, long long b) {
  if (!b) return 1;
  if (b & 1) return (a * binpow(a, b - 1)) % mod;
  return binpow((a * a) % mod, b >> 1);
}
void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    dsu[i] = i;
  }
  for (int i = 0; i + k <= n; ++i) {
    for (int j = 0; j < k; ++j) {
      ob(i + j, i + k - 1 - j);
    }
  }
  set<int> s;
  for (int i = 0; i < n; ++i) {
    s.insert(get(i));
  }
  cout << binpow(m, s.size());
}
