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