#include <bits/stdc++.h>
using namespace std;
long long t, u, v, n, c, d, m, q, l, r, ql, qr, x, k;
const int N = 1e5 + 5;
const long long mod = 1e9 + 7;
const bool JUDGE = false;
vector<int> adj[N];
bool vis[N];
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = true;
  for (long long i = 0; i < adj[x].size(); i++) {
    dfs(adj[x][i]);
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  if (JUDGE) {
    freopen("cf.txt", "r", stdin);
    freopen("cf_out.txt", "w", stdout);
  }
  cin >> n >> m >> k;
  if (k & 1) {
    for (long long i = k / 2; i < n - k / 2; i++) {
      for (long long j = 1; j < k / 2 + 1; j++) {
        adj[i - j].push_back(i + j);
        adj[i + j].push_back(i - j);
      }
    }
  } else {
    for (long long i = k / 2 - 1; i < n - k / 2; i++) {
      for (long long j = 0; j < k / 2; j++) {
        int v = i - j;
        int u = i + j + 1;
        adj[u].push_back(v);
        adj[v].push_back(u);
      }
    }
  }
  int e = 0;
  memset(vis, false, sizeof(vis));
  for (long long i = 0; i < n; i++) {
    if (!vis[i]) {
      e++;
      dfs(i);
    }
  }
  long long ans = 1;
  for (long long i = 0; i < e; i++) {
    ans = (ans * m) % mod;
  }
  cout << ans << '\n';
  return 0;
}
