#include <bits/stdc++.h>
using namespace std;
int fa[3000];
int father(int k) {
  if (fa[k] == k) return k;
  int t = father(fa[k]);
  fa[k] = t;
  return t;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) {
    fa[i] = i;
  }
  for (int i = 1; i + k - 1 <= n; ++i) {
    int l = i, r = i + k - 1;
    while (l < r) {
      int f1 = father(l), f2 = father(r);
      if (f1 != f2) {
        fa[f2] = f1;
      }
      ++l, --r;
    }
  }
  long long ans = 1;
  for (int i = 1; i <= n; ++i) {
    if (fa[i] == i) {
      ans = ans * m % 1000000007;
    }
  }
  cout << ans << endl;
  return 0;
}
