#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 10;
const int mod = 1e9 + 7;
vector<int> node[maxn];
int n, m, k;
long long ans = 1;
bool mark[maxn];
void conect(int L, int R) {
  while (L < R) {
    node[L].push_back(R);
    node[R].push_back(L);
    L++;
    R--;
  }
}
void dfs(int root) {
  mark[root] = true;
  for (int i = 0; i < node[root].size(); i++)
    if (!mark[node[root][i]]) dfs(node[root][i]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (int i = 1; i <= n - k + 1; i++) conect(i, i + k - 1);
  int moal = 0;
  for (int i = 1; i <= n; i++)
    if (!mark[i]) {
      dfs(i);
      moal++;
    }
  while (moal > 0) {
    ans = (ans * m) % mod;
    moal--;
  }
  cout << ans << endl;
  return 0;
}
