#include <bits/stdc++.h>
using namespace std;
const double EPS = 0.0000000001;
const long long mod1 = 998244353;
const long long mod2 = 1000000007;
const long long mod3 = 1000000009;
const long long inf = 1000000000000000000;
long long get(long long n, long long a, long long mod = mod2) {
  if (!a) return 1;
  if (a == 1) return n % mod;
  if (a & 1) return n % mod * get(n, a - 1) % mod;
  return get(n, a / 2) % mod * get(n, a / 2) % mod;
}
signed main() {
  long long a, b, c;
  cin >> a >> b >> c;
  if (a == c) {
    cout << get(b, (a + 1) / 2) % mod2;
    return 0;
  }
  if (c > a) {
    cout << get(b, a) % mod2;
    return 0;
  }
  if (c == 1) {
    cout << get(b, a) % mod2 << endl;
    return 0;
  }
  if (c % 2 == 0) {
    cout << b % mod2;
    return 0;
  }
  cout << b * b % mod2;
}
