#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
int f[10000];
int s(int k) {
  if (f[k] == k)
    return k;
  else
    return f[k] = s(f[k]);
}
int n, m, k;
void unions(int p1, int p2) {
  int f1 = s(p1), f2 = s(p2);
  if (f1 > f2) swap(f1, f2);
  f[f1] = f2;
}
long long ks(int k) {
  if (k == 0) return 1;
  if (k == 1) return m;
  long long tmp = ks(k / 2);
  tmp = (tmp * tmp) % mod;
  if (k & 1)
    return tmp * m % mod;
  else
    return tmp;
}
int main() {
  while (scanf("%d%d%d", &n, &m, &k) == 3) {
    for (int i = 1; i <= n; ++i) f[i] = i;
    for (int i = 1; i <= n - k + 1; ++i)
      for (int j = 1; j <= k / 2; ++j) unions(i + j - 1, i + k - j);
    int k = 0;
    for (int i = 1; i <= n; ++i)
      if (s(i) == i) ++k;
    cout << ks(k) << endl;
  }
  return 0;
}
