#include <bits/stdc++.h>
using namespace std;
const long long N = 2005;
const long long MOD = 1000 * 1000 * 1000 + 7;
long long mul(long long a, long long b) { return (a * b + MOD) % MOD; }
long long add(long long a, long long b) { return (a + b + MOD) % MOD; }
vector<long long> g[N];
long long n, m, k, p;
void input() {
  cin >> n >> m >> k;
  p = k % 2;
}
void makeGraph() {
  for (long long i = 1; i <= n; i++)
    for (long long j = i + 1; j <= n; j++) {
      long long diff = abs(j - i);
      if (diff < k && diff % 2 != p && k <= n) {
        int now = j - i + 1;
        int go = (k - now) / 2;
        int rmost = go + j;
        int lmost = i - go;
        if (rmost <= n && lmost >= 1) {
          g[i].push_back(j);
          g[j].push_back(i);
        }
      }
    }
}
long long col[N];
void dfs(long long u) {
  col[u] = 1;
  for (long long i = 0; i < g[u].size(); i++)
    if (!col[g[u][i]]) dfs(g[u][i]);
}
long long ccp() {
  memset(col, 0, sizeof col);
  long long cnt = 0;
  for (long long i = 1; i <= n; i++) {
    if (!col[i]) {
      cnt++;
      dfs(i);
    }
  }
  return cnt;
}
long long POW(long long a, long long lu) {
  if (lu == 1) return a % MOD;
  if (lu == 0) return 1;
  long long mi = POW(a, lu / 2);
  mi = mul(mi, mi);
  if (lu & 1) mi = mul(mi, a);
  return mi;
}
int main() {
  input();
  makeGraph();
  long long ans = POW(m, ccp());
  cout << ans << endl;
}
