#include <bits/stdc++.h>
using namespace std;
long long fp(long long base, long long power) {
  long long result = 1;
  while (power > 0) {
    if (power & 1) result = (result * base) % 1000000007;
    base = (base * base) % 1000000007;
    power >>= 1;
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n)
    cout << fp(m, n) << endl;
  else if (k == n)
    cout << fp(m, (n + 1) / 2) << endl;
  else {
    if (k % 2)
      cout << m * m << endl;
    else
      cout << m << endl;
  }
}
