#include <bits/stdc++.h>
using namespace std;
long long binpow(int n, int m, int mod) {
  if (m == 0) {
    return 1;
  }
  if (m % 2 == 1) {
    return (binpow(n, m - 1, mod) * n) % mod;
  } else {
    long long c = binpow(n, m / 2, mod);
    return (c * c) % mod;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  int n, m, k;
  cin >> n >> m >> k;
  long long mod = 1000000007;
  if (k > n || k == 1) {
    cout << binpow(m, n, mod);
  } else if (k == n) {
    cout << binpow(m, (n + 1) / 2, mod);
  } else if (k % 2 == 1) {
    cout << m * m;
  } else {
    cout << m;
  }
  return 0;
}
