#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
int n = 0, m = 0, k = 0;
int main() {
  long long ans = 1;
  cin >> n >> m >> k;
  if (k == 1 || k > n) {
    for (int i = 1; i <= n; ++i) {
      ans = ans * m % 1000000007;
    }
  } else if (k == n) {
    for (int i = 1; i <= (n + 1) / 2; ++i) {
      ans = ans * m % 1000000007;
    }
  } else if (k % 2 == 0 && k != n && k != 1 && k < n) {
    ans = m;
  } else if (k % 2 == 1 && k != n && k != 1 && k < n) {
    ans = m * m % 1000000007;
  }
  cout << ans << endl;
  return 0;
}
