#include <bits/stdc++.h>
using namespace std;
const int long long mod = 1000 * 1000 * 1000 + 7;
long long pow(long long x, long long k) {
  if (k == 1) return x % mod;
  if (k % 2 == 1) return (pow(x, k - 1) * x) % mod;
  long long t = pow(x, k / 2);
  return (t * t) % mod;
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  if (k == 1 || k > n)
    cout << pow(m, n);
  else if (k == n)
    cout << pow(m, (n + 1) / 2);
  else if (k % 2 == 0)
    cout << m;
  else
    cout << m * m;
  return 0;
}
