#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007LL;
long long Pow_mod(long long x, long long k, long long m) {
  long long res = 1;
  while (k) {
    x %= m;
    if (k & 1) {
      res *= x;
      res %= m;
    }
    x *= x;
    k >>= 1;
  }
  return res;
}
int main() {
  long long n, m, k;
  cin >> n >> m >> k;
  if (k == 1 || n < k)
    cout << Pow_mod(m, n, mod) << endl;
  else if (n == k)
    cout << Pow_mod(m, (n + 1) / 2, mod) << endl;
  else if (k & 1)
    cout << ((m * m) % mod) << endl;
  else
    cout << (m % mod) << endl;
  return 0;
}
