#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
static inline void amin(T &x, U y) {
  if (x > y) x = y;
}
template <typename T, typename U>
static inline void amax(T &x, U y) {
  if (x < y) x = y;
}
const long long mod = 1e9 + 7;
int p[2019];
int rk[2019];
int find(int x) { return (p[x] == x) ? x : p[x] = find(p[x]); }
void merge(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) {
    return;
  }
  if (rk[x] > rk[y]) {
    swap(x, y);
  }
  p[x] = y;
  if (rk[x] == rk[y]) {
    rk[y]++;
  }
}
long long power(long long x, long long y) {
  if (y == 0) {
    return 1;
  }
  long long p = power((x * x) % mod, y / 2);
  if (y % 2) {
    return (p * x) % mod;
  }
  return p;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    p[i] = i;
    rk[i] = 0;
  }
  for (int i = 0; i < n; ++i) {
    if (i + k - 1 >= n) {
      break;
    }
    for (int j = 0; j < k / 2; ++j) {
      merge(i + j, i + k - 1 - j);
    }
  }
  vector<int> present(2019, 0);
  int distinct = 0;
  for (int i = 0; i < n; ++i) {
    if (present[find(i)] == 0) {
      present[find(i)] = 1;
      distinct++;
    }
  }
  long long ans;
  ans = power(m, distinct);
  cout << ans << "\n";
  return 0;
}
