#include <bits/stdc++.h>
using namespace std;
const int md = 1000000007;
int n, m, k;
int chk[2222];
vector<int> g[2222];
int ans;
void dfs(int u) {
  chk[u] = 1;
  for (int i = 0; i < g[u].size(); ++i)
    if (!chk[g[u][i]]) dfs(g[u][i]);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n - k + 1; ++i) {
    int l = i, r = i + k - 1;
    while (l < r) {
      g[l].push_back(r);
      g[r].push_back(l);
      ++l;
      --r;
    }
  }
  for (int i = 1; i <= n; ++i)
    if (!chk[i]) dfs(i), ++ans;
  long long f = 1;
  for (int i = 1; i <= ans; ++i) f = f * m % md;
  printf("%I64d", f);
  return 0;
}
