#include <bits/stdc++.h>
using namespace std;
int n, m, k;
const int MOD = 1000000007;
long long Get(int power) {
  if (power == 0) return 1;
  if (power == 1) return m;
  long long tmp = Get(power / 2);
  tmp = (tmp * tmp) % MOD;
  if (power % 2 == 1) tmp = (tmp * m) % MOD;
  return tmp;
}
void Main(const int cas) {
  if (n < k || k == 1)
    cout << Get(n) << endl;
  else if (n == k)
    cout << Get((n + 1) / 2) << endl;
  else if (n > k) {
    if (k % 2 == 0)
      cout << m << endl;
    else if (k % 2 == 1)
      cout << m * m << endl;
  }
}
int main() {
  int cas = 1;
  while (scanf("%d%d%d", &n, &m, &k) != EOF && (n || m || k)) {
    Main(cas++);
  }
  return 0;
}
