#include <bits/stdc++.h>
using namespace std;
const int N = 2001;
int pa[N], ra[N];
long long powmod(long long a, long long b, long long mod) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
  }
  return res;
}
int find(int a) {
  if (a == pa[a])
    return a;
  else
    return pa[a] = find(pa[a]);
}
void merge(int a, int b) {
  a = find(a);
  b = find(b);
  if (a == b) return;
  if (ra[a] > ra[b]) swap(a, b);
  ra[b] += ra[a];
  pa[a] = b;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++) pa[i] = i, ra[i] = 1;
  for (int i = 1; i <= n - k + 1; i++) {
    int x = i;
    int y = i + k - 1;
    while (x < y) merge(x, y), x++, y--;
  }
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (i == pa[i]) cnt++;
  }
  cout << powmod(m, cnt, 1e9 + 7);
  return 0;
}
