#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y / 2;
    x = (x * x) % 1000000007;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t, n, k, j, y, z, c, d, i, q, m, a, b, x, sum, l, r, ans, p;
  t = 1;
  while (t--) {
    cin >> n >> m >> k;
    if (k == 1 || k > n)
      ans = power(m, n);
    else if (k == n)
      ans = power(m, (n + 1) / 2);
    else if (k % 2)
      ans = power(m, 2);
    else
      ans = m;
    cout << ans << endl;
  }
  return 0;
}
