#include <bits/stdc++.h>
using namespace std;
int n, m, k;
vector<int> adj[2005];
vector<int> vis(2005, -1);
void dfs(int v) {
  vis[v] = 1;
  for (auto &val : adj[v]) {
    if (vis[val] == -1) {
      dfs(val);
    }
  }
}
void get_edg(int l, int r) {
  while (l <= r) {
    adj[l].push_back(r);
    adj[r].push_back(l);
    l++;
    r--;
    if (l == r) break;
  }
}
int power(long long x, int n, int m) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return power((x * x) % m, n / 2, m);
  else {
    return (x * (power((x * x) % m, (n - 1) / 2, m) % m)) % m;
  }
}
int main() {
  long long MOD = 1e9 + 7;
  int t;
  t = 1;
  while (t--) {
    cin >> n >> m >> k;
    int l = 1, r = k;
    while (r <= n) {
      get_edg(l, r);
      l++, r++;
    }
    long long grp = 0;
    for (int i = 1; i <= n; i++) {
      if (vis[i] == -1) {
        grp++;
        dfs(i);
      }
    }
    cout << power(m, grp, MOD);
  }
  return 0;
}
