#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
void solve() {
  long long n, m, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n)
    cout << power(m, n, 1000000007) << "\n";
  else if (k == n)
    cout << power(m, (n + 1) / 2, 1000000007);
  else if (k % 2)
    cout << power(m, 2, 1000000007);
  else
    cout << m << "\n";
}
signed main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
