#include <bits/stdc++.h>
using namespace std;
int const siz = 1e9, bound = 1e6, mod = siz + 7;
long long const oo = 1e18;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  long long ans = 0;
  if (k == 1 || k > n) {
    for (int(i) = 0; (i) < (n); (i)++) {
      if (ans == 0)
        ans = m;
      else
        ans = (ans * m) % mod;
    }
  } else if (k == n) {
    for (int(i) = 0; (i) < ((n + 1) / 2); (i)++) {
      if (ans == 0)
        ans = m;
      else
        ans = (ans * m) % mod;
    }
  } else if (k % 2 == 1)
    ans = m * m;
  else
    ans = m;
  cout << ans << endl;
  return 0;
}
