#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)1e9 + 7;
long long modpow(long long x, long long d) {
  if (d == 0) {
    return 1ll;
  }
  long long ret = modpow(x, d / 2);
  ret = (ret * ret) % mod;
  if (d & 1) {
    ret = (ret * x) % mod;
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> pa(n);
  iota(pa.begin(), pa.end(), 0);
  vector<int> sz(n, 1);
  auto root = [&](int x) {
    while (pa[x] != x) {
      x = pa[x] = pa[pa[x]];
    }
    return x;
  };
  auto unite = [&](int x, int y) {
    x = root(x), y = root(y);
    if (sz[x] < sz[y]) {
      swap(x, y);
    }
    pa[y] = x;
    sz[x] += sz[y];
  };
  for (int i = 0; i + k <= n; i++) {
    int left = i, right = i + k - 1;
    while (left < right) {
      unite(left, right);
      left++, right--;
    }
  }
  int comps = 0;
  for (int i = 0; i < n; i++) {
    comps += (root(i) == i);
  }
  cout << modpow(m, comps);
}
