#include <bits/stdc++.h>
using namespace std;
const int BASE = 1000000007;
int c[2001][2001];
int n, m, k, kk;
int a[5001];
int col[2001];
int main() {
  cin >> n >> m >> k;
  if (k > n || k == 1) {
    long long res = 1;
    for (int i = 1; i <= n; i++) res = (res * m) % BASE;
    cout << res << endl;
    return 0;
  }
  int l = 1;
  int r = k;
  int t = 0;
  while (l <= r) {
    t++;
    a[l] = a[r] = t;
    l++;
    r--;
  }
  for (int p = 2; p <= k; p++) {
    int l = p;
    int r = p + k - 1;
    if (r > n) break;
    a[r] = 10000;
    while (l <= r) {
      int tmin = min(a[r], a[l]);
      int rr = a[r];
      int ll = a[l];
      a[r] = tmin;
      for (int ii = 1; ii <= k; ii++)
        if (a[ii] == rr)
          a[ii] = tmin;
        else if (a[ii] == ll)
          a[ii] = tmin;
      l++;
      r--;
    }
  }
  int tcount = 0;
  for (int i = 1; i <= k; i++) col[a[i]] = 1;
  for (int i = 1; i <= 2000; i++)
    if (col[i] == 1) tcount++;
  long long res = 1;
  for (int i = 1; i <= tcount; i++) {
    res = (m * res) % BASE;
  }
  cout << res << endl;
  return 0;
}
