#include <bits/stdc++.h>
using namespace std;
const int model = 1e9 + 7;
const int maxn = 3000;
bool exist[maxn];
int fa[maxn];
int n, m, k;
int get_ans(int n, int m) {
  long long ans = 1;
  long long x = n;
  while (m) {
    if (m & 1) ans = (ans * x) % model;
    m /= 2;
    x = (x * x) % model;
  }
  return ans;
}
int get_fa(int x) {
  if (fa[x] == x) return x;
  fa[x] = get_fa(fa[x]);
  return fa[x];
}
int main() {
  cin >> n >> m >> k;
  int len = 0;
  if (n < k)
    cout << get_ans(m, n) << endl;
  else {
    for (int i = 1; i <= n; i++) fa[i] = i;
    for (int i = k; i <= n; i++) {
      for (int j = 1; j * 2 <= k; j++) {
        int x = get_fa(i - k + j), y = get_fa(i - j + 1);
        if (x != y) fa[x] = y;
      }
    }
    int len = 0;
    memset(exist, true, sizeof exist);
    for (int i = 1; i <= n; i++) {
      int x = get_fa(i);
      if (exist[x]) {
        len++;
        exist[x] = false;
      }
    }
    cout << get_ans(m, len) << endl;
  }
}
