#include <bits/stdc++.h>
using namespace std;
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
int XX[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int YY[] = {-1, 0, 1, -1, 1, -1, 0, 1};
long long int parent[100005];
long long int siz[100005];
long long int find_parent(long long int v) {
  if (v == parent[v]) return v;
  return parent[v] = find_parent(parent[v]);
}
void make_set(long long int v) {
  parent[v] = v;
  siz[v] = 1;
}
void union_sets(long long int a, long long int b) {
  long long int pa = find_parent(a);
  long long int emplace_back = find_parent(b);
  if (pa != emplace_back) {
    if (siz[pa] < siz[emplace_back]) swap(pa, emplace_back);
    parent[emplace_back] = pa;
    siz[pa] += siz[emplace_back];
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int n, q, a, b, i, j, m, k;
  cin >> n >> m >> k;
  for (i = 1; i <= n; i++) make_set(i);
  for (i = 0; i <= n - k + 2; i++) {
    j = i + k - 1;
    long long int x, y;
    x = i;
    y = j;
    if (x >= 1 && x <= n && y >= 1 && y <= n) {
      while (x < y) {
        union_sets(x, y);
        x++;
        y--;
      }
    }
  }
  set<long long int> s;
  for (i = 1; i <= n; i++) {
    long long int pi = find_parent(i);
    s.insert(pi);
  }
  long long int ans = 1, count = 0;
  while (count < s.size()) {
    ans *= m;
    ans %= 1000000007;
    count++;
  }
  cout << ans;
}
