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