#include <bits/stdc++.h>
using namespace std;
const int OO = 0x3f3f3f3f, N = 3e3 + 5, mod = 1e9 + 7;
int n, m, k;
vector<int> adj[N];
bool vis[N];
long long ans = 1;
void dfs(int p) {
  vis[p] = 1;
  for (int ch : adj[p]) {
    if (!vis[ch]) dfs(ch);
  }
}
int main() {
  cin >> n >> m >> k;
  for (int u = 1; u + k - 1 <= n; ++u) {
    for (int i = u, j = u + k - 1; i <= j; ++i, --j) {
      adj[i].push_back(j);
      adj[j].push_back(i);
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      ans = (ans * m) % mod;
      dfs(i);
    }
  }
  cout << ans;
  return 0;
}
