#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> parent;
vector<int> rank2;
int mod = 1e9 + 7;
int find(int p) {
  if (parent[p] == p) return p;
  int temp = find(parent[p]);
  return parent[p] = temp;
}
void union2(int p1, int p2) {
  if (rank2[p1] < rank2[p2])
    parent[p1] = p2;
  else if (rank2[p1] > rank2[p2])
    parent[p2] = p1;
  else {
    parent[p1] = p2;
    rank2[p2] += 1;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  int i, j, n, m, k;
  cin >> n >> m >> k;
  if (k > n) {
    long long ans = 1;
    for (i = 0; i < n; i++) {
      ans = (ans * m) % mod;
    }
    cout << ans << endl;
    return 0;
  }
  parent.clear();
  parent.resize(n, 0);
  rank2.clear();
  rank2.resize(n, 0);
  for (i = 0; i < n; i++) {
    parent[i] = i;
    rank2[i] = 1;
  }
  for (i = 0; i <= n - k; i++) {
    int diff = k - 1;
    for (j = i;; j++) {
      int l = j, r = j + diff;
      if (l >= r) break;
      if (l != r) {
        int par1 = find(l);
        int par2 = find(r);
        if (par1 != par2) union2(par1, par2);
      }
      diff -= 2;
    }
  }
  vector<int> num(n + 2, 0);
  for (i = 0; i < n; i++) {
    num[find(i)] += 1;
  }
  long long ans = 1;
  for (i = 0; i < n; i++) {
    if (num[i] != 0) ans = (ans * m) % mod;
  }
  cout << ans % mod << endl;
}
