#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int base = 97;
long long res = 1;
const int MAX_N = 2001;
int pr[MAX_N];
int sz[MAX_N];
int find(int v) {
  if (pr[v] == v) return v;
  return pr[v] = find(pr[v]);
}
void Union(int u, int v) {
  u = find(u);
  v = find(v);
  if (u == v) return;
  if (sz[u] > sz[v]) swap(u, v);
  pr[u] = v;
}
int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++) pr[i] = i, sz[i] = 1;
  for (int i = 0; i + k - 1 < n; i++)
    for (int j = 0; 2 * j < k; j++) Union(i + j, i + k - 1 - j);
  for (int i = 0; i < n; i++)
    if (find(i) == i) {
      res = 1LL * res * m % MOD;
    }
  cout << res << endl;
}
