#include <bits/stdc++.h>
using namespace std;
const int dr[]{-1, -1, 0, 1, 1, 1, 0, -1};
const int dc[]{0, 1, 1, 1, 0, -1, -1, -1};
void run() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
struct DSU {
  vector<int> rank, parent, size;
  int forsets;
  DSU(int n) {
    size = rank = parent = vector<int>(n + 1, 1);
    forsets = n;
    for (int i = 0; i <= n; i++) {
      parent[i] = i;
    }
  }
  int find_set(int v) {
    if (v == parent[v]) return v;
    return parent[v] = find_set(parent[v]);
  }
  void link(int par, int node) {
    parent[node] = par;
    size[par] += size[node];
    if (rank[par] == rank[node]) rank[par]++;
    forsets--;
  }
  bool union_sets(int v, int u) {
    v = find_set(v), u = find_set(u);
    if (v == u) return false;
    if (rank[v] < rank[u]) swap(v, u);
    link(v, u);
    return true;
  }
  bool same_set(int v, int u) { return find_set(v) == find_set(u); }
  int size_set(int v) { return size[find_set(v)]; }
};
const int mod = 1e9 + 7;
long long power(long long x, long long y) {
  if (y == 0) return 1;
  if (y == 1) return x;
  long long r = power(x, y >> 1);
  return (((r * r) % mod) * power(x, y & 1)) % mod;
}
int main() {
  run();
  int n, m, k;
  cin >> n >> m >> k;
  DSU uf(n);
  for (int i = 0; i <= n; i++) {
    for (int pos = 0, nxt = k - 1; pos < nxt && pos <= i; pos++, nxt--) {
      if (i + k - pos > n) continue;
      int j = i - pos + nxt;
      if (j < n) uf.union_sets(i, j);
    }
  }
  cout << power(m, uf.forsets) << "\n";
}
