#include <bits/stdc++.h>
using namespace std;
const int N = 310;
const int mod = 1e9 + 7;
long long Pow(int m, int n) {
  long long res = 1;
  for (int i = 0; i < n; i++) res = (res * m) % mod;
  return res;
}
int main() {
  int m, n, k;
  cin >> m >> n >> k;
  if (k == 1 || k > m)
    cout << Pow(n, m);
  else if (k == m)
    cout << Pow(n, (k + 1) / 2);
  else if (!(k % 2))
    cout << n;
  else if (k % 2)
    cout << (n * n) % mod;
  return 0;
}
