#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvl = vector<vl>;
using ii = pair<int, int>;
using vii = vector<ii>;
using vs = vector<string>;
using msi = map<string, int>;
using iss = istringstream;
ll powmod(ll x, ll n, ll M) {
  if (n == 0) return 1 % M;
  ll half = powmod(x, n / 2, M);
  if (n % 2 == 0) return (half * half) % M;
  return (((half * half) % M) * x) % M;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  const ll M = 1e9 + 7;
  ll n, m, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n)
    cout << powmod(m, n, M) << '\n';
  else if (k == n)
    cout << powmod(m, (n + 1) / 2, M) << '\n';
  else if (k % 2 == 0)
    cout << m << '\n';
  else
    cout << m * m << '\n';
  return 0;
}
