#include <bits/stdc++.h>
using namespace std;
long long n, m, k;
long long pwr, ans = 1;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cin.tie(0), cout.tie(0),
      cout.precision(15);
  cin >> n >> m >> k;
  if (k == 1 or k > n) {
    pwr = n;
  } else if (k == n) {
    pwr = (n >> 1) + (n & 1);
  } else if (k & 1) {
    pwr = 2;
  } else {
    pwr = 1;
  }
  while (pwr--) {
    ans *= m;
    ans %= mod;
  }
  cout << ans;
  return 0;
}
