#include <bits/stdc++.h>
using namespace std;
long long mypow(long long a, long long b) {
  long long r = 1;
  while (b--) {
    r *= a;
    r %= 1000000007;
  }
  return r;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  if (k != 1 && k < n)
    cout << m + (k % 2) * m * (m - 1) << endl;
  else if (k == n)
    cout << mypow(m, (n + 1) / 2) << endl;
  else
    cout << mypow(m, n) << endl;
}
