#include <bits/stdc++.h>
using namespace std;
const int mo = 1000000007;
int fa[2010];
bool a[2010];
int n, m, k;
int Get(int x) {
  if (fa[x] == x) return x;
  fa[x] = Get(fa[x]);
  return fa[x];
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) fa[i] = i;
  for (int i = 1, j = k; j <= n; ++i, ++j) {
    for (int ii = i, jj = j; ii < jj; ++ii, --jj) {
      int fax = Get(ii);
      int fay = Get(jj);
      fa[fax] = fay;
    }
  }
  memset(a, false, sizeof(a));
  for (int i = 1; i <= n; ++i) a[Get(i)] = true;
  long long res = 1;
  for (int i = 1; i <= n; ++i)
    if (a[i]) res = res * m % mo;
  cout << res << endl;
  return 0;
}
