#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int modPow(int x, int y) {
  long long res = 1;
  long long a = x;
  while (y > 0) {
    if (y % 2 == 1) {
      res = (res * a) % MOD;
    }
    a = (a * a) % MOD;
    y /= 2;
  }
  return (int)(res);
}
int visited[2000];
void dfs(int x, int n, int k) {
  if (visited[x] == -1) {
    visited[x] = 1;
    for (int p = 0; p < k; p++) {
      int b = x - p;
      if ((b >= 0) && (b + k <= n)) {
        int q = k - p - 1;
        int y = q + b;
        dfs(y, n, k);
      }
    }
  }
}
int solve(int n, int m, int k) {
  memset(visited, -1, sizeof(visited));
  int compos = 0;
  for (int i = 0; i < n; i++) {
    if (visited[i] == -1) {
      compos++;
      dfs(i, n, k);
    }
  }
  return modPow(m, compos);
}
inline void init() {}
int main() {
  init();
  int n, m, k;
  while (cin >> n >> m >> k) {
    cout << solve(n, m, k) << endl;
  }
  return 0;
}
