#include <bits/stdc++.h>
using namespace std;
int find(int v, vector<int> &p) {
  if (p[v] < 0) return v;
  while (true) {
    if (p[v] == -1) return v;
    v = p[v];
  }
  return 0;
}
long long mod = 1000000007;
long long power(long long m, long long e) {
  long long ans = 1;
  for (long long i = 0; i < e; i++) {
    ans = ans * m;
    ans = ans % mod;
  }
  return ans;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<pair<int, int>> v;
  vector<int> p(n + 1, -1), v1, sz(n + 1, 1);
  for (int i = 0; i < n - k + 1; i++) {
    for (int j = 0; j < k / 2; j++) {
      int x = i + j, y = i + k - 1 - j;
      int x1 = find(x, p), y1 = find(y, p);
      if (x1 != y1) {
        if (sz[x1] < sz[y1]) {
          swap(x, y);
        }
        p[y1] = x1;
        sz[x1] = sz[x1] + sz[y1];
      }
    }
  }
  int e = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] == -1) {
      e++;
    }
  }
  cout << power(m, e) << endl;
}
