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