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