#include <bits/stdc++.h>
using namespace std;
const int OO = 1e9 + 7;
const int MOD = 1e9 + 7;
const int N = 2e3 + 7;
int par[N];
int find(int x) {
  if (x == par[x]) return x;
  par[x] = find(par[x]);
  return par[x];
}
bool merge(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return 0;
  if (rand() & 1) swap(x, y);
  par[x] = y;
  return 1;
}
long long fast_pow(int a, int b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0) {
    long long gg = fast_pow(a, b / 2);
    return (gg * gg) % MOD;
  } else
    return (fast_pow(a, b - 1) * a) % MOD;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i <= N - 1; i++) par[i] = i;
  for (int i = 1; i <= n - k + 1; i++) {
    int cnt = 0;
    for (int j = i; j <= (k / 2) + i - 1; j++) {
      merge(find(j), find(i + k - 1 - cnt));
      cnt++;
    }
  }
  set<int> st;
  for (int i = 1; i <= n; i++) {
    st.insert(find(i));
  }
  cout << fast_pow(m, st.size()) << endl;
  return 0;
}
