#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y % 2 == 1) res = (res * x) % mod;
    y /= 2;
    x = (x * x) % mod;
  }
  return res % mod;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  if (k > n || k == 1) {
    cout << power(m, n) << '\n';
  } else if (k == n) {
    cout << power(m, (n + 1) / 2) << '\n';
  } else if (k % 2 == 1) {
    cout << (m * m) % mod << '\n';
  } else {
    cout << m << '\n';
  }
  return 0;
}
